Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
AnimationInstance.h
1 /***********************************************************************
2  filename: CEGUIAnimationInstance.h
3  created: 7/8/2010
4  author: Martin Preisler
5 
6  purpose: Defines the interface for the AnimationInstance class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIAnimationInstance_h_
31 #define _CEGUIAnimationInstance_h_
32 
33 #include "CEGUI/EventArgs.h"
34 #include "CEGUI/Event.h"
35 #include <map>
36 #include <vector>
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 
52 class CEGUIEXPORT AnimationEventArgs : public EventArgs
53 {
54 public:
55  AnimationEventArgs(AnimationInstance* inst) : instance(inst) {}
58 };
59 
74 class CEGUIEXPORT AnimationInstance :
75  public AllocatedObject<AnimationInstance>
76 {
77 public:
80  static const String EventNamespace;
81 
94 
96  AnimationInstance(Animation* definition);
97 
101  ~AnimationInstance(void);
102 
107  Animation* getDefinition() const;
108 
114  void setTarget(PropertySet* target);
115 
120  PropertySet* getTarget() const;
121 
128  void setEventReceiver(EventSet* receiver);
129 
134  EventSet* getEventReceiver() const;
135 
142  void setEventSender(EventSet* sender);
143 
148  EventSet* getEventSender() const;
149 
155  void setTargetWindow(Window* target);
156 
162  void setPosition(float position);
163 
168  float getPosition() const;
169 
175  void setSpeed(float speed);
176 
181  float getSpeed() const;
182 
187  void setSkipNextStep(bool skip);
188 
197  bool getSkipNextStep() const;
198 
214  void setMaxStepDeltaSkip(float maxDelta);
215 
220  float getMaxStepDeltaSkip() const;
221 
235  void setMaxStepDeltaClamp(float maxDelta);
236 
241  float getMaxStepDeltaClamp() const;
242 
253  void start(bool skipNextStep = true);
254 
259  void stop();
260 
265  void pause();
266 
274  void unpause(bool skipNextStep = true);
275 
284  void togglePause(bool skipNextStep = true);
285 
291  bool isRunning() const;
292 
301  void setAutoSteppingEnabled(bool enabled);
302 
307  bool isAutoSteppingEnabled() const;
308 
316  void step(float delta);
317 
322  bool handleStart(const CEGUI::EventArgs& e);
323 
328  bool handleStop(const CEGUI::EventArgs& e);
329 
334  bool handlePause(const CEGUI::EventArgs& e);
335 
340  bool handleUnpause(const CEGUI::EventArgs& e);
341 
346  bool handleTogglePause(const CEGUI::EventArgs& e);
347 
352  void savePropertyValue(const String& propertyName);
353 
357  void purgeSavedPropertyValues(void);
358 
362  const String& getSavedPropertyValue(const String& propertyName);
363 
371  void addAutoConnection(Event::Connection conn);
372 
380  void unsubscribeAutoConnections();
381 
390  void apply();
391 
392 private:
394  void onAnimationStarted();
396  void onAnimationStopped();
398  void onAnimationPaused();
400  void onAnimationUnpaused();
401 
403  void onAnimationEnded();
405  void onAnimationLooped();
406 
408  Animation* d_definition;
409 
411  PropertySet* d_target;
413  EventSet* d_eventReceiver;
417  EventSet* d_eventSender;
418 
423  float d_position;
425  float d_speed;
427  bool d_bounceBackwards;
429  bool d_running;
431  bool d_skipNextStep;
433  float d_maxStepDeltaSkip;
435  float d_maxStepDeltaClamp;
437  bool d_autoSteppingEnabled;
438 
439  typedef std::map<String, String, std::less<String>
440  CEGUI_MAP_ALLOC(String, String)> PropertyValueMap;
444  PropertyValueMap d_savedPropertyValues;
445 
446  typedef std::vector<Event::Connection
447  CEGUI_VECTOR_ALLOC(Event::Connection)> ConnectionTracker;
449  ConnectionTracker d_autoConnections;
450 };
451 
452 } // End of CEGUI namespace section
453 
454 #if defined(_MSC_VER)
455 # pragma warning(pop)
456 #endif
457 
458 #endif // end of guard _CEGUIAnimationInstance_h_
459