MyGUI_ControllerFadeAlpha.cpp
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#include "MyGUI_Precompiled.h"
#include "MyGUI_ControllerFadeAlpha.h"
#include "MyGUI_Gui.h"
#include "MyGUI_InputManager.h"
#include "MyGUI_WidgetManager.h"
#include "MyGUI_Widget.h"
namespace MyGUI
{
void ControllerFadeAlpha::prepareItem(Widget* _widget)
{
// подготовка виджета, блокируем если только нужно
if (!mEnabled)
_widget->setEnabledSilent(mEnabled);
if ((ALPHA_MIN != mAlpha) && (!_widget->getVisible()))
{
_widget->setAlpha(ALPHA_MIN);
_widget->setVisible(true);
}
// отписываем его от ввода
if (!mEnabled)
InputManager::getInstance().unlinkWidget(_widget);
// вызываем пользовательский делегат для подготовки
eventPreAction(_widget, this);
}
bool ControllerFadeAlpha::addTime(Widget* _widget, float _time)
{
float alpha = _widget->getAlpha();
// проверяем нужно ли к чему еще стремиться
if (mAlpha > alpha)
{
alpha += _time * mCoef;
if (mAlpha > alpha)
{
_widget->setAlpha(alpha);
eventUpdateAction(_widget, this);
return true;
}
_widget->setAlpha(mAlpha);
}
else if (mAlpha < alpha)
{
alpha -= _time * mCoef;
if (mAlpha < alpha)
{
_widget->setAlpha(alpha);
eventUpdateAction(_widget, this);
return true;
}
_widget->setAlpha(mAlpha);
}
// вызываем пользовательский делегат пост обработки
eventPostAction(_widget, this);
return false;
}
void ControllerFadeAlpha::setProperty(std::string_view _key, std::string_view _value)
{
if (_key == "Alpha")
setAlpha(utility::parseValue<float>(_value));
else if (_key == "Coef")
setCoef(utility::parseValue<float>(_value));
else if (_key == "Enabled")
setEnabled(utility::parseValue<bool>(_value));
}
void ControllerFadeAlpha::setAlpha(float _value)
{
mAlpha = _value;
}
void ControllerFadeAlpha::setCoef(float _value)
{
mCoef = _value;
}
void ControllerFadeAlpha::setEnabled(bool _value)
{
mEnabled = _value;
}
} // 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