nux-1.14.0
|
00001 /* 00002 * Copyright (C) 2010 Canonical, Ltd. 00003 * 00004 * This library is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License 00006 * version 3.0 as published by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU Lesser General Public License version 3.0 for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library. If not, see 00015 * <http://www.gnu.org/licenses/>. 00016 * 00017 * Authored by Gordon Allott <gord.allott@canonical.com> 00018 */ 00019 00020 #ifndef TIMELINE_H 00021 #define TIMELINE_H 00022 00023 namespace nux 00024 { 00025 class Timeline : public Object 00026 { 00027 public: 00028 00029 Timeline (unsigned int msecs, const TCHAR *Caption, NUX_FILE_LINE_DECL); 00030 ~Timeline(); 00031 00032 void Stop (); 00033 void Start (); 00034 void Pause (); 00035 void Rewind (); 00036 00037 double GetProgress (); //ranges from 0.0 -> 1.0 00038 virtual double GetEasing (); // override to provide easing values 00039 00040 void DoTick (unsigned long msecs); // If you use this, you make baby kittens cry 00041 00042 bool Looping; 00043 unsigned long Duration; 00044 bool IsPlaying; 00045 00046 sigc::signal <void, unsigned long> NewFrame; 00047 sigc::signal <void> Completed; 00048 sigc::signal <void> Started; 00049 sigc::signal <void> Paused; 00050 00051 protected: 00052 unsigned long _ElapsedTime; 00053 }; 00054 00055 00056 // template <typename T> 00057 // class PropertyAnimationContainer 00058 // { 00059 00060 // }; 00061 00062 // class AnimatedPropertyBase 00063 // { 00064 // public: 00065 // AnimatedPropertyBase(){}; 00066 00067 // virtual void Animate(float t){}; 00068 00069 // }; 00070 00071 // // Explicit specialization. The explicit type could be float, int, Color.... 00072 // template <> 00073 // class PropertyAnimationContainer<float> : public AnimatedPropertyBase 00074 // { 00075 // public: 00076 // PropertyAnimationContainer(Property<float>& prop, float start_value, float end_value) 00077 // : prop_(prop) 00078 // { 00079 // start_value_ = start_value; 00080 // end_value_ = end_value; 00081 // } 00082 00083 // virtual void Animate(float t) 00084 // { 00085 // float value = (1.0f - t) * start_value_ + t * end_value_; 00086 // prop_.set(value); 00087 // } 00088 00089 // Property<float>& prop_; 00090 // float start_value_; 00091 // float end_value_; 00092 00093 // }; 00094 00095 // template <> 00096 // class PropertyAnimationContainer<Color> : public AnimatedPropertyBase 00097 // { 00098 // public: 00099 // PropertyAnimationContainer(Property<Color>& prop, Color start_value, Color end_value) 00100 // : prop_(prop) 00101 // { 00102 // start_value_ = start_value; 00103 // end_value_ = end_value; 00104 // } 00105 00106 // virtual void Animate(float t) 00107 // { 00108 // Color value = (1.0f - t) * start_value_ + t * end_value_; 00109 // prop_.set(value); 00110 // } 00111 00112 // Property<Color>& prop_; 00113 // Color start_value_; 00114 // Color end_value_; 00115 00116 // }; 00117 00118 // class AnimationTimeline : public Object 00119 // { 00120 // public: 00121 // AnimationTimeline() {}; 00122 00123 // template <typename T> 00124 // void AddProperty(Property<T>& prop, T start_value, T end_value) 00125 // { 00126 // PropertyAnimationContainer<T>* a = new PropertyAnimationContainer<T> (prop, start_value, end_value); 00127 00128 // animated_properties_.push_back(a); 00129 // } 00130 00131 // void Animate(float t) 00132 // { 00133 // std::list<AnimatedPropertyBase*>::iterator it; 00134 00135 // // Go through all the properties and update them. 00136 // for(it = animated_properties_.begin(); it != animated_properties_.end(); ++it) 00137 // { 00138 // (*it)->Animate(t); 00139 // } 00140 // } 00141 00142 // std::list<AnimatedPropertyBase*> animated_properties_; 00143 // }; 00144 } 00145 00146 #endif // TIMELINE_H