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
93
96
101
107
113 void setTarget(PropertySet* target);
114
120
127 void setEventReceiver(EventSet* receiver);
128
134
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
307
315 void step(float delta);
316
322
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
391private:
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
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
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.
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.
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:92
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:90
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