Crazy Eddies GUI System  0.7.8
CEGUIAnimationInstance.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 "CEGUIEventArgs.h"
34 #include "CEGUIEvent.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 {
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 
296  void step(float delta);
297 
302  bool handleStart(const CEGUI::EventArgs& e);
303 
308  bool handleStop(const CEGUI::EventArgs& e);
309 
314  bool handlePause(const CEGUI::EventArgs& e);
315 
320  bool handleUnpause(const CEGUI::EventArgs& e);
321 
326  bool handleTogglePause(const CEGUI::EventArgs& e);
327 
332  void savePropertyValue(const String& propertyName);
333 
337  void purgeSavedPropertyValues(void);
338 
342  const String& getSavedPropertyValue(const String& propertyName);
343 
351  void addAutoConnection(Event::Connection conn);
352 
360  void unsubscribeAutoConnections();
361 
362 private:
364  void apply();
365 
367  void onAnimationStarted();
369  void onAnimationStopped();
371  void onAnimationPaused();
373  void onAnimationUnpaused();
374 
376  void onAnimationEnded();
378  void onAnimationLooped();
379 
381  Animation* d_definition;
382 
384  PropertySet* d_target;
386  EventSet* d_eventReceiver;
390  EventSet* d_eventSender;
391 
396  float d_position;
398  float d_speed;
400  bool d_bounceBackwards;
402  bool d_running;
404  bool d_skipNextStep;
406  float d_maxStepDeltaSkip;
408  float d_maxStepDeltaClamp;
409 
410  typedef std::map<String, String> PropertyValueMap;
414  PropertyValueMap d_savedPropertyValues;
415 
416  typedef std::vector<Event::Connection> ConnectionTracker;
418  ConnectionTracker d_autoConnections;
419 };
420 
421 } // End of CEGUI namespace section
422 
423 #if defined(_MSC_VER)
424 # pragma warning(pop)
425 #endif
426 
427 #endif // end of guard _CEGUIAnimationInstance_h_
428