MyGUI: MyGUI_ActionController.cpp Source File

MyGUI 3.4.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
12namespace 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#ifdef M_PI
45#undef M_PI
46#endif
47 const float M_PI = 3.141593f;
48 float k = std::sin(M_PI * _current_time - M_PI / 2.0f);
49 if (k < 0) k = (-std::pow(-k, 0.7f) + 1) / 2;
50 else k = (std::pow(k, 0.7f) + 1) / 2;
51 linearMoveFunction(_startRect, _destRect, _result, k);
52 }
53
54 } // namespace action
55
56} // namespace MyGUI
MyGUI_ActionController.h
MyGUI_Precompiled.h
MyGUI_Widget.h
MyGUI_WidgetManager.h
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:27
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition MyGUI_Widget.cpp:959
MyGUI::WidgetManager::getInstance
static WidgetManager & getInstance()
MyGUI::WidgetManager::destroyWidget
void destroyWidget(Widget *_widget)
Definition MyGUI_WidgetManager.cpp:118
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::action::inertionalMoveFunction
void inertionalMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _current_time)
Definition MyGUI_ActionController.cpp:42
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget, ControllerItem *_controller)
Definition MyGUI_ActionController.cpp:18
MyGUI::action::actionWidgetShow
void actionWidgetShow(Widget *_widget, ControllerItem *_controller)
Definition MyGUI_ActionController.cpp:23
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::M_PI
const float M_PI
Definition MyGUI_ControllerEdgeHide.cpp:20
MyGUI::types::TCoord< int >
MyGUI::types::TCoord::height
T height
Definition MyGUI_TCoord.h:25
MyGUI::types::TCoord::width
T width
Definition MyGUI_TCoord.h:24
MyGUI::types::TCoord::set
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition MyGUI_TCoord.h:165
MyGUI::types::TCoord::top
T top
Definition MyGUI_TCoord.h:23
MyGUI::types::TCoord::left
T left
Definition MyGUI_TCoord.h:22