[pitivi/ges: 79/287] ui: Handle track height properly using layers instead of calculation ourself
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 79/287] ui: Handle track height properly using layers instead of calculation ourself
- Date: Thu, 15 Mar 2012 16:32:28 +0000 (UTC)
commit 14196ee8a2a5de868de2837b4e09033f267095bb
Author: Thibault Saunier <thibault saunier collabora com>
Date: Thu Dec 8 15:09:36 2011 -0300
ui: Handle track height properly using layers instead of calculation ourself
+ Make MoveContext, and Track Loggable
+ readd headers to track.py
pitivi/timeline/timeline.py | 32 ++++++++++++++---
pitivi/ui/timeline.py | 3 +-
pitivi/ui/track.py | 78 +++++++++++++++++++++++-------------------
3 files changed, 71 insertions(+), 42 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index b70a912..50a0895 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -23,6 +23,7 @@
import ges
from pitivi.utils import infinity
+from pitivi.log.loggable import Loggable
from pitivi.signalinterface import Signallable
from pitivi.timeline.gap import Gap, SmallestGapsFinder, invalid_gap
@@ -194,13 +195,14 @@ class EditingContext(object):
return gaps.left_gap, gaps.right_gap
-class MoveContext(EditingContext):
+class MoveContext(EditingContext, Loggable):
"""An editing context which sets the start point of the editing targets.
It has support for ripple, slip-and-slide editing modes."""
def __init__(self, timeline, focus, other):
EditingContext.__init__(self, timeline, focus, other)
+ Loggable.__init__(self)
min_priority = infinity
earliest = infinity
@@ -354,12 +356,28 @@ class MoveContext(EditingContext):
return start
+ def _ensureLayer(self):
+ """
+ Make sure we have a layer in our timeline
+
+ Returns: The number of layer present in self.timeline
+ """
+ num_layers = len(self.timeline.get_layers())
+
+ if (num_layers == 0):
+ layer = ges.TimelineLayer()
+ layer.props.auto_transition = True
+ self.timeline.add_layer(layer)
+ num_layers = 1
+
+ return num_layers
+
def _defaultTo(self, position, priority):
if self._snap:
position = self.snapToEdge(position,
position + self.default_span)
- num_layers = len(self.timeline.get_layers())
+ num_layers = self._ensureLayer()
#Make sure the priority is between 0 and 1 not skipping
#any layer
@@ -383,6 +401,7 @@ class MoveContext(EditingContext):
moved = True
if not moved:
+ self.debug("Adding layer")
layer = ges.TimelineLayer()
layer.props.auto_transition = True
layer.props.priority = priority
@@ -399,9 +418,10 @@ class MoveContext(EditingContext):
obj.props.start = long(position + s_offset)
#Remove empty layers
- for layer in self.timeline.get_layers():
- if not len(layer.get_objects()):
- self.timeline.remove_layer(layer)
+ last_layer = self.timeline.get_layers()[-1]
+ if not last_layer.get_objects():
+ self.debug("Removing layer")
+ self.timeline.remove_layer(last_layer)
return position, priority
@@ -713,7 +733,7 @@ class Selection(Signallable):
"""
track_effects = []
for timeline_object in self.selected:
- for track in timeline_object.track_objects:
+ for track in timeline_object.get_track_objects():
if isinstance(track, ges.TrackEffect):
track_effects.append(track)
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 7049e07..8e65129 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -708,7 +708,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
"The GESTimeline")
def _layerAddedCb(self, unused_layer, unused_user_data):
- num_layers = (self._timeline.get_layers()[-1].props.priority + 1)
+ layers = self._timeline.get_layers()
+ num_layers = len(layers)
self.vadj.props.upper = (LAYER_HEIGHT_EXPANDED + LAYER_SPACING + TRACK_SPACING) * 2 * num_layers
diff --git a/pitivi/ui/track.py b/pitivi/ui/track.py
index 1dccb26..c316e6f 100644
--- a/pitivi/ui/track.py
+++ b/pitivi/ui/track.py
@@ -1,11 +1,36 @@
-from pitivi.ui.zoominterface import Zoomable
-from pitivi.ui.trackobject import TrackObject
-from pitivi.receiver import receiver, handler
-from pitivi.ui.common import LAYER_HEIGHT_EXPANDED, LAYER_HEIGHT_COLLAPSED, LAYER_SPACING
+# PiTiVi , Non-linear video editor
+#
+# pitivi/timeline/timeline.py
+#
+# Copyright (c) 2005, Edward Hervey <bilboed bilboed com>
+# Copyright (c) 2009, Alessandro Decina <alessandro decina collabora co uk>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
import goocanvas
import ges
import gobject
+from pitivi.log.loggable import Loggable
+from pitivi.ui.zoominterface import Zoomable
+from pitivi.receiver import receiver, handler
+from pitivi.ui.trackobject import TrackObject
+from pitivi.ui.common import LAYER_HEIGHT_EXPANDED,\
+ LAYER_HEIGHT_COLLAPSED, LAYER_SPACING
+
class Transition(goocanvas.Rect, Zoomable):
@@ -57,18 +82,18 @@ class Transition(goocanvas.Rect, Zoomable):
self._updateAll()
-class Track(goocanvas.Group, Zoomable):
+class Track(goocanvas.Group, Zoomable, Loggable):
__gtype_name__ = 'Track'
def __init__(self, instance, track, timeline=None):
goocanvas.Group.__init__(self)
Zoomable.__init__(self)
+ Loggable.__init__(self)
self.app = instance
self.widgets = {}
self.transitions = []
self.timeline = timeline
self.track = track
- self.max_priority = 0
self._expanded = True
## Properties
@@ -82,22 +107,13 @@ class Track(goocanvas.Group, Zoomable):
self.get_canvas().regroupTracks()
def getHeight(self):
- track_objects = self.track.get_objects()
- max_priority = 0
- for track_object in track_objects:
- if isinstance(track_object, ges.TrackAudioTestSource):
- continue
- if isinstance(track_object, ges.TrackVideoTestSource):
- continue
- priority = track_object.get_timeline_object().get_layer().get_property("priority")
- if priority > max_priority:
- max_priority = priority
- self.track.max_priority = max_priority
- if self.track.max_priority < 0:
- self.track.max_priority = 0
+ # FIXME we have a refcount issue somewhere, the following makes sure
+ # no to crash because of it
+ #track_objects = self.track.get_objects()
if self._expanded:
- return (1 + self.track.max_priority) * (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)
- #return LAYER_HEIGHT_EXPANDED + LAYER_SPACING
+ nb_layers = len(self.timeline.get_layers())
+
+ return nb_layers * (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)
else:
return LAYER_HEIGHT_COLLAPSED + LAYER_SPACING
@@ -108,6 +124,7 @@ class Track(goocanvas.Group, Zoomable):
## track signals
def _setTrack(self):
+ self.debug("Setting track")
if self.track:
for trackobj in self.track.get_objects():
self._objectAdded(None, trackobj)
@@ -116,21 +133,12 @@ class Track(goocanvas.Group, Zoomable):
@handler(track, "track-object-added")
def _objectAdded(self, unused_timeline, track_object):
- if isinstance(track_object, ges.TrackParseLaunchEffect):
- return
- if isinstance(track_object, ges.TrackAudioTestSource):
- return
- if isinstance(track_object, ges.TrackVideoTestSource):
- return
- if isinstance(track_object, ges.TrackVideoTestSource):
- return
- if isinstance(track_object, ges.TrackAudioTransition):
- self._transitionAdded(track_object)
- return
- if isinstance(track_object, ges.TrackVideoTransition):
+ if isinstance(track_object, ges.TrackTransition):
self._transitionAdded(track_object)
- return
- gobject.timeout_add(1, self.check, track_object)
+ elif not isinstance(track_object, ges.TrackEffect):
+ #FIXME GES hack, waiting for the discoverer to do its job
+ # so the duration properies are set properly
+ gobject.timeout_add(1, self.check, track_object)
def check(self, tr_obj):
if tr_obj.get_timeline_object():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]