[pitivi] Handle initialization of layer controls well
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Handle initialization of layer controls well
- Date: Sat, 21 Jul 2012 19:58:17 +0000 (UTC)
commit 51d49e3ecf3f464d48cde7ac5f7f233734f1dda8
Author: Paul Lange <palango gmx de>
Date: Thu May 17 19:57:24 2012 -0500
Handle initialization of layer controls well
pitivi/timeline/timeline.py | 28 ++++++++++++++++++----------
pitivi/timeline/track.py | 14 +++++++++++++-
2 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 801d4c7..232bc87 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -469,18 +469,28 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
self.height = height
self._request_size()
+ def updateTracks(self):
+ print("Updating all TrackObjects")
+ for track in self._tracks:
+ track.updateTrackObjects()
+
class TimelineControls(gtk.VBox, Loggable):
"""Contains the timeline track names."""
- def __init__(self):
+ def __init__(self, instance):
gtk.VBox.__init__(self)
Loggable.__init__(self)
+ self.app = instance
self._track_controls = {}
self._timeline = None
self.set_spacing(LAYER_SPACING)
self.type_map = {ges.TRACK_TYPE_AUDIO: AudioLayerControl,
ges.TRACK_TYPE_VIDEO: VideoLayerControl}
+ self.connect("size-allocate", self._sizeAllocatedCb)
+
+ def _sizeAllocatedCb(self, widget, alloc):
+ self.app.gui.timeline_ui._canvas.updateTracks()
## Timeline callbacks
@@ -545,23 +555,21 @@ class TimelineControls(gtk.VBox, Loggable):
del self._track_controls[layer]
+ def getHeightOfLayer(self, track_type, layer):
+ if track_type == ges.TRACK_TYPE_VIDEO:
+ return self._track_controls[layer]["video"].getHeight()
+ else:
+ return self._track_controls[layer]["audio"].getHeight()
+
def getYOfLayer(self, track_type, layer):
y = 0
- print "start new calculation of y"
for child in self.get_children():
- print type(child)
- print isinstance(child, self.type_map[track_type])
- print layer == child._layer
if layer == child._layer and \
isinstance(child, self.type_map[track_type]):
- print "return y = %s" % y
return y
y += child.getHeight()
- print "h %s of %s" % (child.getHeight(), child)
y += LAYER_SPACING
- print "iter y = %s" % y
-
return 0
# maybe do a list with values
@@ -715,7 +723,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.attach(zoom_controls_hbox, 0, 1, 0, 1, yoptions=0, xoptions=gtk.FILL)
# controls for tracks and layers
- self._controls = TimelineControls()
+ self._controls = TimelineControls(self.app)
controlwindow = gtk.Viewport(None, self.vadj)
controlwindow.add(self._controls)
controlwindow.set_size_request(-1, 1)
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index d200129..ae11ccc 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -417,8 +417,10 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
def setHeight(self, height):
self._height = height
+ self.bg.props.height = height
self.start_handle.props.height = height
self.end_handle.props.height = height
+ self._selec_indic.props.height = height
self._update()
def getHeight(self):
@@ -574,9 +576,16 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
except Exception, e:
raise Exception(e)
+ # get layer and track_type
layer = self.element.get_timeline_object().get_layer()
track_type = self.element.get_track().props.track_type
+ # update height, compare with current height to not run into recursion
+ new_height = self.app.gui.timeline_ui._controls.getHeightOfLayer(track_type, layer)
+ if self.height != new_height:
+ print "update heigth %s" % new_height
+ self.height = new_height
+
# get y position for layer
y = self.app.gui.timeline_ui._controls.getYOfLayer(track_type, layer)
#priority = self.element.get_timeline_object().get_layer().get_priority()
@@ -584,7 +593,6 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
# get relative y for audio
if track_type == ges.TRACK_TYPE_AUDIO:
y -= self.app.gui.timeline_ui._controls.getHeightOfVideo()
- print y
# Setting new position
self.set_simple_transform(x, y, 1, 0)
@@ -754,3 +762,7 @@ class Track(goocanvas.Group, Zoomable, Loggable):
self.add_child(w)
self.transitions.append(w)
w.raise_(None)
+
+ def updateTrackObjects(self):
+ for track_object in self.widgets.itervalues():
+ track_object._update()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]