[pitivi] Add separators between layer controls



commit 2e285906539d1103d87b52fafe3c467ff01ac32e
Author: Paul Lange <palango gmx de>
Date:   Fri Jul 6 16:04:23 2012 +0200

    Add separators between layer controls

 pitivi/timeline/layer.py    |   41 ++++++++++++++++++++++++++++++-----------
 pitivi/timeline/timeline.py |   19 ++++++++++---------
 2 files changed, 40 insertions(+), 20 deletions(-)
---
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index a56ae86..f87a62a 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -1,7 +1,7 @@
 # -- coding: utf-8 --
 # PiTiVi , Non-linear video editor
 #
-#       pitivi/timeline/layercontrols.py
+#       pitivi/timeline/layer.py
 #
 # Copyright (c) 2012, Paul Lange <palango gmx de>
 #
@@ -32,7 +32,7 @@ from pitivi.utils.ui import LAYER_SPACING
 
 # TODO add tooltips
 # TODO GTK3 port to GtkGrid
-class BaseLayerControl(gtk.EventBox, Loggable):
+class BaseLayerControl(gtk.VBox, Loggable):
     """
     Base Layer control classes
     """
@@ -40,13 +40,9 @@ class BaseLayerControl(gtk.EventBox, Loggable):
     __gtype_name__ = 'LayerControl'
 
     def __init__(self, app, layer, layer_type):
-        gtk.EventBox.__init__(self)
+        gtk.VBox.__init__(self, spacing=0)
         Loggable.__init__(self)
 
-        table = gtk.Table(rows=2, columns=2)
-        table.props.border_width = 2
-        self.add(table)
-
         self._app = app
         self._layer = layer
         self._selected = False
@@ -57,11 +53,19 @@ class BaseLayerControl(gtk.EventBox, Loggable):
         # that is used for list items in TreeView.
         self.SELECTED_COLOR = self.rc_get_style().base[gtk.STATE_SELECTED]
 
-        self.connect("button_press_event", self._buttonPressCb)
-
+        table = gtk.Table(rows=2, columns=2)
+        table.props.border_width = 2
         table.set_row_spacings(3)
         table.set_col_spacings(3)
 
+        self.eventbox = gtk.EventBox()
+        self.eventbox.add(table)
+        self.eventbox.connect("button_press_event", self._buttonPressCb)
+        self.pack_start(self.eventbox)
+
+        self.sep = SpacedSeparator()
+        self.pack_start(self.sep)
+
         icon_mapping = {ges.TRACK_TYPE_AUDIO: "audio-x-generic",
                         ges.TRACK_TYPE_VIDEO: "video-x-generic"}
 
@@ -171,10 +175,10 @@ class BaseLayerControl(gtk.EventBox, Loggable):
         Called when the selection state changes
         """
         if self.selected:
-            self.modify_bg(gtk.STATE_NORMAL, self.SELECTED_COLOR)
+            self.eventbox.modify_bg(gtk.STATE_NORMAL, self.SELECTED_COLOR)
             self.name_entry.modify_bg(gtk.STATE_NORMAL, self.SELECTED_COLOR)
         else:
-            self.modify_bg(gtk.STATE_NORMAL, self.UNSELECTED_COLOR)
+            self.eventbox.modify_bg(gtk.STATE_NORMAL, self.UNSELECTED_COLOR)
             self.name_entry.modify_bg(gtk.STATE_NORMAL, self.UNSELECTED_COLOR)
 
         # continue GTK signal propagation
@@ -187,6 +191,12 @@ class BaseLayerControl(gtk.EventBox, Loggable):
     def getHeight(self):
         return self.get_allocation().height
 
+    def getSeparatorHeight(self):
+        return self.sep.get_allocation().height
+
+    def getControlHeight(self):
+        return self.getHeight() - self.getSeparatorHeight()
+
     def setSoloState(self, state):
         self.solo_button.set_active(state)
 
@@ -274,3 +284,12 @@ class TwoStateButton(gtk.Button):
 
         self.set_label(self.states[self._state])
         self.emit("changed-state", self._state)
+
+
+class SpacedSeparator(gtk.VBox):
+
+    def __init__(self):
+        gtk.VBox.__init__(self)
+
+        self.add(gtk.HSeparator())
+        self.props.border_width = 6
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 4e44266..dd75c11 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -495,12 +495,15 @@ class TimelineControls(gtk.VBox, Loggable):
         self._layer_controls = {}
         self._selected_layer = None
         self._timeline = None
-        self.set_spacing(LAYER_SPACING)
+        self.set_spacing(0)
+        self.separator_height = 0
         self.type_map = {ges.TRACK_TYPE_AUDIO: AudioLayerControl,
                          ges.TRACK_TYPE_VIDEO: VideoLayerControl}
         self.connect("size-allocate", self._sizeAllocatedCb)
 
     def _sizeAllocatedCb(self, widget, alloc):
+        if self.children():
+            self.separator_height = self.children()[0].getSeparatorHeight()
         self.app.gui.timeline_ui._canvas.updateTracks()
 
 ## Timeline callbacks
@@ -569,9 +572,9 @@ class TimelineControls(gtk.VBox, Loggable):
 
     def getHeightOfLayer(self, track_type, layer):
         if track_type == ges.TRACK_TYPE_VIDEO:
-            return self._layer_controls[layer][ges.TRACK_TYPE_VIDEO].getHeight()
+            return self._layer_controls[layer][ges.TRACK_TYPE_VIDEO].getControlHeight()
         else:
-            return self._layer_controls[layer][ges.TRACK_TYPE_AUDIO].getHeight()
+            return self._layer_controls[layer][ges.TRACK_TYPE_AUDIO].getControlHeight()
 
     def getYOfLayer(self, track_type, layer):
         y = 0
@@ -581,7 +584,6 @@ class TimelineControls(gtk.VBox, Loggable):
                 return y
 
             y += child.getHeight()
-            y += LAYER_SPACING
         return 0
 
     def getHeightOfTrack(self, track_type):
@@ -589,9 +591,8 @@ class TimelineControls(gtk.VBox, Loggable):
         for child in self.get_children():
             if isinstance(child, self.type_map[track_type]):
                 y += child.getHeight()
-                y += LAYER_SPACING
 
-        return y - LAYER_SPACING
+        return y - self.separator_height
 
     def getPriorityForY(self, y):
         priority = -1
@@ -602,7 +603,7 @@ class TimelineControls(gtk.VBox, Loggable):
             if y <= current:
                 return priority
 
-            current += child.getHeight() + LAYER_SPACING
+            current += child.getHeight()
             priority += 1
 
         # another check if priority has been incremented but not returned
@@ -655,7 +656,7 @@ class TimelineControls(gtk.VBox, Loggable):
         # count height
         for child in self.get_children():
             # calculate upper bound
-            next_y = current_y + child.getHeight()
+            next_y = current_y + child.getControlHeight()
 
             # if y is in bounds, activate control and terminate
             if y >= current_y and y <= next_y:
@@ -663,7 +664,7 @@ class TimelineControls(gtk.VBox, Loggable):
                 return
             # else check next control
             else:
-                current_y = next_y + LAYER_SPACING
+                current_y += child.getHeight()
 
 
 class InfoStub(gtk.HBox, Loggable):



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