[pitivi] ruler: Fix the play header display



commit 614d70f38c75c5cfec14361eefdbfd068004b1fc
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Jan 12 22:14:05 2014 +0100

    ruler: Fix the play header display
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=721972

 pitivi/timeline/ruler.py    |   14 +++++++++-----
 pitivi/timeline/timeline.py |    9 ++++++---
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index d1e9d8a..69210e0 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -166,8 +166,11 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
 
 ## timeline position changed method
 
-    def timelinePositionChanged(self, value, unused_frame=None):
-        self.position = value
+    def setPipeline(self, pipeline):
+        pipeline.connect('position', self.timelinePositionCb)
+
+    def timelinePositionCb(self, pipeline, position):
+        self.position = position
         self.queue_draw()
 
 ## Gtk.Widget overrides
@@ -392,9 +395,10 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
             frame_num += 1
 
     def drawPosition(self, context):
-        # a simple RED line will do for now
-        xpos = self.nsToPixel(self.position) - self.pixbuf_offset
-        context.set_line_width(PLAYHEAD_WIDTH)
+        # Add 0.5 so that the line center is at the middle of the pixel,
+        # without this the line appears blurry.
+        xpos = self.nsToPixel(self.position) - self.pixbuf_offset + 0.5
+        context.set_line_width(PLAYHEAD_WIDTH + 2)
         context.set_source_rgb(1.0, 0, 0)
         context.move_to(xpos, 0)
         context.line_to(xpos, context.get_target().get_height())
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 1381dec..6b15cff 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -370,7 +370,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
         track.disconnect_by_func(self._trackElementRemovedCb)
 
     def _positionCb(self, unused_pipeline, position):
-        self.playhead.props.x = self.nsToPixel(position)
+        self._movePlayhead(position)
         self._container._scrollToPlayhead()
         self.lastPosition = position
 
@@ -380,17 +380,19 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
             self.playhead.set_easing_duration(600)
         height = len(self.bTimeline.get_layers()) * (EXPANDED_SIZE + SPACING) * 2
         self.playhead.set_size(PLAYHEAD_WIDTH, height)
-        self.playhead.props.x = self.nsToPixel(self.lastPosition)
+        self._movePlayhead(self.lastPosition)
         if self._project and self._project.pipeline.getState() != Gst.State.PLAYING:
             self.playhead.restore_easing_state()
 
+    def _movePlayhead(self, position):
+        self.playhead.props.x = self.nsToPixel(position)
+
     def _createPlayhead(self):
         self.playhead = Clutter.Actor()
         self.playhead.set_background_color(PLAYHEAD_COLOR)
         self.playhead.set_size(0, 0)
         self.playhead.set_position(0, 0)
         self.playhead.set_easing_duration(0)
-        self.playhead.set_z_position(1)
         self.add_child(self.playhead)
 
     def _createSnapIndicator(self):
@@ -1373,6 +1375,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         if self._project:
             self._seeker = self._project.seeker
             self.timeline.setProject(self._project)
+            self.ruler.setPipeline(self._project.pipeline)
 
             self.ruler.setProjectFrameRate(self._project.videorate)
             self.ruler.zoomChanged()


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