MyGUI 3.4.3
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::action
13{
14
15 void actionWidgetHide(Widget* _widget, ControllerItem* _controller)
16 {
17 _widget->setVisible(false);
18 }
19
20 void actionWidgetShow(Widget* _widget, ControllerItem* _controller)
21 {
22 _widget->setVisible(true);
23 }
24
25 void actionWidgetDestroy(Widget* _widget, ControllerItem* _controller)
26 {
28 }
29
30 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
31 {
32 _result.set(
33 _startRect.left - int(float(_startRect.left - _destRect.left) * _k),
34 _startRect.top - int(float(_startRect.top - _destRect.top) * _k),
35 _startRect.width - int(float(_startRect.width - _destRect.width) * _k),
36 _startRect.height - int(float(_startRect.height - _destRect.height) * _k));
37 }
38
40 const IntCoord& _startRect,
41 const IntCoord& _destRect,
42 IntCoord& _result,
43 float _current_time)
44 {
45#ifdef M_PI
46 #undef M_PI
47#endif
48 const float M_PI = 3.141593f;
49 float k = std::sin(M_PI * _current_time - M_PI / 2.0f);
50 if (k < 0)
51 k = (-std::pow(-k, 0.7f) + 1) / 2;
52 else
53 k = (std::pow(k, 0.7f) + 1) / 2;
54 linearMoveFunction(_startRect, _destRect, _result, k);
55 }
56
57} // namespace MyGUI
widget description should be here.
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)
void set(T const &_left, T const &_top, T const &_width, T const &_height)