[pitivi/gtktimeline] timeline: Represent audio only or video only clips up/down inside the layer
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/gtktimeline] timeline: Represent audio only or video only clips up/down inside the layer
- Date: Fri, 5 Jun 2015 20:59:58 +0000 (UTC)
commit e12e1f35b567616f5196393af9aa36ebd6f3c874
Author: Thibault Saunier <tsaunier gnome org>
Date: Fri Jun 5 21:15:43 2015 +0200
timeline: Represent audio only or video only clips up/down inside the layer
Making it more beautiful and avoiding confusion with old projects where we could have hidden
clips (audio only or video only clips on the same layer)
http://phabricator.freedesktop.org/T86
pitivi/timeline/elements.py | 53 +++++++++++++++++++++++++-----------------
pitivi/timeline/layer.py | 7 +++++-
pitivi/timeline/timeline.py | 34 +--------------------------
3 files changed, 39 insertions(+), 55 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 7d56943..35cd6a2 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -574,16 +574,10 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self._connectGES()
self.get_accessible().set_name(self.bClip.get_name())
- def do_get_preferred_width(self):
- return self.nsToPixel(self.bClip.props.duration), self.nsToPixel(self.bClip.props.duration)
-
- def do_get_preferred_height(self):
- parent = self.get_parent()
- return parent.get_allocated_height(), parent.get_allocated_height()
-
- def _savePositionState(self):
+ def _savePositionState(self, y=0):
self.__force_position_update = False
self._current_x = self.nsToPixel(self.bClip.props.start)
+ self._current_y = y
self._curent_width = self.nsToPixel(self.bClip.props.duration)
parent = self.get_parent()
if parent:
@@ -593,26 +587,48 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self._current_parent_height = 0
self._current_parent = parent
+ def __computeHeightAndY(self):
+ parent = self.get_parent()
+ parent_height = parent.get_allocated_height()
+
+ y = 0
+ height = parent_height
+ has_video = self.bClip.find_track_elements(None, GES.TrackType.VIDEO, GObject.TYPE_NONE)
+ has_audio = self.bClip.find_track_elements(None, GES.TrackType.AUDIO, GObject.TYPE_NONE)
+ if not has_video or not has_audio:
+ if self.layer and self.layer.media_types == (GES.TrackType.AUDIO | GES.TrackType.VIDEO):
+ height = parent_height / 2
+ if not has_video:
+ y = height
+
+ return height, y
+
def updatePosition(self):
parent = self.get_parent()
+
+ if not parent or not self.layer:
+ return
+
x = self.nsToPixel(self.bClip.props.start)
width = self.nsToPixel(self.bClip.props.duration)
parent_height = parent.get_allocated_height()
+ height, y = self.__computeHeightAndY()
if self.__force_position_update or \
x != self._current_x or \
+ y != self._current_y or \
width != self._curent_width \
or parent_height != self._current_parent_height or \
parent != self._current_parent:
- self.layer.move(self, x, 0)
- self.set_size_request(width, parent_height)
+ self.layer.move(self, x, y)
+ self.set_size_request(width, height)
elements = self._elements_container.get_children()
for child in elements:
- child.setSize(width, parent_height / len(elements))
+ child.setSize(width, height / len(elements))
- self._savePositionState()
+ self._savePositionState(y)
def _setupWidget(self):
pass
@@ -705,20 +721,13 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
return False
def _startChangedCb(self, unused_clip, unused_pspec):
- if self.get_parent() is None:
- # FIXME Check why that happens at all (looks like a GTK bug)
- return
-
- self.layer.move(self, self.nsToPixel(self.bClip.props.start), 0)
+ self.updatePosition()
def _durationChangedCb(self, unused_clip, unused_pspec):
- parent = self.get_parent()
- if parent:
- duration = self.nsToPixel(self.bClip.props.duration)
- parent_height = parent.get_allocated_height()
- self.set_size_request(duration, parent_height)
+ self.updatePosition()
def _layerChangedCb(self, bClip, unused_pspec):
+ self.updatePosition()
bLayer = bClip.props.layer
if bLayer:
self.layer = bLayer.ui
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index f6698d1..e82a8e2 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -437,6 +437,7 @@ class Layer(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self.info("Not updating media types as"
" we are editing the timeline")
return
+ old_media_types = self.media_types
self.media_types = GES.TrackType(0)
bClips = self.bLayer.get_clips()
@@ -472,6 +473,9 @@ class Layer(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self.props.height_request = height
self.bLayer.control_ui.props.height_request = height
+ if old_media_types != self.media_types:
+ self.updatePosition()
+
def move(self, child, x, y):
self._layout.move(child, x, y)
@@ -528,7 +532,8 @@ class Layer(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
def updatePosition(self):
for bClip in self.bLayer.get_clips():
- bClip.ui.updatePosition()
+ if hasattr(bClip, "ui"):
+ bClip.ui.updatePosition()
def do_draw(self, cr):
Gtk.Box.do_draw(self, cr)
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index c123248..682102c 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1483,43 +1483,13 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
if self.bTimeline:
self.app.action_log.begin("ungroup")
- containers = set({})
-
for obj in self.timeline.selection:
toplevel = obj.get_toplevel_parent()
if toplevel == self.timeline.current_group:
for child in toplevel.get_children(False):
- containers.add(child)
- toplevel.ungroup(False)
+ child.ungroup(False)
else:
- containers.add(toplevel)
-
- for container in containers:
- was_clip = isinstance(container, GES.Clip)
- clips = GES.Container.ungroup(container, False)
- if not was_clip:
- continue
-
- new_layers = {}
- for clip in clips:
- if isinstance(clip, GES.Clip):
- all_audio = True
- for child in clip.get_children(True):
- if child.get_track_type() != GES.TrackType.AUDIO:
- all_audio = False
- break
-
- if not all_audio:
- self.debug("Not all audio, not moving anything to a new layer")
-
- continue
-
- new_layer = new_layers.get(clip.get_layer().get_priority(), None)
- if not new_layer:
- new_layer = self.timeline.createLayer(clip.get_layer().get_priority() + 1)
- new_layers[clip.get_layer().get_priority()] = new_layer
- self.info("Moving audio audio clip %s to new layer %s" % (clip, new_layer))
- clip.move_to_layer(new_layer)
+ toplevel.ungroup(False)
self.timeline.resetSelectionGroup()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]