Crazy Eddie's GUI System  0.8.4
AnimationInstance.h
00001 /***********************************************************************
00002     created:    7/8/2010
00003     author:     Martin Preisler
00004 
00005     purpose:    Defines the interface for the AnimationInstance class
00006 *************************************************************************/
00007 /***************************************************************************
00008  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
00009  *
00010  *   Permission is hereby granted, free of charge, to any person obtaining
00011  *   a copy of this software and associated documentation files (the
00012  *   "Software"), to deal in the Software without restriction, including
00013  *   without limitation the rights to use, copy, modify, merge, publish,
00014  *   distribute, sublicense, and/or sell copies of the Software, and to
00015  *   permit persons to whom the Software is furnished to do so, subject to
00016  *   the following conditions:
00017  *
00018  *   The above copyright notice and this permission notice shall be
00019  *   included in all copies or substantial portions of the Software.
00020  *
00021  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  *   OTHER DEALINGS IN THE SOFTWARE.
00028  ***************************************************************************/
00029 #ifndef _CEGUIAnimationInstance_h_
00030 #define _CEGUIAnimationInstance_h_
00031 
00032 #include "CEGUI/EventArgs.h"
00033 #include "CEGUI/Event.h"
00034 #include <map>
00035 #include <vector>
00036 
00037 #if defined(_MSC_VER)
00038 #   pragma warning(push)
00039 #   pragma warning(disable : 4251)
00040 #endif
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 
00051 class CEGUIEXPORT AnimationEventArgs : public EventArgs
00052 {
00053 public:
00054     AnimationEventArgs(AnimationInstance* inst) : instance(inst) {}
00056     AnimationInstance* instance;
00057 };
00058 
00073 class CEGUIEXPORT AnimationInstance :
00074     public AllocatedObject<AnimationInstance>
00075 {
00076 public:
00079     static const String EventNamespace;
00080 
00082     static const String EventAnimationStarted;
00084     static const String EventAnimationStopped;
00086     static const String EventAnimationPaused;
00088     static const String EventAnimationUnpaused;
00090     static const String EventAnimationEnded;
00092     static const String EventAnimationLooped;
00093 
00095     AnimationInstance(Animation* definition);
00096 
00100     ~AnimationInstance(void);
00101 
00106     Animation* getDefinition() const;
00107 
00113     void setTarget(PropertySet* target);
00114 
00119     PropertySet* getTarget() const;
00120 
00127     void setEventReceiver(EventSet* receiver);
00128 
00133     EventSet* getEventReceiver() const;
00134 
00141     void setEventSender(EventSet* sender);
00142 
00147     EventSet* getEventSender() const;
00148 
00154     void setTargetWindow(Window* target);
00155 
00161     void setPosition(float position);
00162 
00167     float getPosition() const;
00168 
00174     void setSpeed(float speed);
00175 
00180     float getSpeed() const;
00181 
00186     void setSkipNextStep(bool skip);
00187 
00196     bool getSkipNextStep() const;
00197 
00213     void setMaxStepDeltaSkip(float maxDelta);
00214 
00219     float getMaxStepDeltaSkip() const;
00220 
00234     void setMaxStepDeltaClamp(float maxDelta);
00235 
00240     float getMaxStepDeltaClamp() const;
00241 
00252     void start(bool skipNextStep = true);
00253 
00258     void stop();
00259 
00264     void pause();
00265 
00273     void unpause(bool skipNextStep = true);
00274 
00283     void togglePause(bool skipNextStep = true);
00284 
00290     bool isRunning() const;
00291 
00300     void setAutoSteppingEnabled(bool enabled);
00301 
00306     bool isAutoSteppingEnabled() const;
00307 
00315     void step(float delta);
00316 
00321     bool handleStart(const CEGUI::EventArgs& e);
00322 
00327     bool handleStop(const CEGUI::EventArgs& e);
00328 
00333     bool handlePause(const CEGUI::EventArgs& e);
00334 
00339     bool handleUnpause(const CEGUI::EventArgs& e);
00340 
00345     bool handleTogglePause(const CEGUI::EventArgs& e);
00346 
00351     void savePropertyValue(const String& propertyName);
00352 
00356     void purgeSavedPropertyValues(void);
00357 
00361     const String& getSavedPropertyValue(const String& propertyName);
00362 
00370     void addAutoConnection(Event::Connection conn);
00371 
00379     void unsubscribeAutoConnections();
00380 
00389     void apply();
00390 
00391 private:
00393     void onAnimationStarted();
00395     void onAnimationStopped();
00397     void onAnimationPaused();
00399     void onAnimationUnpaused();
00400 
00402     void onAnimationEnded();
00404     void onAnimationLooped();
00405 
00407     Animation* d_definition;
00408 
00410     PropertySet* d_target;
00412     EventSet* d_eventReceiver;
00416     EventSet* d_eventSender;
00417 
00422     float d_position;
00424     float d_speed;
00426     bool d_bounceBackwards;
00428     bool d_running;
00430     bool d_skipNextStep;
00432     float d_maxStepDeltaSkip;
00434     float d_maxStepDeltaClamp;
00436     bool d_autoSteppingEnabled;
00437 
00438     typedef std::map<String, String, std::less<String>
00439         CEGUI_MAP_ALLOC(String, String)> PropertyValueMap;
00443     PropertyValueMap d_savedPropertyValues;
00444 
00445     typedef std::vector<Event::Connection
00446         CEGUI_VECTOR_ALLOC(Event::Connection)> ConnectionTracker;
00448     ConnectionTracker d_autoConnections;
00449 };
00450 
00451 } // End of  CEGUI namespace section
00452 
00453 #if defined(_MSC_VER)
00454 #   pragma warning(pop)
00455 #endif
00456 
00457 #endif  // end of guard _CEGUIAnimationInstance_h_
00458 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends