Crazy Eddie's GUI System 0.8.7
Affector.h
1/***********************************************************************
2 created: 7/8/2010
3 author: Martin Preisler
4
5 purpose: Defines the interface for the Affector clas
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 _CEGUIAffector_h_
30#define _CEGUIAffector_h_
31
32#include "CEGUI/String.h"
33#include "CEGUI/KeyFrame.h"
34#include <map>
35
36#if defined(_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4251)
39#endif
40
41// Start of CEGUI namespace section
42namespace CEGUI
43{
44
55class CEGUIEXPORT Affector : public AllocatedObject<Affector>
56{
57public:
60 {
63
68
72 AM_RelativeMultiply
73 };
74
79
81 ~Affector(void);
82
87 inline Animation* getParent() const
88 {
89 return d_parent;
90 }
91
99 size_t getIdxInParent() const;
100
110
119
124 void setTargetProperty(const String& target);
125
130 const String& getTargetProperty() const;
131
139 void setInterpolator(Interpolator* interpolator);
140
148 void setInterpolator(const String& name);
149
155
160 KeyFrame* createKeyFrame(float position);
161
170 KeyFrame* createKeyFrame(float position, const String& value,
172 const String& sourceProperty = "");
173
178 void destroyKeyFrame(KeyFrame* keyframe);
179
184 KeyFrame* getKeyFrameAtPosition(float position) const;
185
190 bool hasKeyFrameAtPosition(float position) const;
191
196 KeyFrame* getKeyFrameAtIdx(size_t index) const;
197
202 size_t getNumKeyFrames() const;
203
208 void moveKeyFrameToPosition(KeyFrame* keyframe, float newPosition);
209
214 void moveKeyFrameToPosition(float oldPosition, float newPosition);
215
226
239 void apply(AnimationInstance* instance);
240
248 void writeXMLToStream(XMLSerializer& xml_stream) const;
249
250private:
252 Animation* d_parent;
254 ApplicationMethod d_applicationMethod;
256 String d_targetProperty;
258 Interpolator* d_interpolator;
259
260 typedef std::map<float, KeyFrame*, std::less<float>
261 CEGUI_MAP_ALLOC(float, KeyFrame*)> KeyFrameMap;
265 KeyFrameMap d_keyFrames;
266};
267
268} // End of CEGUI namespace section
269
270#if defined(_MSC_VER)
271# pragma warning(pop)
272#endif
273
274#endif // end of guard _CEGUIAffector_h_
275
Defines an 'affector' class.
Definition: Affector.h:56
Interpolator * getInterpolator() const
Retrieves currently used interpolator of this Affector.
void setTargetProperty(const String &target)
Sets the property that will be affected.
void moveKeyFrameToPosition(float oldPosition, float newPosition)
Moves key frame at given old position to given new position.
size_t getIdxInParent() const
Retrieves index with which this affector is retrievable in parent Animation.
Affector(Animation *parent)
KeyFrame * getKeyFrameAtPosition(float position) const
Retrieves a KeyFrame at given position.
void setApplicationMethod(ApplicationMethod method)
Sets the application method.
Animation * getParent() const
Retrieves the parent animation of this keyframe.
Definition: Affector.h:87
void destroyKeyFrame(KeyFrame *keyframe)
Destroys given keyframe.
void savePropertyValues(AnimationInstance *instance)
Internal method, causes all properties that are used by this affector and it's keyframes to be saved.
KeyFrame * getKeyFrameAtIdx(size_t index) const
Retrieves a KeyFrame with given index.
void setInterpolator(const String &name)
Sets interpolator of this Affector.
void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this Affector to out_stream.
ApplicationMethod
enumerates the possible methods of application
Definition: Affector.h:60
@ AM_Absolute
applies values as absolutes
Definition: Affector.h:62
@ AM_Relative
Definition: Affector.h:67
KeyFrame * createKeyFrame(float position, const String &value, KeyFrame::Progression progression=KeyFrame::P_Linear, const String &sourceProperty="")
Creates a KeyFrame at given position.
ApplicationMethod getApplicationMethod() const
Retrieves current application method.
void moveKeyFrameToPosition(KeyFrame *keyframe, float newPosition)
Moves given key frame to given new position.
void setInterpolator(Interpolator *interpolator)
Sets interpolator of this Affector.
void apply(AnimationInstance *instance)
Applies this Affector's definition with parameters from given Animation Instance.
~Affector(void)
destructor, this destroys all key frames defined inside this affector
bool hasKeyFrameAtPosition(float position) const
Checks whether there is a key frame at given position.
size_t getNumKeyFrames() const
Returns number of key frames defined in this affector.
const String & getTargetProperty() const
Gets the property that will be affected.
KeyFrame * createKeyFrame(float position)
Creates a KeyFrame at given position.
Definition: MemoryAllocatedObject.h:110
Defines an 'animation instance' class.
Definition: AnimationInstance.h:75
Defines an 'animation' class.
Definition: Animation.h:65
Defines a 'interpolator' class.
Definition: Interpolator.h:55
Defines a 'key frame' class.
Definition: KeyFrame.h:51
Progression
Definition: KeyFrame.h:57
@ P_Linear
linear progression
Definition: KeyFrame.h:59
String class used within the GUI system.
Definition: String.h:64
Class used to create XML Document.
Definition: XMLSerializer.h:87
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1