MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #include "MyGUI_Precompiled.h" 00008 #include "MyGUI_ActionController.h" 00009 #include "MyGUI_Widget.h" 00010 #include "MyGUI_WidgetManager.h" 00011 00012 namespace MyGUI 00013 { 00014 00015 namespace action 00016 { 00017 00018 void actionWidgetHide(Widget* _widget, ControllerItem* _controller) 00019 { 00020 _widget->setVisible(false); 00021 } 00022 00023 void actionWidgetShow(Widget* _widget, ControllerItem* _controller) 00024 { 00025 _widget->setVisible(true); 00026 } 00027 00028 void actionWidgetDestroy(Widget* _widget, ControllerItem* _controller) 00029 { 00030 WidgetManager::getInstance().destroyWidget(_widget); 00031 } 00032 00033 void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k) 00034 { 00035 _result.set( 00036 _startRect.left - int( float(_startRect.left - _destRect.left) * _k ), 00037 _startRect.top - int( float(_startRect.top - _destRect.top) * _k ), 00038 _startRect.width - int( float(_startRect.width - _destRect.width) * _k ), 00039 _startRect.height - int( float(_startRect.height - _destRect.height) * _k )); 00040 } 00041 00042 void inertionalMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _current_time) 00043 { 00044 #ifndef M_PI 00045 const float M_PI = 3.141593f; 00046 #endif 00047 float k = sin(M_PI * _current_time - M_PI / 2.0f); 00048 if (k < 0) k = (-pow(-k, 0.7f) + 1) / 2; 00049 else k = (pow(k, 0.7f) + 1) / 2; 00050 linearMoveFunction(_startRect, _destRect, _result, k); 00051 } 00052 00053 } // namespace action 00054 00055 } // namespace MyGUI