Crazy Eddies GUI System 0.7.6
CEGUIAffector.h
00001 /***********************************************************************
00002     filename:   CEGUIAffector.h
00003     created:    7/8/2010
00004     author:     Martin Preisler
00005 
00006     purpose:    Defines the interface for the Affector clas
00007 *************************************************************************/
00008 /***************************************************************************
00009  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUIAffector_h_
00031 #define _CEGUIAffector_h_
00032 
00033 #include "CEGUIString.h"
00034 #include "CEGUIKeyFrame.h"
00035 #include <map>
00036 
00037 #if defined(_MSC_VER)
00038 #   pragma warning(push)
00039 #   pragma warning(disable : 4251)
00040 #endif
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 
00056 class CEGUIEXPORT Affector
00057 {
00058 public:
00060     enum ApplicationMethod
00061     {
00063         AM_Absolute,
00064 
00068         AM_Relative,
00069 
00073         AM_RelativeMultiply
00074     };
00075 
00079     Affector(Animation* parent);
00080 
00082     ~Affector(void);
00083 
00092     void setApplicationMethod(ApplicationMethod method);
00093 
00101     ApplicationMethod getApplicationMethod() const;
00102 
00107     void setTargetProperty(const String& target);
00108 
00113     const String& getTargetProperty() const;
00114 
00122     void setInterpolator(Interpolator* interpolator);
00123 
00131     void setInterpolator(const String& name);
00132 
00137     Interpolator* getInterpolator() const;
00138 
00143     KeyFrame* createKeyFrame(float position);
00144 
00153     KeyFrame* createKeyFrame(float position, const String& value,
00154                              KeyFrame::Progression progression = KeyFrame::P_Linear,
00155                              const String& sourceProperty = "");
00156 
00161     void destroyKeyFrame(KeyFrame* keyframe);
00162 
00167     KeyFrame* getKeyFrameAtPosition(float position) const;
00168 
00173     KeyFrame* getKeyFrameAtIdx(size_t index) const;
00174 
00179     size_t getNumKeyFrames() const;
00180 
00185     void moveKeyFrameToPosition(KeyFrame* keyframe, float newPosition);
00186 
00191     void moveKeyFrameToPosition(float oldPosition, float newPosition);
00192 
00202     void savePropertyValues(AnimationInstance* instance);
00203 
00216     void apply(AnimationInstance* instance);
00217 
00218 private:
00220     Animation* d_parent;
00222     ApplicationMethod d_applicationMethod;
00224     String d_targetProperty;
00226     Interpolator* d_interpolator;
00227 
00228     typedef std::map<float, KeyFrame*> KeyFrameMap;
00232     KeyFrameMap d_keyFrames;
00233 };
00234 
00235 } // End of  CEGUI namespace section
00236 
00237 #if defined(_MSC_VER)
00238 #   pragma warning(pop)
00239 #endif
00240 
00241 #endif  // end of guard _CEGUIAffector_h_
00242