MyGUI  3.2.0
MyGUI_ActionController.cpp
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_ActionController.h"
00025 #include "MyGUI_Widget.h"
00026 #include "MyGUI_WidgetManager.h"
00027 
00028 namespace MyGUI
00029 {
00030 
00031     namespace action
00032     {
00033 
00034         void actionWidgetHide(Widget* _widget)
00035         {
00036             _widget->setVisible(false);
00037         }
00038 
00039         void actionWidgetShow(Widget* _widget)
00040         {
00041             _widget->setVisible(true);
00042         }
00043 
00044         void actionWidgetDestroy(Widget* _widget)
00045         {
00046             WidgetManager::getInstance().destroyWidget(_widget);
00047         }
00048 
00049         void linearMoveFunction(const IntCoord& _startRect, const IntCoord& _destRect, IntCoord& _result, float _k)
00050         {
00051             _result.set(
00052                 _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