Crazy Eddies GUI System  0.7.2
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 
189  void start();
190 
195  void stop();
196 
201  void pause();
202 
207  void unpause();
208 
213  void togglePause();
214 
220  bool isRunning() const;
221 
226  void step(float delta);
227 
232  bool handleStart(const CEGUI::EventArgs& e);
233 
238  bool handleStop(const CEGUI::EventArgs& e);
239 
244  bool handlePause(const CEGUI::EventArgs& e);
245 
250  bool handleUnpause(const CEGUI::EventArgs& e);
251 
256  bool handleTogglePause(const CEGUI::EventArgs& e);
257 
262  void savePropertyValue(const String& propertyName);
263 
267  void purgeSavedPropertyValues(void);
268 
272  const String& getSavedPropertyValue(const String& propertyName);
273 
281  void addAutoConnection(Event::Connection conn);
282 
290  void unsubscribeAutoConnections();
291 
292 private:
294  void apply();
295 
297  void onAnimationStarted();
299  void onAnimationStopped();
301  void onAnimationPaused();
303  void onAnimationUnpaused();
304 
306  void onAnimationEnded();
308  void onAnimationLooped();
309 
311  Animation* d_definition;
312 
314  PropertySet* d_target;
316  EventSet* d_eventReceiver;
320  EventSet* d_eventSender;
321 
326  float d_position;
328  float d_speed;
330  bool d_bounceBackwards;
332  bool d_running;
333 
334  typedef std::map<String, String> PropertyValueMap;
338  PropertyValueMap d_savedPropertyValues;
339 
340  typedef std::vector<Event::Connection> ConnectionTracker;
342  ConnectionTracker d_autoConnections;
343 };
344 
345 } // End of CEGUI namespace section
346 
347 #if defined(_MSC_VER)
348 # pragma warning(pop)
349 #endif
350 
351 #endif // end of guard _CEGUIAnimationInstance_h_
352