00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "MyGUI_Precompiled.h"
00025 #include "MyGUI_ActionController.h"
00026 #include "MyGUI_Widget.h"
00027 #include "MyGUI_WidgetManager.h"
00028
00029 namespace MyGUI
00030 {
00031
00032 namespace action
00033 {
00034
00035 void actionWidgetHide(WidgetPtr _widget)
00036 {
00037 _widget->setVisible(false);
00038 }
00039
00040 void actionWidgetShow(WidgetPtr _widget)
00041 {
00042 _widget->setVisible(true);
00043 }
00044
00045 void actionWidgetDestroy(WidgetPtr _widget)
00046 {
00047 WidgetManager::getInstance().destroyWidget(_widget);
00048 }
00049
00050 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
00051 {
00052 _result.set(_startRect.left - int( float(_startRect.left - _destRect.left) * _k ),
00053 _startRect.top - int( float(_startRect.top - _destRect.top) * _k ),
00054 _startRect.width - int( float(_startRect.width - _destRect.width) * _k ),
00055 _startRect.height - int( float(_startRect.height - _destRect.height) * _k )
00056 );
00057 }
00058
00059 void inertionalMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _current_time)
00060 {
00061 #ifndef M_PI
00062 const float M_PI = 3.141593;
00063 #endif
00064 double k = sin(M_PI * _current_time - M_PI/2);
00065 if (k<0) k = (-pow((-k), (double)0.7) + 1)/2;
00066 else k = (pow((k), (double)0.7) + 1)/2;
00067 linearMoveFunction(_startRect, _destRect, _result, (float)k);
00068 }
00069
00070 }
00071
00072 }