MyGUI  3.2.0
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  {
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
const float M_PI
void set(T const &_left, T const &_top, T const &_width, T const &_height)
Definition: MyGUI_TCoord.h:180
static WidgetManager & getInstance()
void destroyWidget(Widget *_widget)
virtual void setVisible(bool _value)
void inertionalMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _current_time)
void linearMoveFunction(const IntCoord &_startRect, const IntCoord &_destRect, IntCoord &_result, float _k)
void actionWidgetDestroy(Widget *_widget)
void actionWidgetHide(Widget *_widget)
void actionWidgetShow(Widget *_widget)