[pitivi] timeline: Fix zoom box and layers controls different widths



commit 1c15f47f226c936965a74a6b84335550e649c7af
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Aug 29 22:44:07 2016 +0200

    timeline: Fix zoom box and layers controls different widths
    
    This also fixes the playhead looking broken while the startup wizard
    dialog is shown.
    
    Differential Revision: https://phabricator.freedesktop.org/D1288

 build/flatpak/pitivi-flatpak |    1 +
 pitivi/timeline/layer.py     |    5 -----
 pitivi/timeline/timeline.py  |   34 ++++++++++++++++++++--------------
 pitivi/utils/ui.py           |    1 -
 pitivi/utils/widgets.py      |    2 --
 tests/test_undo_timeline.py  |    3 +--
 6 files changed, 22 insertions(+), 24 deletions(-)
---
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index 120ccc8..3f7cea3 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -508,6 +508,7 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
         for envvar in [
                 "GST_CHECKS", "GST_DEBUG", "GST_VALIDATE", "GST_VALIDATE_LAUNCHER_DEBUG",
                 "PITIVI_DEBUG", "PITIVI_DEVELOPMENT", "DISPLAY", "GST_DEBUG_DUMP_DOT_DIR",
+                "LANG",
                 ("GST_PLUGIN_SYSTEM_PATH", "/app/lib/gstreamer-1.0/"),
                 ("GST_PRESET_PATH",
                  "/app/share/gstreamer-1.0/presets/:/app/share/pitivi/gstpresets/"),
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 3e7f975..74b9c3f 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -110,7 +110,6 @@ class LayerControls(Gtk.EventBox, Loggable):
         self.ges_timeline = self.ges_layer.get_timeline()
         self.app = app
 
-        self.props.width_request = ui.CONTROL_WIDTH
         # Half the height because we display only the video strip when empty.
         self.props.height_request = ui.LAYER_HEIGHT / 2 + ui.PADDING * 3
         self.props.hexpand = True
@@ -128,8 +127,6 @@ class LayerControls(Gtk.EventBox, Loggable):
         hbox.pack_start(self.sep, False, False, 0)
 
         self.before_sep = SpacedSeparator(Gtk.PositionType.TOP)
-        self.before_sep.props.width_request = self.props.width_request - 1
-        self.before_sep.props.vexpand = False
         vbox.pack_start(self.before_sep, False, False, 0)
 
         name_row = Gtk.Box()
@@ -162,8 +159,6 @@ class LayerControls(Gtk.EventBox, Loggable):
         vbox.pack_start(space, False, False, 0)
 
         self.after_sep = SpacedSeparator(Gtk.PositionType.BOTTOM)
-        self.after_sep.props.width_request = self.props.width_request - 1
-        self.after_sep.props.vexpand = False
         vbox.pack_start(self.after_sep, False, False, 0)
 
         self.ges_layer.connect("notify::priority", self.__layerPriorityChangedCb)
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index c3455a9..1281f1a 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -47,7 +47,6 @@ from pitivi.utils.timeline import TimelineError
 from pitivi.utils.timeline import Zoomable
 from pitivi.utils.ui import alter_style_class
 from pitivi.utils.ui import clear_styles
-from pitivi.utils.ui import CONTROL_WIDTH
 from pitivi.utils.ui import EFFECT_TARGET_ENTRY
 from pitivi.utils.ui import EXPANDED_SIZE
 from pitivi.utils.ui import LAYER_HEIGHT
@@ -202,7 +201,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
     __gtype_name__ = "PitiviTimeline"
 
-    def __init__(self, container, app):
+    def __init__(self, container, app, size_group=None):
         Gtk.EventBox.__init__(self)
         Zoomable.__init__(self)
         Loggable.__init__(self)
@@ -235,6 +234,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.__layers_controls_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
         self.__layers_controls_vbox.props.hexpand = False
         self.__layers_controls_vbox.props.valign = Gtk.Align.START
+        if size_group:
+            size_group.add_widget(self.__layers_controls_vbox)
 
         # Stuff the layers controls in a viewport so it can be scrolled.
         viewport = Gtk.Viewport(vadjustment=self.vadj)
@@ -301,6 +302,10 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.connect("drag-drop", self._drag_drop_cb)
         self.connect("drag-data-received", self._drag_data_received_cb)
 
+    @property
+    def controls_width(self):
+        return self.__layers_controls_vbox.get_allocated_width()
+
     def sendFakeEvent(self, event, event_widget=None):
         # Member usefull for testsing
         self.__fake_event_widget = event_widget
@@ -453,12 +458,11 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.__draw_snap_indicator(cr)
 
     def __draw_vertical_bar(self, cr, xpos, width, color):
-        hadj_position = self.hadj.get_value()
-        layer_controls_width = self.__layers_controls_vbox.get_allocated_width()
-        xpos = xpos + layer_controls_width - hadj_position
-        if xpos < layer_controls_width:
+        xpos -= self.hadj.get_value()
+        if xpos < 0:
             return
 
+        xpos += self.controls_width
         height = self.get_allocated_height()
         cr.set_line_width(width)
         cr.move_to(xpos, 0)
@@ -525,7 +529,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
         if x is not None:
             x += self.hadj.props.value
-            x -= CONTROL_WIDTH
+            x -= self.controls_width
 
         if y is not None:
             y += self.vadj.props.value
@@ -564,7 +568,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
                 self.parent.scroll_up()
         elif event.get_state() & (Gdk.ModifierType.CONTROL_MASK |
                                   Gdk.ModifierType.MOD1_MASK):
-            x -= CONTROL_WIDTH
+            x -= self.controls_width
             # Figure out first where to scroll at the end
             if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
                 # The time at the mouse cursor.
@@ -713,7 +717,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
     def _seek(self, event):
         event_widget = self.get_event_widget(event)
         x, unused_y = event_widget.translate_coordinates(self, event.x, event.y)
-        x -= CONTROL_WIDTH
+        x -= self.controls_width
         x += self.hadj.get_value()
         position = max(0, self.pixelToNs(x))
         self._project.pipeline.simple_seek(position)
@@ -1050,7 +1054,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
                                                   not self.dropping_clips)
 
         x, y = event_widget.translate_coordinates(self, x, y)
-        x -= CONTROL_WIDTH
+        x -= self.controls_width
         x += self.hadj.get_value()
         y += self.vadj.get_value()
 
@@ -1315,9 +1319,11 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
     # Internal API
 
     def _createUi(self):
-        self.zoomBox = ZoomBox(self)
+        left_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
+        zoom_box = ZoomBox(self)
+        left_size_group.add_widget(zoom_box)
 
-        self.timeline = Timeline(self, self.app)
+        self.timeline = Timeline(self, self.app, left_size_group)
         self.hadj = self.timeline.layout.get_hadjustment()
         self.vadj = self.timeline.layout.get_vadjustment()
 
@@ -1345,7 +1351,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             ".%s.trough" % Gtk.STYLE_CLASS_SCROLLBAR, hscrollbar,
             "border: alpha (@base_color, 0.0); background: alpha (@base_color, 0.0);")
 
-        self.attach(self.zoomBox, 0, 0, 1, 1)
+        self.attach(zoom_box, 0, 0, 1, 1)
         self.attach(self.ruler, 1, 0, 1, 1)
         self.attach(self.timeline, 0, 1, 2, 1)
         self.attach(vscrollbar, 2, 1, 1, 1)
@@ -1711,7 +1717,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
     def transposeXY(self, x, y):
         height = self.ruler.get_allocation().height
         x += self.timeline.get_scroll_point().x
-        return x - CONTROL_WIDTH, y - height
+        return x - self.timeline.controls_width, y - height
 
     # Zoomable
 
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index ebad6f6..f21bd13 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -49,7 +49,6 @@ from pitivi.utils.misc import path_from_uri
 
 # Dimensions in pixels
 EXPANDED_SIZE = 65
-CONTROL_WIDTH = 240
 
 PADDING = 6
 SPACING = 10
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 1902ca7..26d7d4a 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -35,7 +35,6 @@ from pitivi.configure import get_ui_dir
 from pitivi.utils.loggable import Loggable
 from pitivi.utils.timeline import Zoomable
 from pitivi.utils.ui import beautify_length
-from pitivi.utils.ui import CONTROL_WIDTH
 from pitivi.utils.ui import disable_scroll
 from pitivi.utils.ui import pack_color_32
 from pitivi.utils.ui import pack_color_64
@@ -1064,7 +1063,6 @@ class ZoomBox(Gtk.Grid, Zoomable):
 
         self.set_hexpand(False)
         self.set_column_spacing(ZOOM_SLIDER_PADDING)
-        self.set_size_request(CONTROL_WIDTH, -1)
         self.show_all()
 
     def _zoomAdjustmentChangedCb(self, adjustment):
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 68ac3a1..71c1d89 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -33,7 +33,6 @@ from pitivi.undo.timeline import ClipAdded
 from pitivi.undo.timeline import ClipRemoved
 from pitivi.undo.timeline import EffectAddedAction
 from pitivi.undo.undo import PropertyChangedAction
-from pitivi.utils.ui import CONTROL_WIDTH
 from pitivi.utils.ui import LAYER_HEIGHT
 from pitivi.utils.ui import URI_TARGET_ENTRY
 from tests import common
@@ -687,7 +686,7 @@ class TestDragDropUndo(BaseTestUndoTimeline):
                 def translate_coordinates(widget, x, y):
                     return x, y
                 timeline_ui.translate_coordinates = translate_coordinates
-                timeline_ui._drag_motion_cb(None, None, CONTROL_WIDTH, LAYER_HEIGHT * 2, 0)
+                timeline_ui._drag_motion_cb(None, None, 0, LAYER_HEIGHT * 2, 0)
                 self.assertFalse(timeline_ui.drag_get_data.called)
                 self.assertIsNotNone(timeline_ui.draggingElement)
                 self.assertTrue(timeline_ui.dropping_clips)


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