MyGUI  3.2.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 
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  {
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