MyGUI 3.4.1
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"
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 {
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
widget description should be here.
Definition: MyGUI_Widget.h:37
virtual void setVisible(bool _value)
static WidgetManager & getInstance()
void destroyWidget(Widget *_widget)
void actionWidgetDestroy(Widget *_widget, ControllerItem *_controller)
void linearMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _k)
void inertionalMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _current_time)
void actionWidgetHide(Widget *_widget, ControllerItem *_controller)
void actionWidgetShow(Widget *_widget, ControllerItem *_controller)
const float M_PI
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition: MyGUI_TCoord.h:165