MyGUI 3.2.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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
12 namespace MyGUI
13 {
14
15 namespace action
16 {
17
18 void actionWidgetHide(Widget* _widget, ControllerItem* _controller)
19 {
20 _widget->setVisible(false);
21 }
22
23 void actionWidgetShow(Widget* _widget, ControllerItem* _controller)
24 {
25 _widget->setVisible(true);
26 }
27
28 void actionWidgetDestroy(Widget* _widget, ControllerItem* _controller)
29 {
30 WidgetManager::getInstance().destroyWidget(_widget);
31 }
32
33 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
34 {
35 _result.set(
36 _startRect.left - int( float(_startRect.left - _destRect.left) * _k ),
37 _startRect.top - int( float(_startRect.top - _destRect.top) * _k ),
38 _startRect.width - int( float(_startRect.width - _destRect.width) * _k ),
39 _startRect.height - int( float(_startRect.height - _destRect.height) * _k ));
40 }
41
42 void inertionalMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _current_time)
43 {
44 #ifndef M_PI
45 const float M_PI = 3.141593f;
46 #endif
47 float k = sin(M_PI * _current_time - M_PI / 2.0f);
48 if (k < 0) k = (-pow(-k, 0.7f) + 1) / 2;
49 else k = (pow(k, 0.7f) + 1) / 2;
50 linearMoveFunction(_startRect, _destRect, _result, k);
51 }
52
53 } // namespace action
54
55 } // namespace MyGUI
MyGUI::types::TCoord
Definition: MyGUI_TCoord.h:20
MyGUI::Widget
Widget properties. Widget_skin_childs Skin childs. Widget widget description should be here...
Definition: MyGUI_Widget.h:29
MyGUI_ActionController.h
MyGUI_Precompiled.h
MyGUI::M_PI
const float M_PI
Definition: MyGUI_ControllerEdgeHide.cpp:18
MyGUI::types::TCoord::set
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition: MyGUI_TCoord.h:165
MyGUI::Singleton< WidgetManager >::getInstance
static WidgetManager & getInstance()
Definition: MyGUI_Singleton.h:38
MyGUI_WidgetManager.h
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget, ControllerItem *_controller)
Definition: MyGUI_ActionController.cpp:18
MyGUI::WidgetManager::destroyWidget
void destroyWidget(Widget *_widget)
Definition: MyGUI_WidgetManager.cpp:118
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition: MyGUI_Widget.cpp:965
MyGUI::action::inertionalMoveFunction
void inertionalMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _current_time)
Definition: MyGUI_ActionController.cpp:42
MyGUI::action::actionWidgetDestroy
void actionWidgetDestroy(Widget *_widget, ControllerItem *_controller)
Definition: MyGUI_ActionController.cpp:28
MyGUI::action::linearMoveFunction
void linearMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _k)
Definition: MyGUI_ActionController.cpp:33
MyGUI::types::TCoord::width
T width
Definition: MyGUI_TCoord.h:24
MyGUI::types::TCoord::top
T top
Definition: MyGUI_TCoord.h:23
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::action::actionWidgetShow
void actionWidgetShow(Widget *_widget, ControllerItem *_controller)
Definition: MyGUI_ActionController.cpp:23
MyGUI_Widget.h
MyGUI::ControllerItem
Definition: MyGUI_ControllerItem.h:25
MyGUI::types::TCoord::left
T left
Definition: MyGUI_TCoord.h:22
MyGUI::types::TCoord::height
T height
Definition: MyGUI_TCoord.h:25