MyGUI: MyGUI_ActionController.cpp Source File

MyGUI 3.4.3

MyGUI_ActionController.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_ActionController.h"
9#include "MyGUI_Widget.h"
10#include "MyGUI_WidgetManager.h"
11
12namespace MyGUI::action
13{
14
15 void actionWidgetHide(Widget* _widget, ControllerItem* _controller)
16 {
17 _widget->setVisible(false);
18 }
19
20 void actionWidgetShow(Widget* _widget, ControllerItem* _controller)
21 {
22 _widget->setVisible(true);
23 }
24
25 void actionWidgetDestroy(Widget* _widget, ControllerItem* _controller)
26 {
27 WidgetManager::getInstance().destroyWidget(_widget);
28 }
29
30 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
31 {
32 _result.set(
33 _startRect.left - int(float(_startRect.left - _destRect.left) * _k),
34 _startRect.top - int(float(_startRect.top - _destRect.top) * _k),
35 _startRect.width - int(float(_startRect.width - _destRect.width) * _k),
36 _startRect.height - int(float(_startRect.height - _destRect.height) * _k));
37 }
38
39 void inertionalMoveFunction(
40 const IntCoord& _startRect,
41 const IntCoord& _destRect,
42 IntCoord& _result,
43 float _current_time)
44 {
45#ifdef M_PI
46 #undef M_PI
47#endif
48 const float M_PI = 3.141593f;
49 float k = std::sin(M_PI * _current_time - M_PI / 2.0f);
50 if (k < 0)
51 k = (-std::pow(-k, 0.7f) + 1) / 2;
52 else
53 k = (std::pow(k, 0.7f) + 1) / 2;
54 linearMoveFunction(_startRect, _destRect, _result, k);
55 }
56
57} // 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