MyGUI_ActionController.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_ActionController.h"
#include "MyGUI_Widget.h"
#include "MyGUI_WidgetManager.h"
namespace MyGUI::action
{
void actionWidgetHide(Widget* _widget, ControllerItem* _controller)
{
_widget->setVisible(false);
}
void actionWidgetShow(Widget* _widget, ControllerItem* _controller)
{
_widget->setVisible(true);
}
void actionWidgetDestroy(Widget* _widget, ControllerItem* _controller)
{
WidgetManager::getInstance().destroyWidget(_widget);
}
void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
{
_result.set(
_startRect.left - int(float(_startRect.left - _destRect.left) * _k),
_startRect.top - int(float(_startRect.top - _destRect.top) * _k),
_startRect.width - int(float(_startRect.width - _destRect.width) * _k),
_startRect.height - int(float(_startRect.height - _destRect.height) * _k));
}
void inertionalMoveFunction(
const IntCoord& _startRect,
const IntCoord& _destRect,
IntCoord& _result,
float _current_time)
{
#ifdef M_PI
#undef M_PI
#endif
const float M_PI = 3.141593f;
float k = std::sin(M_PI * _current_time - M_PI / 2.0f);
if (k < 0)
k = (-std::pow(-k, 0.7f) + 1) / 2;
else
k = (std::pow(k, 0.7f) + 1) / 2;
linearMoveFunction(_startRect, _destRect, _result, k);
}
} // namespace MyGUI
MyGUI_ActionController.h
MyGUI_Precompiled.h
MyGUI_Widget.h
MyGUI_WidgetManager.h
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:26
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition MyGUI_Widget.cpp:1022
MyGUI::WidgetManager::getInstance
static WidgetManager & getInstance()
MyGUI::WidgetManager::destroyWidget
void destroyWidget(Widget *_widget)
Definition MyGUI_WidgetManager.cpp:123
MyGUI::action
Definition MyGUI_ActionController.h:19
MyGUI::action::actionWidgetDestroy
void actionWidgetDestroy(Widget *_widget, ControllerItem *_controller)
Definition MyGUI_ActionController.cpp:25
MyGUI::action::linearMoveFunction
void linearMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _k)
Definition MyGUI_ActionController.cpp:30
MyGUI::action::inertionalMoveFunction
void inertionalMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _current_time)
Definition MyGUI_ActionController.cpp:39
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget, ControllerItem *_controller)
Definition MyGUI_ActionController.cpp:15
MyGUI::action::actionWidgetShow
void actionWidgetShow(Widget *_widget, ControllerItem *_controller)
Definition MyGUI_ActionController.cpp:20
MyGUI::M_PI
const float M_PI
Definition MyGUI_ControllerEdgeHide.cpp:20
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::types::TCoord::height
T height
Definition MyGUI_TCoord.h:23
MyGUI::types::TCoord::width
T width
Definition MyGUI_TCoord.h:22
MyGUI::types::TCoord::set
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition MyGUI_TCoord.h:140
MyGUI::types::TCoord::top
T top
Definition MyGUI_TCoord.h:21
MyGUI::types::TCoord::left
T left
Definition MyGUI_TCoord.h:20