[pitivi] Update priority calculations, remove LAYER_HEIGHT_COLLAPSED



commit c0ea15a6d7390dbd4991b4e7db6d6c5cf9056ace
Author: Paul Lange <palango gmx de>
Date:   Fri May 18 04:50:57 2012 -0500

    Update priority calculations, remove LAYER_HEIGHT_COLLAPSED

 pitivi/timeline/timeline.py |   23 ++++++++++++++++++-----
 pitivi/timeline/track.py    |   20 ++++++--------------
 2 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index a359cff..a6827dd 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -53,10 +53,9 @@ from pitivi.dialogs.prefs import PreferencesDialog
 
 from pitivi.utils.receiver import receiver, handler
 from pitivi.utils.loggable import Loggable
-from pitivi.utils.ui import SPACING, TRACK_SPACING, LAYER_HEIGHT_EXPANDED,\
-    LAYER_SPACING, TYPE_PITIVI_FILESOURCE, VIDEO_EFFECT_TUPLE, \
-    AUDIO_EFFECT_TUPLE, EFFECT_TUPLE, FILESOURCE_TUPLE, TYPE_PITIVI_EFFECT, \
-    unpack_cairo_pattern, Point
+from pitivi.utils.ui import SPACING, TRACK_SPACING, unpack_cairo_pattern, \
+    LAYER_SPACING, TYPE_PITIVI_FILESOURCE, VIDEO_EFFECT_TUPLE, Point, \
+    AUDIO_EFFECT_TUPLE, EFFECT_TUPLE, FILESOURCE_TUPLE, TYPE_PITIVI_EFFECT
 
 # FIXME GES Port regression
 # from pitivi.utils.align import AutoAligner
@@ -587,6 +586,18 @@ class TimelineControls(gtk.VBox, Loggable):
 
         return y - LAYER_SPACING
 
+    def getPriorityForY(self, y):
+        priority = -1
+        current = 0
+        for child in self.get_children():
+            if y <= current:
+                return priority
+
+            current += child.getHeight() + LAYER_SPACING
+            priority += 1
+
+        return 0
+
 
 class InfoStub(gtk.HBox, Loggable):
     """
@@ -1136,7 +1147,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
     def _move_temp_source(self, x, y):
         x = self.hadj.props.value + x
         y = self.vadj.props.value + y
-        priority = int((y // (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)))
+
+        priority = self._controls.getPriorityForY(y)
+
         delta = Zoomable.pixelToNs(x)
         obj = self._temp_objects[0]
         self._move_context.editTo(delta, priority)
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index dec723a..628882e 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -39,8 +39,7 @@ from pitivi.settings import GlobalSettings
 from pitivi.utils.signal import Signallable
 from pitivi.utils.timeline import SELECT, SELECT_ADD, UNSELECT, \
     SELECT_BETWEEN, EditingContext, Controller, View, Zoomable
-from pitivi.utils.ui import LAYER_HEIGHT_EXPANDED,\
-        LAYER_HEIGHT_COLLAPSED, LAYER_SPACING, \
+from pitivi.utils.ui import LAYER_SPACING, \
         unpack_cairo_pattern, unpack_cairo_gradient
 from thumbnailer import Preview
 
@@ -209,8 +208,8 @@ class TrackObjectController(Controller):
         x = x + self._hadj.get_value()
 
         position = Zoomable.pixelToNs(x)
-        priority = int((y - self._y_offset + self._vadj.get_value()) //
-            (LAYER_HEIGHT_EXPANDED + LAYER_SPACING))
+        priority = self.app.gui.timeline_ui._controls.getPriorityForY(
+                        y - self._y_offset + self._vadj.get_value())
 
         self._context.setMode(self._getMode())
         self.debug("Setting position")
@@ -413,7 +412,7 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
 
 ## Properties
 
-    _height = LAYER_HEIGHT_EXPANDED
+    _height = 0
 
     def setHeight(self, height):
         self._height = height
@@ -433,16 +432,12 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
     def setExpanded(self, expanded):
         self._expanded = expanded
         if not self._expanded:
-            self.height = LAYER_HEIGHT_COLLAPSED
             self.preview.props.visibility = goocanvas.ITEM_INVISIBLE
             self.namebg.props.visibility = goocanvas.ITEM_INVISIBLE
-            self.bg.props.height = LAYER_HEIGHT_COLLAPSED
             self.name.props.y = 0
         else:
-            self.height = LAYER_HEIGHT_EXPANDED
             self.preview.props.visibility = goocanvas.ITEM_VISIBLE
             self.namebg.props.visibility = goocanvas.ITEM_VISIBLE
-            self.bg.props.height = LAYER_HEIGHT_EXPANDED
             self.name.props.y = NAME_VOFFSET + NAME_PADDING
 
     def getExpanded(self):
@@ -706,11 +701,8 @@ class Track(goocanvas.Group, Zoomable, Loggable):
             self.get_canvas().regroupTracks()
 
     def getHeight(self):
-        if self._expanded:
-            track_type = self.track.props.track_type
-            return self.app.gui.timeline_ui._controls.getHeightOfTrack(track_type)
-        else:
-            return LAYER_HEIGHT_COLLAPSED + LAYER_SPACING
+        track_type = self.track.props.track_type
+        return self.app.gui.timeline_ui._controls.getHeightOfTrack(track_type)
 
     height = property(getHeight)
 



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