[pitivi] timelinecanvas: make sure razor actually splits at playhead position when razor is snapped to the pl



commit 5a84d3004e791a4f9845382c61754e308f31da42
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Mon Jun 29 17:13:22 2009 -0700

    timelinecanvas: make sure razor actually splits at playhead position when razor is snapped to the playhead

 pitivi/ui/timelinecanvas.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index 7cd9d74..df60fee 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -236,7 +236,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
             for item in items:
                 if isinstance(item, TrackObject):
                     self.app.action_log.begin("split object")
-                    item.element.split(self.pixelToNs(x))
+                    item.element.split(self._snapToPlayhead(self.pixelToNs(x)))
                     self.app.action_log.commit()
 
         return True
@@ -244,6 +244,12 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
     def _razorClickedCb(self, unused_canvas, unused_event):
         return True
 
+    def _snapToPlayhead(self, time):
+        thresh = self.pixelToNs(self.settings.edgeSnapDeadband)
+        if abs(time - self._position) <= thresh:
+            return self._position
+        return time
+
     max_duration = 0
 
     def setMaxDuration(self, duration):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]