[pitivi: 1/5] ui.timelinecanvas: snap razor to playhead position
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi: 1/5] ui.timelinecanvas: snap razor to playhead position
- Date: Thu, 16 Apr 2009 05:34:16 -0400 (EDT)
commit f6636c3c7c68e6d2d6be8785dc5e336aa7dcdcf5
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date: Wed Apr 15 11:37:40 2009 -0700
ui.timelinecanvas: snap razor to playhead position
---
pitivi/ui/timeline.py | 1 +
pitivi/ui/timelinecanvas.py | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 3b02e13..9ee11fe 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -300,6 +300,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
def timelinePositionChanged(self, position):
self._position = position
self.ruler.timelinePositionChanged(position)
+ self._canvas._position = position
self.scrollToPlayhead()
def scrollToPlayhead(self):
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index f130ad7..e09eb27 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -48,6 +48,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
self._selected_sources = []
self._tracks = []
self._height = 0
+ self._position = 0
self._block_size_request = False
self.props.integer_layout = True
@@ -172,8 +173,13 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
def _razorMovedCb(self, canvas, event):
+ def snap(x):
+ pos = self.nsToPixel(self._position)
+ if abs(x - pos) <= DEADBAND:
+ return pos
+ return x
x, y = self.convert_from_pixels(event.x, event.y)
- self._razor.props.x = self.nsToPixel(self.pixelToNs(x))
+ self._razor.props.x = snap(self.nsToPixel(self.pixelToNs(x)))
return True
def _razorReleasedCb(self, unused_canvas, event):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]