MyGUI
3.0.3
|
00001 00007 /* 00008 This file is part of MyGUI. 00009 00010 MyGUI is free software: you can redistribute it and/or modify 00011 it under the terms of the GNU Lesser General Public License as published by 00012 the Free Software Foundation, either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 MyGUI is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License 00021 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 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(Widget* _widget) 00036 { 00037 _widget->setVisible(false); 00038 } 00039 00040 void actionWidgetShow(Widget* _widget) 00041 { 00042 _widget->setVisible(true); 00043 } 00044 00045 void actionWidgetDestroy(Widget* _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.141593f; 00063 #endif 00064 float k = sin(M_PI * _current_time - M_PI/2.0f); 00065 if (k<0) k = (-pow(-k, 0.7f) + 1)/2; 00066 else k = (pow(k, 0.7f) + 1)/2; 00067 linearMoveFunction(_startRect, _destRect, _result, k); 00068 } 00069 00070 } // namespace action 00071 00072 } // namespace MyGUI