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
43namespace CEGUI
44{
45
51class CEGUIEXPORT AnimationEventArgs : public EventArgs
52{
53public:
54 AnimationEventArgs(AnimationInstance* inst) : instance(inst) {}
57};
58
73class CEGUIEXPORT AnimationInstance :
74 public AllocatedObject<AnimationInstance>
75{
76public:
79 static const String EventNamespace;
80
95
98
103
109
115 void setTarget(PropertySet* target);
116
122
129 void setEventReceiver(EventSet* receiver);
130
136
144
150
156 void setTargetWindow(Window* target);
157
163 void setPosition(float position);
164
169 float getPosition() const;
170
176 void setSpeed(float speed);
177
182 float getSpeed() const;
183
188 void setSkipNextStep(bool skip);
189
198 bool getSkipNextStep() const;
199
215 void setMaxStepDeltaSkip(float maxDelta);
216
221 float getMaxStepDeltaSkip() const;
222
236 void setMaxStepDeltaClamp(float maxDelta);
237
242 float getMaxStepDeltaClamp() const;
243
254 void start(bool skipNextStep = true);
255
260 void stop();
261
266 void pause();
267
275 void unpause(bool skipNextStep = true);
276
285 void togglePause(bool skipNextStep = true);
286
291 void finish();
292
298 bool isRunning() const;
299
308 void setAutoSteppingEnabled(bool enabled);
309
315
323 void step(float delta);
324
330
336
342
348
354
360
365 void savePropertyValue(const String& propertyName);
366
371
375 const String& getSavedPropertyValue(const String& propertyName);
376
385
394
403 void apply();
404
405private:
407 void onAnimationStarted();
409 void onAnimationStopped();
411 void onAnimationPaused();
413 void onAnimationUnpaused();
415 void onAnimationFinished();
416
418 void onAnimationEnded();
420 void onAnimationLooped();
421
423 Animation* d_definition;
424
426 PropertySet* d_target;
428 EventSet* d_eventReceiver;
432 EventSet* d_eventSender;
433
438 float d_position;
440 float d_speed;
442 bool d_bounceBackwards;
444 bool d_running;
446 bool d_skipNextStep;
448 float d_maxStepDeltaSkip;
450 float d_maxStepDeltaClamp;
452 bool d_autoSteppingEnabled;
453
454 typedef std::map<String, String, std::less<String>
455 CEGUI_MAP_ALLOC(String, String)> PropertyValueMap;
459 PropertyValueMap d_savedPropertyValues;
460
461 typedef std::vector<Event::Connection
462 CEGUI_VECTOR_ALLOC(Event::Connection)> ConnectionTracker;
464 ConnectionTracker d_autoConnections;
465};
466
467} // End of CEGUI namespace section
468
469#if defined(_MSC_VER)
470# pragma warning(pop)
471#endif
472
473#endif // end of guard _CEGUIAnimationInstance_h_
474
Definition: MemoryAllocatedObject.h:110
EventArgs based class that holds information about which animation instnace fired given event.
Definition: AnimationInstance.h:52
AnimationInstance * instance
pointer to a AnimationInstance object of relevance to the event.
Definition: AnimationInstance.h:56
Defines an 'animation instance' class.
Definition: AnimationInstance.h:75
void setEventSender(EventSet *sender)
Sets event sender - this class will send events and can affect this animation instance if there are a...
bool handleStart(const CEGUI::EventArgs &e)
handler that starts the animation instance
bool isAutoSteppingEnabled() const
Checks whether auto stepping is enabled.
void setSpeed(float speed)
Sets playback speed - you can speed up / slow down individual instances of the same animation....
void stop()
Stops this animation instance - sets position to 0.0 and pauses.
void apply()
Applies this animation instance.
void setPosition(float position)
Sets playback position. Has to be higher or equal to 0.0 and lower or equal to Animation definition's...
void setAutoSteppingEnabled(bool enabled)
Controls whether auto stepping is enabled.
float getPosition() const
Retrieves current playback position.
void setTarget(PropertySet *target)
Sets the target property set - this class will get it's properties affected by the Affectors!
EventSet * getEventReceiver() const
Retrieves the event receiver.
bool handleStop(const CEGUI::EventArgs &e)
handler that stops the animation instance
float getMaxStepDeltaSkip() const
Gets the max delta before step skipping occurs.
static const String EventAnimationStopped
fired when animation instance stops
Definition: AnimationInstance.h:84
void savePropertyValue(const String &propertyName)
Internal method, saves given property (called before it's affected)
bool handleTogglePause(const CEGUI::EventArgs &e)
handler that toggles pause on this animation instance
void pause()
Pauses this animation instance - stops it from stepping forward.
static const String EventAnimationPaused
fired when animation instance pauses
Definition: AnimationInstance.h:86
bool handleFinish(const CEGUI::EventArgs &e)
handler that finishes the animation instance
void togglePause(bool skipNextStep=true)
Pauses the animation if it's running and unpauses it if it isn't.
AnimationInstance(Animation *definition)
internal constructor, please use AnimationManager::instantiateAnimation
static const String EventAnimationStarted
fired when animation instance starts
Definition: AnimationInstance.h:82
void setMaxStepDeltaClamp(float maxDelta)
Sets the max delta before step clamping occurs.
static const String EventAnimationUnpaused
fired when animation instance unpauses
Definition: AnimationInstance.h:88
bool handlePause(const CEGUI::EventArgs &e)
handler that pauses the animation instance
void step(float delta)
Steps the animation forward by the given delta.
Animation * getDefinition() const
Retrieves the animation definition that is used in this instance.
void finish()
Finishes and stops the animation.
bool handleUnpause(const CEGUI::EventArgs &e)
handler that unpauses the animation instance
const String & getSavedPropertyValue(const String &propertyName)
void unpause(bool skipNextStep=true)
Unpauses this animation instance - allows it to step forward again.
static const String EventAnimationFinished
fired when animation instance finishes
Definition: AnimationInstance.h:90
void start(bool skipNextStep=true)
Starts this animation instance - sets position to 0.0 and unpauses.
float getSpeed() const
Retrieves current playback speed.
PropertySet * getTarget() const
Retrieves the target property set.
void setSkipNextStep(bool skip)
Controls whether the next time step is skipped.
void setEventReceiver(EventSet *receiver)
Sets event receiver - this class will receive events when something happens to the playback of this a...
float getMaxStepDeltaClamp() const
Gets the max delta before step clamping occurs.
void setMaxStepDeltaSkip(float maxDelta)
Sets the max delta before step skipping occurs.
void unsubscribeAutoConnections()
Internal method, unsubscribes auto connections.
static const String EventNamespace
Definition: AnimationInstance.h:79
static const String EventAnimationLooped
fired when animation instance loops
Definition: AnimationInstance.h:94
bool isRunning() const
Returns true if this animation instance is currently unpaused, if it is stepping forward.
EventSet * getEventSender() const
Retrieves the event sender.
void setTargetWindow(Window *target)
Helper method, sets given window as target property set, event receiver and event set.
bool getSkipNextStep() const
Returns true if the next step is going to be skipped.
static const String EventAnimationEnded
fired when animation instance ends
Definition: AnimationInstance.h:92
void purgeSavedPropertyValues(void)
void addAutoConnection(Event::Connection conn)
Internal method, adds reference to created auto connection.
Defines an 'animation' class.
Definition: Animation.h:65
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
Interface providing event signaling and handling.
Definition: EventSet.h:167
Interface providing introspection capabilities.
Definition: PropertySet.h:108
String class used within the GUI system.
Definition: String.h:64
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1