MyGUI: MyGUI_ControllerFadeAlpha.cpp Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_ControllerFadeAlpha.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
8#include "MyGUI_ControllerFadeAlpha.h"
9#include "MyGUI_Gui.h"
10#include "MyGUI_InputManager.h"
11#include "MyGUI_WidgetManager.h"
12#include "MyGUI_Widget.h"
13
14namespace MyGUI
15{
16
17 ControllerFadeAlpha::ControllerFadeAlpha() :
18 mAlpha(1),
19 mCoef(1),
20 mEnabled(true)
21 {
22 }
23
24 void ControllerFadeAlpha::prepareItem(Widget* _widget)
25 {
26 // подготовка виджета, блокируем если только нужно
27 if (!mEnabled) _widget->setEnabledSilent(mEnabled);
28
29 if ((ALPHA_MIN != mAlpha) && (!_widget->getVisible()))
30 {
31 _widget->setAlpha(ALPHA_MIN);
32 _widget->setVisible(true);
33 }
34
35 // отписываем его от ввода
36 if (!mEnabled) InputManager::getInstance().unlinkWidget(_widget);
37
38 // вызываем пользовательский делегат для подготовки
39 eventPreAction(_widget, this);
40 }
41
42 bool ControllerFadeAlpha::addTime(Widget* _widget, float _time)
43 {
44 float alpha = _widget->getAlpha();
45
46 // проверяем нужно ли к чему еще стремиться
47 if (mAlpha > alpha)
48 {
49 alpha += _time * mCoef;
50 if (mAlpha > alpha)
51 {
52 _widget->setAlpha(alpha);
53 eventUpdateAction(_widget, this);
54 return true;
55 }
56 else
57 {
58 _widget->setAlpha(mAlpha);
59 }
60 }
61 else if (mAlpha < alpha)
62 {
63 alpha -= _time * mCoef;
64 if (mAlpha < alpha)
65 {
66 _widget->setAlpha(alpha);
67 eventUpdateAction(_widget, this);
68 return true;
69 }
70 else
71 {
72 _widget->setAlpha(mAlpha);
73 }
74 }
75
76 // вызываем пользовательский делегат пост обработки
77 eventPostAction(_widget, this);
78
79 return false;
80 }
81
82 void ControllerFadeAlpha::setProperty(const std::string& _key, const std::string& _value)
83 {
84 if (_key == "Alpha")
85 setAlpha(utility::parseValue<float>(_value));
86 else if (_key == "Coef")
87 setCoef(utility::parseValue<float>(_value));
88 else if (_key == "Enabled")
89 setEnabled(utility::parseValue<bool>(_value));
90 }
91
92 void ControllerFadeAlpha::setAlpha(float _value)
93 {
94 mAlpha = _value;
95 }
96
97 void ControllerFadeAlpha::setCoef(float _value)
98 {
99 mCoef = _value;
100 }
101
102 void ControllerFadeAlpha::setEnabled(bool _value)
103 {
104 mEnabled = _value;
105 }
106
107} // namespace MyGUI
MyGUI_ControllerFadeAlpha.h
MyGUI_Gui.h
MyGUI_InputManager.h
MyGUI_Precompiled.h
MyGUI_Widget.h
MyGUI_WidgetManager.h
MyGUI::ControllerFadeAlpha::ControllerFadeAlpha
ControllerFadeAlpha()
Definition MyGUI_ControllerFadeAlpha.cpp:17
MyGUI::ControllerFadeAlpha::setAlpha
void setAlpha(float _value)
Definition MyGUI_ControllerFadeAlpha.cpp:92
MyGUI::ControllerFadeAlpha::prepareItem
void prepareItem(Widget *_widget) override
Definition MyGUI_ControllerFadeAlpha.cpp:24
MyGUI::ControllerFadeAlpha::setCoef
void setCoef(float _value)
Definition MyGUI_ControllerFadeAlpha.cpp:97
MyGUI::ControllerFadeAlpha::setProperty
void setProperty(const std::string &_key, const std::string &_value) override
Definition MyGUI_ControllerFadeAlpha.cpp:82
MyGUI::ControllerFadeAlpha::setEnabled
void setEnabled(bool _value)
Definition MyGUI_ControllerFadeAlpha.cpp:102
MyGUI::ControllerFadeAlpha::addTime
bool addTime(Widget *_widget, float _time) override
Definition MyGUI_ControllerFadeAlpha.cpp:42
MyGUI::ControllerItem::eventPreAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPreAction
Definition MyGUI_ControllerItem.h:42
MyGUI::ControllerItem::eventPostAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPostAction
Definition MyGUI_ControllerItem.h:54
MyGUI::ControllerItem::eventUpdateAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventUpdateAction
Definition MyGUI_ControllerItem.h:48
MyGUI::InputManager::unlinkWidget
void unlinkWidget(Widget *_widget)
Definition MyGUI_InputManager.cpp:704
MyGUI::InputManager::getInstance
static InputManager & getInstance()
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::Widget::setAlpha
void setAlpha(float _value)
Definition MyGUI_Widget.cpp:434
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition MyGUI_Widget.cpp:959
MyGUI::Widget::getVisible
bool getVisible() const
Definition MyGUI_Widget.cpp:1250
MyGUI::Widget::getAlpha
float getAlpha() const
Definition MyGUI_Widget.cpp:1260
MyGUI::Widget::setEnabledSilent
void setEnabledSilent(bool _value)
Definition MyGUI_Widget.cpp:1280
MyGUI::utility::parseValue
T parseValue(const std::string &_value)
Definition MyGUI_StringUtility.h:112
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::ALPHA_MIN
const float ALPHA_MIN
Definition MyGUI_Macros.h:21