MyGUI: MyGUI_ControllerFadeAlpha.cpp Source File

MyGUI 3.4.3

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 void ControllerFadeAlpha::prepareItem(Widget* _widget)
18 {
19 // подготовка виджета, блокируем если только нужно
20 if (!mEnabled)
21 _widget->setEnabledSilent(mEnabled);
22
23 if ((ALPHA_MIN != mAlpha) && (!_widget->getVisible()))
24 {
25 _widget->setAlpha(ALPHA_MIN);
26 _widget->setVisible(true);
27 }
28
29 // отписываем его от ввода
30 if (!mEnabled)
31 InputManager::getInstance().unlinkWidget(_widget);
32
33 // вызываем пользовательский делегат для подготовки
34 eventPreAction(_widget, this);
35 }
36
37 bool ControllerFadeAlpha::addTime(Widget* _widget, float _time)
38 {
39 float alpha = _widget->getAlpha();
40
41 // проверяем нужно ли к чему еще стремиться
42 if (mAlpha > alpha)
43 {
44 alpha += _time * mCoef;
45 if (mAlpha > alpha)
46 {
47 _widget->setAlpha(alpha);
48 eventUpdateAction(_widget, this);
49 return true;
50 }
51
52 _widget->setAlpha(mAlpha);
53 }
54 else if (mAlpha < alpha)
55 {
56 alpha -= _time * mCoef;
57 if (mAlpha < alpha)
58 {
59 _widget->setAlpha(alpha);
60 eventUpdateAction(_widget, this);
61 return true;
62 }
63
64 _widget->setAlpha(mAlpha);
65 }
66
67 // вызываем пользовательский делегат пост обработки
68 eventPostAction(_widget, this);
69
70 return false;
71 }
72
73 void ControllerFadeAlpha::setProperty(std::string_view _key, std::string_view _value)
74 {
75 if (_key == "Alpha")
76 setAlpha(utility::parseValue<float>(_value));
77 else if (_key == "Coef")
78 setCoef(utility::parseValue<float>(_value));
79 else if (_key == "Enabled")
80 setEnabled(utility::parseValue<bool>(_value));
81 }
82
83 void ControllerFadeAlpha::setAlpha(float _value)
84 {
85 mAlpha = _value;
86 }
87
88 void ControllerFadeAlpha::setCoef(float _value)
89 {
90 mCoef = _value;
91 }
92
93 void ControllerFadeAlpha::setEnabled(bool _value)
94 {
95 mEnabled = _value;
96 }
97
98} // namespace MyGUI
MyGUI_ControllerFadeAlpha.h
MyGUI_Gui.h
MyGUI_InputManager.h
MyGUI_Precompiled.h
MyGUI_Widget.h
MyGUI_WidgetManager.h
MyGUI::ControllerFadeAlpha::setProperty
void setProperty(std::string_view _key, std::string_view _value) override
Definition MyGUI_ControllerFadeAlpha.cpp:73
MyGUI::ControllerFadeAlpha::setAlpha
void setAlpha(float _value)
Definition MyGUI_ControllerFadeAlpha.cpp:83
MyGUI::ControllerFadeAlpha::prepareItem
void prepareItem(Widget *_widget) override
Definition MyGUI_ControllerFadeAlpha.cpp:17
MyGUI::ControllerFadeAlpha::setCoef
void setCoef(float _value)
Definition MyGUI_ControllerFadeAlpha.cpp:88
MyGUI::ControllerFadeAlpha::setEnabled
void setEnabled(bool _value)
Definition MyGUI_ControllerFadeAlpha.cpp:93
MyGUI::ControllerFadeAlpha::addTime
bool addTime(Widget *_widget, float _time) override
Definition MyGUI_ControllerFadeAlpha.cpp:37
MyGUI::ControllerItem::eventPreAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPreAction
Definition MyGUI_ControllerItem.h:41
MyGUI::ControllerItem::eventPostAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPostAction
Definition MyGUI_ControllerItem.h:53
MyGUI::ControllerItem::eventUpdateAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventUpdateAction
Definition MyGUI_ControllerItem.h:47
MyGUI::InputManager::unlinkWidget
void unlinkWidget(Widget *_widget)
Definition MyGUI_InputManager.cpp:695
MyGUI::InputManager::getInstance
static InputManager & getInstance()
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::Widget::setAlpha
void setAlpha(float _alpha)
Definition MyGUI_Widget.cpp:466
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition MyGUI_Widget.cpp:1022
MyGUI::Widget::getVisible
bool getVisible() const
Definition MyGUI_Widget.cpp:1327
MyGUI::Widget::getAlpha
float getAlpha() const
Definition MyGUI_Widget.cpp:1337
MyGUI::Widget::setEnabledSilent
void setEnabledSilent(bool _value)
Definition MyGUI_Widget.cpp:1357
MyGUI::utility::parseValue
T parseValue(std::string_view _value)
Definition MyGUI_StringUtility.h:60
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::ALPHA_MIN
constexpr float ALPHA_MIN
Definition MyGUI_Macros.h:21