Crazy Eddie's GUI System  0.8.7
AnimationInstance.h
1 /***********************************************************************
2  created: 7/8/2010
3  author: Martin Preisler
4 
5  purpose: Defines the interface for the AnimationInstance class
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIAnimationInstance_h_
30 #define _CEGUIAnimationInstance_h_
31 
32 #include "CEGUI/EventArgs.h"
33 #include "CEGUI/Event.h"
34 #include <map>
35 #include <vector>
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
51 class CEGUIEXPORT AnimationEventArgs : public EventArgs
52 {
53 public:
54  AnimationEventArgs(AnimationInstance* inst) : instance(inst) {}
57 };
58 
73 class CEGUIEXPORT AnimationInstance :
74  public AllocatedObject<AnimationInstance>
75 {
76 public:
79  static const String EventNamespace;
80 
93 
96 
101 
107 
113  void setTarget(PropertySet* target);
114 
120 
127  void setEventReceiver(EventSet* receiver);
128 
134 
141  void setEventSender(EventSet* sender);
142 
148 
154  void setTargetWindow(Window* target);
155 
161  void setPosition(float position);
162 
167  float getPosition() const;
168 
174  void setSpeed(float speed);
175 
180  float getSpeed() const;
181 
186  void setSkipNextStep(bool skip);
187 
196  bool getSkipNextStep() const;
197 
213  void setMaxStepDeltaSkip(float maxDelta);
214 
219  float getMaxStepDeltaSkip() const;
220 
234  void setMaxStepDeltaClamp(float maxDelta);
235 
240  float getMaxStepDeltaClamp() const;
241 
252  void start(bool skipNextStep = true);
253 
258  void stop();
259 
264  void pause();
265 
273  void unpause(bool skipNextStep = true);
274 
283  void togglePause(bool skipNextStep = true);
284 
290  bool isRunning() const;
291 
300  void setAutoSteppingEnabled(bool enabled);
301 
306  bool isAutoSteppingEnabled() const;
307 
315  void step(float delta);
316 
322 
327  bool handleStop(const CEGUI::EventArgs& e);
328 
334 
340 
346 
351  void savePropertyValue(const String& propertyName);
352 
357 
361  const String& getSavedPropertyValue(const String& propertyName);
362 
371 
380 
389  void apply();
390 
391 private:
393  void onAnimationStarted();
395  void onAnimationStopped();
397  void onAnimationPaused();
399  void onAnimationUnpaused();
400 
402  void onAnimationEnded();
404  void onAnimationLooped();
405 
407  Animation* d_definition;
408 
410  PropertySet* d_target;
412  EventSet* d_eventReceiver;
416  EventSet* d_eventSender;
417 
422  float d_position;
424  float d_speed;
426  bool d_bounceBackwards;
428  bool d_running;
430  bool d_skipNextStep;
432  float d_maxStepDeltaSkip;
434  float d_maxStepDeltaClamp;
436  bool d_autoSteppingEnabled;
437 
438  typedef std::map<String, String, std::less<String>
439  CEGUI_MAP_ALLOC(String, String)> PropertyValueMap;
443  PropertyValueMap d_savedPropertyValues;
444 
445  typedef std::vector<Event::Connection
446  CEGUI_VECTOR_ALLOC(Event::Connection)> ConnectionTracker;
448  ConnectionTracker d_autoConnections;
449 };
450 
451 } // End of CEGUI namespace section
452 
453 #if defined(_MSC_VER)
454 # pragma warning(pop)
455 #endif
456 
457 #endif // end of guard _CEGUIAnimationInstance_h_
458 
CEGUI::AnimationEventArgs::instance
AnimationInstance * instance
pointer to a AnimationInstance object of relevance to the event.
Definition: AnimationInstance.h:56
CEGUI::AnimationInstance::unpause
void unpause(bool skipNextStep=true)
Unpauses this animation instance - allows it to step forward again.
CEGUI::AnimationInstance::setTarget
void setTarget(PropertySet *target)
Sets the target property set - this class will get it's properties affected by the Affectors!
CEGUI::AnimationInstance::getDefinition
Animation * getDefinition() const
Retrieves the animation definition that is used in this instance.
CEGUI::AnimationInstance::pause
void pause()
Pauses this animation instance - stops it from stepping forward.
CEGUI::AnimationInstance::getMaxStepDeltaSkip
float getMaxStepDeltaSkip() const
Gets the max delta before step skipping occurs.
CEGUI::AnimationInstance::handleUnpause
bool handleUnpause(const CEGUI::EventArgs &e)
handler that unpauses the animation instance
CEGUI::AnimationInstance::EventAnimationStarted
static const String EventAnimationStarted
fired when animation instance starts
Definition: AnimationInstance.h:82
CEGUI::AnimationInstance
Defines an 'animation instance' class.
Definition: AnimationInstance.h:75
CEGUI::AnimationInstance::EventAnimationStopped
static const String EventAnimationStopped
fired when animation instance stops
Definition: AnimationInstance.h:84
CEGUI::AnimationInstance::handleStart
bool handleStart(const CEGUI::EventArgs &e)
handler that starts the animation instance
CEGUI::AnimationInstance::setEventReceiver
void setEventReceiver(EventSet *receiver)
Sets event receiver - this class will receive events when something happens to the playback of this a...
CEGUI::AnimationInstance::handleStop
bool handleStop(const CEGUI::EventArgs &e)
handler that stops the animation instance
CEGUI::AnimationInstance::setSpeed
void setSpeed(float speed)
Sets playback speed - you can speed up / slow down individual instances of the same animation....
CEGUI::AnimationInstance::setMaxStepDeltaSkip
void setMaxStepDeltaSkip(float maxDelta)
Sets the max delta before step skipping occurs.
CEGUI::AnimationInstance::~AnimationInstance
~AnimationInstance(void)
CEGUI::AnimationEventArgs
EventArgs based class that holds information about which animation instnace fired given event.
Definition: AnimationInstance.h:52
CEGUI::AnimationInstance::savePropertyValue
void savePropertyValue(const String &propertyName)
Internal method, saves given property (called before it's affected)
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::EventSet
Interface providing event signaling and handling.
Definition: EventSet.h:167
CEGUI::AnimationInstance::purgeSavedPropertyValues
void purgeSavedPropertyValues(void)
CEGUI::AnimationInstance::setMaxStepDeltaClamp
void setMaxStepDeltaClamp(float maxDelta)
Sets the max delta before step clamping occurs.
CEGUI::PropertySet
Interface providing introspection capabilities.
Definition: PropertySet.h:108
CEGUI::RefCounted< BoundSlot >
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::AnimationInstance::getSkipNextStep
bool getSkipNextStep() const
Returns true if the next step is going to be skipped.
CEGUI::AnimationInstance::getMaxStepDeltaClamp
float getMaxStepDeltaClamp() const
Gets the max delta before step clamping occurs.
CEGUI::AnimationInstance::setSkipNextStep
void setSkipNextStep(bool skip)
Controls whether the next time step is skipped.
CEGUI::AnimationInstance::setPosition
void setPosition(float position)
Sets playback position. Has to be higher or equal to 0.0 and lower or equal to Animation definition's...
CEGUI::AnimationInstance::isAutoSteppingEnabled
bool isAutoSteppingEnabled() const
Checks whether auto stepping is enabled.
CEGUI::AnimationInstance::EventNamespace
static const String EventNamespace
Definition: AnimationInstance.h:79
CEGUI::AnimationInstance::addAutoConnection
void addAutoConnection(Event::Connection conn)
Internal method, adds reference to created auto connection.
CEGUI::AnimationInstance::EventAnimationPaused
static const String EventAnimationPaused
fired when animation instance pauses
Definition: AnimationInstance.h:86
CEGUI::AnimationInstance::getEventSender
EventSet * getEventSender() const
Retrieves the event sender.
CEGUI::AnimationInstance::EventAnimationEnded
static const String EventAnimationEnded
fired when animation instance ends
Definition: AnimationInstance.h:90
CEGUI::AnimationInstance::step
void step(float delta)
Steps the animation forward by the given delta.
CEGUI::AnimationInstance::setEventSender
void setEventSender(EventSet *sender)
Sets event sender - this class will send events and can affect this animation instance if there are a...
CEGUI::AnimationInstance::getSpeed
float getSpeed() const
Retrieves current playback speed.
CEGUI::AnimationInstance::setAutoSteppingEnabled
void setAutoSteppingEnabled(bool enabled)
Controls whether auto stepping is enabled.
CEGUI::AnimationInstance::handleTogglePause
bool handleTogglePause(const CEGUI::EventArgs &e)
handler that toggles pause on this animation instance
CEGUI::AnimationInstance::unsubscribeAutoConnections
void unsubscribeAutoConnections()
Internal method, unsubscribes auto connections.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::AnimationInstance::getTarget
PropertySet * getTarget() const
Retrieves the target property set.
CEGUI::AnimationInstance::apply
void apply()
Applies this animation instance.
CEGUI::AnimationInstance::togglePause
void togglePause(bool skipNextStep=true)
Pauses the animation if it's running and unpauses it if it isn't.
CEGUI::AnimationInstance::getSavedPropertyValue
const String & getSavedPropertyValue(const String &propertyName)
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Animation
Defines an 'animation' class.
Definition: Animation.h:65
CEGUI::AnimationInstance::getPosition
float getPosition() const
Retrieves current playback position.
CEGUI::AnimationInstance::stop
void stop()
Stops this animation instance - sets position to 0.0 and pauses.
CEGUI::AnimationInstance::setTargetWindow
void setTargetWindow(Window *target)
Helper method, sets given window as target property set, event receiver and event set.
CEGUI::AnimationInstance::EventAnimationUnpaused
static const String EventAnimationUnpaused
fired when animation instance unpauses
Definition: AnimationInstance.h:88
CEGUI::AnimationInstance::getEventReceiver
EventSet * getEventReceiver() const
Retrieves the event receiver.
CEGUI::AnimationInstance::AnimationInstance
AnimationInstance(Animation *definition)
internal constructor, please use AnimationManager::instantiateAnimation
CEGUI::AnimationInstance::handlePause
bool handlePause(const CEGUI::EventArgs &e)
handler that pauses the animation instance
CEGUI::AnimationInstance::isRunning
bool isRunning() const
Returns true if this animation instance is currently unpaused, if it is stepping forward.
CEGUI::AnimationInstance::start
void start(bool skipNextStep=true)
Starts this animation instance - sets position to 0.0 and unpauses.
CEGUI::AnimationInstance::EventAnimationLooped
static const String EventAnimationLooped
fired when animation instance loops
Definition: AnimationInstance.h:92
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51