[pitivi] Allow to insert new layers
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Allow to insert new layers
- Date: Wed, 24 Apr 2013 18:03:36 +0000 (UTC)
commit 98c4b813126eb30f4c921f81bfa80b9e49c62d36
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date: Thu Apr 18 04:43:24 2013 +0200
Allow to insert new layers
pitivi/mainwindow.py | 2 +-
pitivi/timeline/elements.py | 9 +++++++-
pitivi/timeline/timeline.py | 47 ++++++++++++++++++++++++++++++++++++++----
3 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 0e86690..05e2f02 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -432,7 +432,7 @@ class PitiviMainWindow(Gtk.Window, Loggable):
# Now, the lower part: the timeline
timeline_area = Gtk.HBox()
- self.timeline_ui = Timeline(instance, self.uimanager)
+ self.timeline_ui = Timeline(self, instance, self.uimanager)
self.timeline_ui.setProjectManager(self.app.projectManager)
self.timeline_ui.controls.connect("selection-changed", self._selectedLayerChangedCb)
ttb = self.uimanager.get_widget("/TimelineToolBar")
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 13929e8..0fe7737 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -146,6 +146,8 @@ class Ghostclip(Clutter.Actor):
self.set_background_color(Clutter.Color.new(100, 100, 100, 50))
self.props.visible = False
+ self.shouldCreateLayer = False
+
def setNbrLayers(self, nbrLayers):
self.nbrLayers = nbrLayers
@@ -171,13 +173,15 @@ class Ghostclip(Clutter.Actor):
y -= self.nbrLayers * (EXPANDED_SIZE + SPACING)
# Would that be a new layer ?
- if priority == self.nbrLayers:
+ if priority == self.nbrLayers or y % (EXPANDED_SIZE + SPACING) < SPACING:
+ self.shouldCreateLayer = True
self.set_size(self.props.width, SPACING)
self.props.y = priority * (EXPANDED_SIZE + SPACING)
if self.track_type == GES.TrackType.AUDIO:
self.props.y += self.nbrLayers * (EXPANDED_SIZE + SPACING)
self.props.visible = True
else:
+ self.shouldCreateLayer = False
# No need to mockup on the same layer
if self.bElement and priority == self.bElement.get_parent().get_layer().get_priority():
self.props.visible = False
@@ -574,6 +578,9 @@ class URISourceElement(TimelineElement):
if self.brother:
self.brother.ghostclip.props.visible = False
+ if self.ghostclip.shouldCreateLayer:
+ self.timeline.insertLayer(self.ghostclip)
+
self._context.editTo(new_start, priority)
self._context.finish()
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index e811aba..f5125a8 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -204,6 +204,20 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
return elem
return None
+ def insertLayer(self, ghostclip):
+ layer = None
+ if ghostclip.priority < len(self.bTimeline.get_layers()):
+ self.bTimeline.enable_update(False)
+ for layer in self.bTimeline.get_layers():
+ if layer.get_priority() >= ghostclip.priority:
+ layer.props.priority += 1
+
+ layer = self.bTimeline.append_layer()
+ layer.props.priority = ghostclip.priority
+ self.bTimeline.enable_update(True)
+ self._container.controls._reorderLayerActors()
+ return layer
+
# drag and drop from the medialibrary
def resetGhostClips(self):
@@ -239,10 +253,16 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
layer = None
target = None
- for layer in self.bTimeline.get_layers():
- if layer.get_priority() == ghostclip.priority:
- target = layer
- break
+
+ if ghostclip.shouldCreateLayer:
+ layer = self.insertLayer(ghostclip)
+ target = layer
+ else:
+ for layer in self.bTimeline.get_layers():
+ if layer.get_priority() == ghostclip.priority:
+ target = layer
+ break
+
if target is None:
layer = self.bTimeline.append_layer()
@@ -482,12 +502,13 @@ def quit2_(*args, **kwargs):
class Timeline(Gtk.VBox, Zoomable):
- def __init__(self, instance, ui_manager):
+ def __init__(self, gui, instance, ui_manager):
Zoomable.__init__(self)
Gtk.VBox.__init__(self)
GObject.threads_init()
+ self.gui = gui
self.ui_manager = ui_manager
self.app = instance
self._settings = self.app.settings
@@ -602,6 +623,8 @@ class Timeline(Gtk.VBox, Zoomable):
self.timeline = TimelineStage(self)
self.controls = ControlContainer(self.timeline)
self.zoomBox = ZoomBox(self)
+ self.shiftMask = False
+ self.controlMask = False
self.stage.set_background_color(Clutter.Color.new(31, 30, 33, 255))
self.timeline.set_position(CONTROL_WIDTH, 0)
@@ -614,6 +637,8 @@ class Timeline(Gtk.VBox, Zoomable):
self.stage.connect("destroy", quit_)
self.stage.connect("button-press-event", self._clickedCb)
self.embed.connect("scroll-event", self._scrollEventCb)
+ self.gui.connect("key-press-event", self._keyPressEventCb)
+ self.gui.connect("key-release-event", self._keyReleaseEventCb)
self.point = Clutter.Point()
self.point.x = 0
@@ -945,6 +970,18 @@ class Timeline(Gtk.VBox, Zoomable):
# Callbacks
+ def _keyPressEventCb(self, widget, event):
+ if event.keyval == Gdk.KEY_Shift_L:
+ self.shiftMask = True
+ elif event.keyval == Gdk.KEY_Control_L:
+ self.controlMask = True
+
+ def _keyReleaseEventCb(self, widget, event):
+ if event.keyval == Gdk.KEY_Shift_L:
+ self.shiftMask = False
+ elif event.keyval == Gdk.KEY_Control_L:
+ self.controlMask = False
+
def _clickedCb(self, stage, event):
actor = self.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, event.x, event.y)
if actor == stage:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]