Crazy Eddie's GUI System  0.8.5
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 
95  AnimationInstance(Animation* definition);
96 
100  ~AnimationInstance(void);
101 
106  Animation* getDefinition() const;
107 
113  void setTarget(PropertySet* target);
114 
119  PropertySet* getTarget() const;
120 
127  void setEventReceiver(EventSet* receiver);
128 
133  EventSet* getEventReceiver() const;
134 
141  void setEventSender(EventSet* sender);
142 
147  EventSet* getEventSender() const;
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 
321  bool handleStart(const CEGUI::EventArgs& e);
322 
327  bool handleStop(const CEGUI::EventArgs& e);
328 
333  bool handlePause(const CEGUI::EventArgs& e);
334 
339  bool handleUnpause(const CEGUI::EventArgs& e);
340 
345  bool handleTogglePause(const CEGUI::EventArgs& e);
346 
351  void savePropertyValue(const String& propertyName);
352 
356  void purgeSavedPropertyValues(void);
357 
361  const String& getSavedPropertyValue(const String& propertyName);
362 
370  void addAutoConnection(Event::Connection conn);
371 
379  void unsubscribeAutoConnections();
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 
static const String EventNamespace
Definition: AnimationInstance.h:79
Definition: MemoryAllocatedObject.h:109
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
static const String EventAnimationUnpaused
fired when animation instance unpauses
Definition: AnimationInstance.h:88
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
EventArgs based class that holds information about which animation instnace fired given event...
Definition: AnimationInstance.h:51
Defines an 'animation' class.
Definition: Animation.h:64
Interface providing introspection capabilities.
Definition: PropertySet.h:107
static const String EventAnimationEnded
fired when animation instance ends
Definition: AnimationInstance.h:90
static const String EventAnimationStopped
fired when animation instance stops
Definition: AnimationInstance.h:84
static const String EventAnimationLooped
fired when animation instance loops
Definition: AnimationInstance.h:92
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Interface providing event signaling and handling.
Definition: EventSet.h:166
static const String EventAnimationStarted
fired when animation instance starts
Definition: AnimationInstance.h:82
static const String EventAnimationPaused
fired when animation instance pauses
Definition: AnimationInstance.h:86
AnimationInstance * instance
pointer to a AnimationInstance object of relevance to the event.
Definition: AnimationInstance.h:56
Defines an 'animation instance' class.
Definition: AnimationInstance.h:73
String class used within the GUI system.
Definition: String.h:62