MyGUI 3.2.0

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

- File List
- Globals

MyGUI_ActionController.cpp
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "MyGUI_Precompiled.h"
24 #include "MyGUI_ActionController.h"
25 #include "MyGUI_Widget.h"
26 #include "MyGUI_WidgetManager.h"
27
28 namespace MyGUI
29 {
30
31 namespace action
32 {
33
34 void actionWidgetHide(Widget* _widget)
35 {
36 _widget->setVisible(false);
37 }
38
39 void actionWidgetShow(Widget* _widget)
40 {
41 _widget->setVisible(true);
42 }
43
44 void actionWidgetDestroy(Widget* _widget)
45 {
46 WidgetManager::getInstance().destroyWidget(_widget);
47 }
48
49 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
50 {
51 _result.set(
52 _startRect.left - int( float(_startRect.left - _destRect.left) * _k ),
53 _startRect.top - int( float(_startRect.top - _destRect.top) * _k ),
54 _startRect.width - int( float(_startRect.width - _destRect.width) * _k ),
55 _startRect.height - int( float(_startRect.height - _destRect.height) * _k )
56 );
57 }
58
59 void inertionalMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _current_time)
60 {
61 #ifndef M_PI
62 const float M_PI = 3.141593f;
63 #endif
64 float k = sin(M_PI * _current_time - M_PI / 2.0f);
65 if (k < 0) k = (-pow(-k, 0.7f) + 1) / 2;
66 else k = (pow(k, 0.7f) + 1) / 2;
67 linearMoveFunction(_startRect, _destRect, _result, k);
68 }
69
70 } // namespace action
71
72 } // namespace MyGUI
MyGUI::types::TCoord
Definition: MyGUI_TCoord.h:35
MyGUI::Widget
Definition: MyGUI_Widget.h:41
MyGUI_ActionController.h
MyGUI_Precompiled.h
MyGUI::M_PI
const float M_PI
Definition: MyGUI_ControllerEdgeHide.cpp:33
MyGUI::types::TCoord::set
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition: MyGUI_TCoord.h:180
MyGUI::Singleton< WidgetManager >::getInstance
static WidgetManager & getInstance()
Definition: MyGUI_Singleton.h:53
MyGUI_WidgetManager.h
MyGUI::WidgetManager::destroyWidget
void destroyWidget(Widget *_widget)
Definition: MyGUI_WidgetManager.cpp:132
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:59
MyGUI::action::linearMoveFunction
void linearMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _k)
Definition: MyGUI_ActionController.cpp:49
MyGUI::types::TCoord::width
T width
Definition: MyGUI_TCoord.h:39
MyGUI::types::TCoord::top
T top
Definition: MyGUI_TCoord.h:38
MyGUI::action::actionWidgetDestroy
void actionWidgetDestroy(Widget *_widget)
Definition: MyGUI_ActionController.cpp:44
MyGUI_Widget.h
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget)
Definition: MyGUI_ActionController.cpp:34
MyGUI::types::TCoord::left
T left
Definition: MyGUI_TCoord.h:37
MyGUI::action::actionWidgetShow
void actionWidgetShow(Widget *_widget)
Definition: MyGUI_ActionController.cpp:39
MyGUI::types::TCoord::height
T height
Definition: MyGUI_TCoord.h:40