Before this fix, PasteCanvas' "time offset" values were being reflected in the positi...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 22 Oct 2007 01:02:44 +0000 (01:02 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 22 Oct 2007 01:02:44 +0000 (01:02 +0000)
git-svn-id: http://svn.voria.com/code@944 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/layer_pastecanvas.cpp
synfig-core/trunk/src/synfig/node.h
synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp

index f8308a7..e156fc7 100644 (file)
@@ -417,7 +417,11 @@ void Layer_PasteCanvas::get_times_vfunc(Node::time_set &set) const
        //TODO: SOMETHING STILL HAS TO BE DONE WITH THE OTHER DIRECTION
        //              (recursing down the tree needs to take this into account too...)
        for(; i != end; ++i)
-               set.insert(*i - time_offset);
+               set.insert(*i
+#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET // see node.h
+                                  - time_offset
+#endif
+                       );
 
        Layer::get_times_vfunc(set);
 }
index 1d52c7f..aeb5da1 100644 (file)
 
 /* === M A C R O S ========================================================= */
 
+// When a PasteCanvas layer has a non-zero 'time offset' parameter, should
+// the waypoints shown for the canvas be adjusted?  This currently only
+// partially works - see the TODO at the end of layer_pastecanvas.cpp
+// #define ADJUST_WAYPOINTS_FOR_TIME_OFFSET
+
 /* === T Y P E D E F S ===================================================== */
 
 /* === C L A S S E S & S T R U C T S ======================================= */
index 81529e7..56ec59d 100644 (file)
@@ -133,7 +133,31 @@ const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v
 
                if(canvasparam)
                {
+#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET // see node.h
+                       synfig::Time::value_type time_offset = 0;
+                       if (v.parent_is_layer_param())
+                       {
+                               synfig::Layer::Handle layer = v.get_layer();
+                               if (layer->get_name()=="PasteCanvas")
+                                       time_offset = layer->get_param("time_offset").get(Time());
+                       }
+
+                       const Node::time_set *times = &canvasparam->get_times();
+
+                       if (time_offset)
+                       {
+                               //! \todo this is a memory leak - blame the 'kind of hack' above
+                               Node::time_set *tmp = new Node::time_set;
+                               Node::time_set::iterator i = times->begin(), end = times->end();
+                               for (; i != end; ++i)
+                                       tmp->insert(*i - time_offset);
+                               return tmp;
+                       }
+
+                       return times;
+#else // ADJUST_WAYPOINTS_FOR_TIME_OFFSET
                        return &canvasparam->get_times();
+#endif
                }
        }