[pitivi] timeline: Fix selection marquee forever visible



commit afa54b0684885083fc7687d939f5a4fabdcc90e9
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Jan 1 17:51:21 2020 +0100

    timeline: Fix selection marquee forever visible
    
    When the mouse cursor moves, instead of checking for marquee.start_x to
    determine we should update the marquee, we now check whether the marquee
    is visible.
    
    The change in Marquee.hide in 3761fdbf3a158f35bb87fb168153ccd94747cc43
    broke it.

 pitivi/timeline/timeline.py | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index a4bc2f30..5ddf4a2b 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -130,12 +130,15 @@ class Marquee(Gtk.Box, Loggable):
         self._timeline = timeline
         self.start_x, self.start_y = 0, 0
         self.end_x, self.end_y = self.start_x, self.start_y
+
+        self.props.no_show_all = True
         self.hide()
 
         self.get_style_context().add_class("Marquee")
 
     def hide(self):
         """Hides and resets the widget."""
+        self.start_x, self.start_y = 0, 0
         self.props.height_request = -1
         self.props.width_request = -1
         self.set_visible(False)
@@ -152,11 +155,13 @@ class Marquee(Gtk.Box, Loggable):
             self._timeline.layout.layers_vbox, event.x, event.y)
         self.end_x, self.end_y = self.start_x, self.start_y
 
+        self.props.width_request = 0
+        self.props.height_request = 0
+        self.set_visible(True)
+
     def move(self, event):
         """Sets the second corner of the marquee.
 
-        Also makes the marquee visible.
-
         Args:
             event (Gdk.EventMotion): The motion event which contains
                 the coordinates of the second corner.
@@ -167,11 +172,10 @@ class Marquee(Gtk.Box, Loggable):
 
         x = min(self.start_x, self.end_x)
         y = min(self.start_y, self.end_y)
-
         self.get_parent().move(self, x, y)
+
         self.props.width_request = abs(self.start_x - self.end_x)
         self.props.height_request = abs(self.start_y - self.end_y)
-        self.set_visible(True)
 
     def find_clips(self):
         """Finds the clips which intersect the marquee.
@@ -179,6 +183,9 @@ class Marquee(Gtk.Box, Loggable):
         Returns:
             List[GES.Clip]: The clips under the marquee.
         """
+        if self.props.width_request == 0:
+            return []
+
         start_layer = self._timeline.get_layer_at(self.start_y)[0]
         end_layer = self._timeline.get_layer_at(self.end_y)[0]
         start_pos = max(0, self._timeline.pixel_to_ns(self.start_x))
@@ -749,7 +756,9 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
             self.__end_moving_layer()
             return False
         elif res and button == 1:
-            self._select_under_marquee()
+            clips = self.layout.marquee.find_clips()
+            self.selection.set_selection(clips, SELECT)
+            self.layout.marquee.hide()
 
         self.scrubbing = False
 
@@ -865,7 +874,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
             if layer != self.__moving_layer:
                 priority = layer.get_priority()
                 self.move_layer(self.__moving_layer, priority)
-        elif self.layout.marquee.start_x:
+        elif self.layout.marquee.is_visible():
             self.layout.marquee.move(event)
         elif self.scrubbing:
             self._seek(event)
@@ -903,15 +912,6 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         y_diff = self._scroll_start_y - event.y
         self.vadj.set_value(self.vadj.get_value() + y_diff)
 
-    def _select_under_marquee(self):
-        if self.layout.marquee.props.width_request > 0:
-            clips = self.layout.marquee.find_clips()
-        else:
-            clips = []
-        self.selection.set_selection(clips, SELECT)
-
-        self.layout.marquee.hide()
-
     def update_position(self):
         for ges_layer in self.ges_timeline.get_layers():
             ges_layer.ui.update_position()


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