[pitivi] timeline: Allow scrolling by dragging with the middle mouse button



commit e316ba1f8210ac1f66637946e40aa7a257a695de
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Nov 27 04:22:58 2015 +0100

    timeline: Allow scrolling by dragging with the middle mouse button
    
    Fixes https://phabricator.freedesktop.org/T2072
    
    Differential Revision: https://phabricator.freedesktop.org/D517
    Reviewed-by: Thibault Saunier <tsaunier gnome org>

 pitivi/timeline/elements.py |    5 ++---
 pitivi/timeline/timeline.py |   17 +++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 235cdee..dec45af 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -775,8 +775,8 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
             return False
 
         res, button = event.get_button()
-        if res and button == 3:
-            # We are supposed to only seek.
+        if res and not button == 1:
+            # Only the left mouse button selects.
             return False
 
         # TODO : Let's be more specific, masks etc ..
@@ -962,7 +962,6 @@ class TransitionClip(Clip):
             self.z_order = 1
         else:
             self.z_order = 0
-            self.set_sensitive(False)
 
         self.get_style_context().add_class("TransitionClip")
 
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 02c2c64..f8cb351 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -279,6 +279,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.layout.put(self.__playhead, self.nsToPixel(self.__last_position), 0)
         self.__disableCenterPlayhead = False
         self._scrubbing = False
+        self._scrolling = False
 
         self.__snap_position = 0
         self.__snap_bar = VerticalBar("SnapBar")
@@ -606,6 +607,11 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
             if clip:
                 clip.shrinkTrimHandles()
 
+        self._scrolling = res and button == 2
+        if self._scrolling:
+            self._scroll_start_x = event.x
+            self._scroll_start_y = event.y
+
         return False
 
     def __buttonReleaseEventCb(self, unused_widget, event):
@@ -622,6 +628,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
         self._scrubbing = False
 
+        self._scrolling = False
+
         if allow_seek and res and (button == 1 and self.app.settings.leftClickAlsoSeeks):
             self._seek(event)
 
@@ -658,6 +666,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
             self.__marquee.move(event)
         elif self._scrubbing:
             self._seek(event)
+        elif self._scrolling:
+            self.__scroll(event)
 
         return False
 
@@ -669,6 +679,13 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         position = max(0, self.pixelToNs(x))
         self._project.seeker.seek(position)
 
+    def __scroll(self, event):
+        # determine how much to move the canvas
+        x_diff = self._scroll_start_x - event.x
+        self.hadj.set_value(self.hadj.get_value() + x_diff)
+        y_diff = self._scroll_start_y - event.y
+        self.vadj.set_value(self.vadj.get_value() + y_diff)
+
     def _selectUnderMarquee(self):
         self.resetSelectionGroup()
         if self.__marquee.props.width_request > 0:


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