[pitivi/1.0] ruler: Display playhead time in tooltip when scrubbing



commit 3bcacb823a61c95fc623a76e8a73bdbc6414ad09
Author: Harish Fulara <harish14143 iiitd ac in>
Date:   Fri Jan 19 17:52:10 2018 +0530

    ruler: Display playhead time in tooltip when scrubbing
    
    Fixes https://phabricator.freedesktop.org/T7502
    
    Differential Revision: https://phabricator.freedesktop.org/D1944

 pitivi/timeline/ruler.py |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 08e760a..40cc9b0 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -194,16 +194,21 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         if not self._pipeline:
             return False
 
-        self.debug("button pressed at x:%d", event.x)
         button = event.button
         if button == 3 or (button == 1 and self.app.settings.leftClickAlsoSeeks):
+            self.debug("button pressed at x:%d", event.x)
             position = self.pixelToNs(event.x + self.pixbuf_offset)
             self._pipeline.simple_seek(position)
+            self.__set_tooltip_text(position, True)
         return False
 
     def do_button_release_event(self, event):
-        self.debug("button released at x:%d", event.x)
-        self.app.gui.focusTimeline()
+        button = event.button
+        if button == 3 or (button == 1 and self.app.settings.leftClickAlsoSeeks):
+            self.debug("button released at x:%d", event.x)
+            self.app.gui.focusTimeline()
+            position = self.pixelToNs(event.x + self.pixbuf_offset)
+            self.__set_tooltip_text(position)
         return False
 
     def do_motion_notify_event(self, event):
@@ -215,13 +220,13 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         seek_mask = Gdk.ModifierType.BUTTON3_MASK
         if self.app.settings.leftClickAlsoSeeks:
             seek_mask |= Gdk.ModifierType.BUTTON1_MASK
-        if event.state & seek_mask:
+
+        seeking = event.state & seek_mask
+        if seeking:
             self.debug("motion at event.x %d", event.x)
             self._pipeline.simple_seek(position)
+        self.__set_tooltip_text(position, seeking)
 
-        human_time = beautify_length(position)
-        cur_frame = int(position / self.ns_per_frame) + 1
-        self.set_tooltip_text(human_time + "\n" + _("Frame #%d") % cur_frame)
         return False
 
     def do_scroll_event(self, event):
@@ -233,6 +238,16 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         self.ns_per_frame = float(Gst.SECOND / self.frame_rate)
         self.scales = (2 / rate, 5 / rate, 10 / rate) + SCALES
 
+    def __set_tooltip_text(self, position, seeking=False):
+        """Updates the tooltip."""
+        if seeking:
+            timeline_duration = self.timeline.ges_timeline.props.duration
+            if position > timeline_duration:
+                position = timeline_duration
+        human_time = beautify_length(position)
+        cur_frame = int(position / self.ns_per_frame) + 1
+        self.set_tooltip_text(human_time + "\n" + _("Frame #%d") % cur_frame)
+
 # Drawing methods
 
     def drawBackground(self, context):


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