MyGUI  3.0.1
MyGUI_ActionController.cpp
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #include "MyGUI_Precompiled.h"
25 #include "MyGUI_ActionController.h"
26 #include "MyGUI_Widget.h"
27 #include "MyGUI_WidgetManager.h"
28 
29 namespace MyGUI
30 {
31 
32  namespace action
33  {
34 
35  void actionWidgetHide(Widget* _widget)
36  {
37  _widget->setVisible(false);
38  }
39 
40  void actionWidgetShow(Widget* _widget)
41  {
42  _widget->setVisible(true);
43  }
44 
45  void actionWidgetDestroy(Widget* _widget)
46  {
48  }
49 
50  void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
51  {
52  _result.set(_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