Author: Carlos Lopez <[email protected]>
Date:   Sun Apr 29 21:12:01 2012 +0200

Add two new members to RendDesc to get and set the duration of the animation. 
Setting the duration modifies the end time respecting the start time.

---

 synfig-core/src/synfig/renddesc.cpp |   22 ++++++++++++++++++++++
 synfig-core/src/synfig/renddesc.h   |    5 +++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/synfig-core/src/synfig/renddesc.cpp 
b/synfig-core/src/synfig/renddesc.cpp
index 4515279..509d0d2 100644
--- a/synfig-core/src/synfig/renddesc.cpp
+++ b/synfig-core/src/synfig/renddesc.cpp
@@ -555,3 +555,25 @@ RendDesc::set_subwindow(int x, int y, int w, int h)
 
        return *this;
 }
+
+RendDesc &
+RendDesc::set_duration(Time duration)
+{
+       if(get_frame_rate())
+       {
+               if(duration > Time(0.0))
+                       set_time_end(get_time_start() + duration  - 
Time(1/get_frame_rate()));
+               else
+                       set_time_end(get_time_start());
+       }
+               
+       return *this;
+}
+
+const Time
+RendDesc::get_duration()
+{
+       if(get_frame_rate())            
+               return (get_time_end() - get_time_start() + 
Time(1/get_frame_rate()));
+       return Time(0.0);
+}
diff --git a/synfig-core/src/synfig/renddesc.h 
b/synfig-core/src/synfig/renddesc.h
index 4230160..a8e0a5f 100644
--- a/synfig-core/src/synfig/renddesc.h
+++ b/synfig-core/src/synfig/renddesc.h
@@ -293,6 +293,11 @@ public:
        Real get_ph()const;
        //! Sets viewport to represent the screen at the given pixel coordinates
        RendDesc &set_subwindow(int x, int y, int w, int h);
+       //! Sets the duration of the animation. 
+       // Keeps the start time and modifies the end time to match the duration
+       RendDesc &set_duration(Time t);
+       //! Gets the duration of the animation
+       const Time get_duration();
 };     // END of class RendDesc
 
 //! This operator allows the combining of RendDesc::Lock flags using the '|' 
operator


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to