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"
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
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)
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")
77 else if (_key == "Coef")
79 else if (_key == "Enabled")
81 }
82
84 {
85 mAlpha = _value;
86 }
87
89 {
90 mCoef = _value;
91 }
92
94 {
95 mEnabled = _value;
96 }
97
98} // namespace MyGUI
void setProperty(std::string_view _key, std::string_view _value) override
void prepareItem(Widget *_widget) override
bool addTime(Widget *_widget, float _time) override
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPreAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPostAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventUpdateAction
void unlinkWidget(Widget *_widget)
static InputManager & getInstance()
widget description should be here.
void setAlpha(float _alpha)
virtual void setVisible(bool _value)
bool getVisible() const
float getAlpha() const
void setEnabledSilent(bool _value)
T parseValue(std::string_view _value)
constexpr float ALPHA_MIN