00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_ControllerFadeAlpha.h"
00025 #include "MyGUI_Gui.h"
00026 #include "MyGUI_InputManager.h"
00027 #include "MyGUI_WidgetManager.h"
00028 #include "MyGUI_Widget.h"
00029
00030 namespace MyGUI
00031 {
00032
00033 ControllerFadeAlpha::ControllerFadeAlpha() :
00034 mAlpha(1),
00035 mCoef(1),
00036 mEnabled(true)
00037 {
00038 }
00039
00040 void ControllerFadeAlpha::prepareItem(WidgetPtr _widget)
00041 {
00042
00043 if (!mEnabled) _widget->setEnabledSilent(mEnabled);
00044
00045 if ((ALPHA_MIN != mAlpha) && (false == _widget->isVisible()))
00046 {
00047 _widget->setAlpha(ALPHA_MIN);
00048 _widget->setVisible(true);
00049 }
00050
00051
00052 if (false == mEnabled) InputManager::getInstance().unlinkWidget(_widget);
00053
00054
00055 eventPreAction(_widget);
00056 }
00057
00058 bool ControllerFadeAlpha::addTime(WidgetPtr _widget, float _time)
00059 {
00060 float alpha = _widget->getAlpha();
00061
00062
00063 if (mAlpha > alpha)
00064 {
00065 alpha += _time * mCoef;
00066 if (mAlpha > alpha)
00067 {
00068 _widget->setAlpha(alpha);
00069 eventUpdateAction(_widget);
00070 return true;
00071 }
00072 else
00073 {
00074 _widget->setAlpha(mAlpha);
00075 }
00076 }
00077 else if (mAlpha < alpha)
00078 {
00079 alpha -= _time * mCoef;
00080 if (mAlpha < alpha)
00081 {
00082 _widget->setAlpha(alpha);
00083 eventUpdateAction(_widget);
00084 return true;
00085 }
00086 else
00087 {
00088 _widget->setAlpha(mAlpha);
00089 }
00090 }
00091
00092
00093 eventPostAction(_widget);
00094
00095 return false;
00096 }
00097
00098 void ControllerFadeAlpha::setProperty(const std::string& _key, const std::string& _value)
00099 {
00100 if (_key == "Alpha") setAlpha(utility::parseValue<float>(_value));
00101 else if (_key == "Coef") setCoef(utility::parseValue<float>(_value));
00102 else if (_key == "Enabled") setEnabled(utility::parseValue<bool>(_value));
00103 }
00104
00105 }