[pitivi/ges: 12/287] GES : make it so you can drag and drop tl objects, trim them and adds transitions automatically
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 12/287] GES : make it so you can drag and drop tl objects, trim them and adds transitions automatically
- Date: Thu, 15 Mar 2012 16:26:50 +0000 (UTC)
commit b39687266bbc571430bd64a52e34bebb40803eb2
Author: Mathieu Duponchelle <seeed laposte net>
Date: Wed Jul 27 19:43:55 2011 +0200
GES : make it so you can drag and drop tl objects, trim them and adds transitions automatically
pitivi/timeline/timeline.py | 90 ++++++++++++++++++++++---------------------
pitivi/ui/timelinecanvas.py | 4 +-
pitivi/ui/trackobject.py | 51 ++++++++++--------------
3 files changed, 70 insertions(+), 75 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index b553db6..a8e8126 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -993,6 +993,7 @@ class EditingContext(object):
def finish(self):
"""Clean up timeline for normal editing"""
# TODO: post undo / redo action here
+ return
self.timeline.enableUpdates()
def setMode(self, mode):
@@ -1092,7 +1093,7 @@ class MoveContext(EditingContext):
self.tracks.add(obj.track)
else:
timeline_object = obj
- timeline_object_tracks = set(track_object.track for track_object
+ timeline_object_tracks = set(track_object.get_track() for track_object
in timeline_object.get_track_objects())
self.tracks.update(timeline_object_tracks)
@@ -1206,17 +1207,17 @@ class MoveContext(EditingContext):
initial_position = self.default_originals[focus_timeline_object][0]
initial_priority = self.default_originals[focus_timeline_object][-1]
- final_priority = self.focus.priority
- final_position = self.focus.start
+ final_priority = self.focus.get_property("priority")
+ final_position = self.focus.get_property("start")
priority = final_priority
# special case for transitions. Allow a single object to overlap
# either of its two neighbors if it overlaps no other objects
if len(self.timeline_objects) == 1:
- if not self._overlapsAreTransitions(focus_timeline_object,
- priority):
- self._defaultTo(initial_position, initial_priority)
+ #if not self._overlapsAreTransitions(focus_timeline_object,
+ #priority):
+ #self._defaultTo(initial_position, initial_priority)
EditingContext.finish(self)
return
@@ -1263,14 +1264,12 @@ class MoveContext(EditingContext):
position + self.default_span)
priority = max(self.min_priority, priority)
- position = max(self.min_position, position)
-
- self.focus.set_property ("priority", priority)
- self.focus.set_property("start", position)
+ self.focus.get_layer().set_property ("priority", priority)
+ #self.focus.set_property("start", long(position))
for obj, (s_offset, p_offset) in self.offsets.iteritems():
obj.set_property("start", position + s_offset)
- obj.set_property ("priority", priority + p_offset)
+ #obj.get_layer().set_property ("priority", priority + p_offset)
return position, priority
@@ -1315,29 +1314,29 @@ class TrimStartContext(EditingContext):
def __init__(self, timeline, focus, other):
EditingContext.__init__(self, timeline, focus, other)
- self.adjacent = timeline.edges.getObjsAdjacentToStart(focus)
- self.adjacent_originals = self._saveValues(self.adjacent)
+ #self.adjacent = timeline.edges.getObjsAdjacentToStart(focus)
+ #self.adjacent_originals = self._saveValues(self.adjacent)
self.tracks = set([])
- if isinstance(self.focus, TrackObject):
- focus_timeline_object = self.focus.timeline_object
- self.tracks.add(self.focus.track)
- else:
- focus_timeline_object = self.focus
- tracks = set(track_object.track for track_object in
- focus.track_objects)
- self.tracks.update(tracks)
+ #if isinstance(self.focus, TrackObject):
+ #focus_timeline_object = self.focus.timeline_object
+ #self.tracks.add(self.focus.track)
+ #else:
+ focus_timeline_object = self.focus
+ tracks = set(track_object.get_track() for track_object in
+ focus.get_track_objects())
+ self.tracks.update(tracks)
self.focus_timeline_object = focus_timeline_object
self.default_originals = self._saveValues([focus_timeline_object])
- ripple = self.timeline.getObjsBeforeTime(focus.start)
- assert not focus.timeline_object in ripple or focus.duration == 0
- self.ripple_originals = self._saveValues(ripple)
- self.ripple_offsets = self._getOffsets(focus.start, focus.priority,
- ripple)
- if ripple:
- self.ripple_min = focus.start - min((obj.start for obj in ripple))
- else:
- self.ripple_min = 0
+ #ripple = self.timeline.getObjsBeforeTime(focus.start)
+ #assert not focus.timeline_object in ripple or focus.duration == 0
+ #self.ripple_originals = self._saveValues(ripple)
+ #self.ripple_offsets = self._getOffsets(focus.start, focus.priority,
+ #ripple)
+ #if ripple:
+ #self.ripple_min = focus.start - min((obj.start for obj in ripple))
+ #else:
+ #self.ripple_min = 0
def _rollTo(self, position, priority):
earliest = self.focus.start - self.focus.in_point
@@ -1369,8 +1368,8 @@ class TrimStartContext(EditingContext):
self._restoreValues(self.ripple_originals)
def _defaultTo(self, position, priority):
- earliest = max(0, self.focus.start - self.focus.in_point)
- self.focus.trimStart(max(position, earliest), snap=self.snap)
+ earliest = max(0, self.focus.get_property("start") - self.focus.get_property("in_point"))
+ self.focus.set_property("in_point", (max(position, earliest)))
return position, priority
@@ -1378,6 +1377,8 @@ class TrimStartContext(EditingContext):
initial_position = self.default_originals[self.focus_timeline_object][0]
timeline_objects = [self.focus_timeline_object]
+ EditingContext.finish(self)
+ return
left_gap, right_gap = self._getGapsAtPriority(self.focus.priority,
timeline_objects, self.tracks)
@@ -1386,32 +1387,31 @@ class TrimStartContext(EditingContext):
left_gap, right_gap = Gap.findAroundObject(self.focus_timeline_object)
position = initial_position - left_gap.duration
self._defaultTo(position, self.focus.priority)
- EditingContext.finish(self)
class TrimEndContext(EditingContext):
def __init__(self, timeline, focus, other):
EditingContext.__init__(self, timeline, focus, other)
- self.adjacent = timeline.edges.getObjsAdjacentToEnd(focus)
- self.adjacent_originals = self._saveValues(self.adjacent)
+ #self.adjacent = timeline.edges.getObjsAdjacentToEnd(focus)
+ #self.adjacent_originals = self._saveValues(self.adjacent)
self.tracks = set([])
if isinstance(self.focus, TrackObject):
focus_timeline_object = self.focus.timeline_object
self.tracks.add(focus.track)
else:
focus_timeline_object = self.focus
- tracks = set(track_object.track for track_object in
- focus.track_objects)
+ tracks = set(track_object.get_track() for track_object in
+ focus.get_track_objects())
self.tracks.update(tracks)
self.focus_timeline_object = focus_timeline_object
self.default_originals = self._saveValues([focus_timeline_object])
- reference = focus.start + focus.duration
- ripple = self.timeline.getObjsAfterTime(reference)
+ reference = focus.get_property("start") + focus.get_property("duration")
+ #ripple = self.timeline.getObjsAfterTime(reference)
- self.ripple_originals = self._saveValues(ripple)
- self.ripple_offsets = self._getOffsets(reference, self.focus.priority,
- ripple)
+ #self.ripple_originals = self._saveValues(ripple)
+ #self.ripple_offsets = self._getOffsets(reference, self.focus.get_priority(),
+ #ripple)
def _rollTo(self, position, priority):
if self._snap:
@@ -1442,8 +1442,9 @@ class TrimEndContext(EditingContext):
self._restoreValues(self.ripple_originals)
def _defaultTo(self, position, priority):
- duration = max(0, position - self.focus.start)
- self.focus.setDuration(duration, snap=self.snap)
+ duration = max(0, position - self.focus.get_property("start"))
+ duration = min(duration, self.focus.max_duration)
+ self.focus.set_property("duration", duration)
return position, priority
@@ -1455,6 +1456,7 @@ class TrimEndContext(EditingContext):
absolute_initial_duration = initial_position + initial_duration
timeline_objects = [self.focus_timeline_object]
+ return
left_gap, right_gap = self._getGapsAtPriority(self.focus.priority,
timeline_objects, self.tracks)
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index e2b22b6..b8cdd42 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -243,7 +243,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
self._selecting = False
self._marquee.props.visibility = goocanvas.ITEM_INVISIBLE
if not self._got_motion_notify:
- self.timeline.setSelectionTo(set(), 0)
+ #self.timeline.setSelectionTo(set(), 0)
seeker.seek(Zoomable.pixelToNs(event.x))
else:
self._got_motion_notify = False
@@ -252,7 +252,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
mode = 1
if event.get_state() & gtk.gdk.CONTROL_MASK:
mode = 2
- self.timeline.setSelectionTo(self._objectsUnderMarquee(), mode)
+ #self.timeline.setSelectionTo(self._objectsUnderMarquee(), mode)
return True
def _objectsUnderMarquee(self):
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index 603bb61..39b109a 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -23,6 +23,7 @@ from pitivi.ui.point import Point
from pitivi.ui.prefs import PreferencesDialog
from pitivi.settings import GlobalSettings
from pitivi.stream import AudioStream, VideoStream
+import ges
LEFT_SIDE = gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE)
RIGHT_SIDE = gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE)
@@ -108,15 +109,17 @@ class TimelineController(controller.Controller):
self._view.unfocus()
def drag_start(self, item, target, event):
- if not self._view.element.selected:
- self._view.timeline.selection.setToObj(self._view.element, SELECT)
- tx = self._view.props.parent.get_transform()
+ return
+ #if not self._view.element.selected:
+ #self._view.timeline.selection.setToObj(self._view.element, SELECT)
+ #tx = self._view.props.parent.get_transform()
# store y offset for later priority calculation
- self._y_offset = tx[5]
+ #self._y_offset = tx[5]
# zero y component of mousdown coordiante
- self._mousedown = Point(self._mousedown[0], 0)
+ #self._mousedown = Point(self._mousedown[0], 0)
def drag_end(self, item, target, event):
+ print "drag ended"
self._context.finish()
self._context = None
self._view.app.action_log.commit()
@@ -124,9 +127,10 @@ class TimelineController(controller.Controller):
def set_pos(self, item, pos):
x, y = pos
position = Zoomable.pixelToNs(x + self._hadj.get_value())
- priority = int((y - self._y_offset + self._vadj.get_value()) //
- (LAYER_HEIGHT_EXPANDED + LAYER_SPACING))
- self._context.setMode(self._getMode())
+ priority = 0
+ #priority = int((y - self._y_offset + self._vadj.get_value()) //
+ #(LAYER_HEIGHT_EXPANDED + LAYER_SPACING))
+ #self._context.setMode(self._getMode())
self._context.editTo(position, priority)
def _getMode(self):
@@ -183,8 +187,8 @@ class StartHandle(TrimHandle):
def drag_start(self, item, target, event):
TimelineController.drag_start(self, item, target, event)
self._context = TrimStartContext(self._view.timeline,
- self._view.element,
- self._view.timeline.selection.getSelectedTrackObjs())
+ self._view.element.get_timeline_object(),
+ set([]))
self._view.app.action_log.begin("trim object")
@@ -199,8 +203,8 @@ class EndHandle(TrimHandle):
def drag_start(self, item, target, event):
TimelineController.drag_start(self, item, target, event)
self._context = TrimEndContext(self._view.timeline,
- self._view.element,
- self._view.timeline.selection.getSelectedTrackObjs())
+ self._view.element.get_timeline_object(),
+ set([]))
self._view.app.action_log.begin("trim object")
@@ -213,8 +217,8 @@ class TrackObject(View, goocanvas.Group, Zoomable):
def drag_start(self, item, target, event):
TimelineController.drag_start(self, item, target, event)
self._context = MoveContext(self._view.timeline,
- self._view.element,
- self._view.timeline.selection.getSelectedTrackObjs())
+ self._view.element.get_timeline_object(),
+ set([]))
self._view.app.action_log.begin("move object")
def _getMode(self):
@@ -225,7 +229,7 @@ class TrackObject(View, goocanvas.Group, Zoomable):
def click(self, pos):
timeline = self._view.timeline
element = self._view.element
- element_end = element.start + element.duration
+ element_end = element.get_property("start") + element.get_property("duration")
if self._last_event.get_state() & gtk.gdk.SHIFT_MASK:
timeline.setSelectionToObj(element, SELECT_BETWEEN)
elif self._last_event.get_state() & gtk.gdk.CONTROL_MASK:
@@ -238,7 +242,7 @@ class TrackObject(View, goocanvas.Group, Zoomable):
x, y = pos
x += self._hadj.get_value()
self._view.app.current.seeker.seek(Zoomable.pixelToNs(x))
- timeline.setSelectionToObj(element, SELECT)
+ #timeline.setSelectionToObj(element, SELECT)
def __init__(self, instance, element, track, timeline, uTrack, is_transition = False):
goocanvas.Group.__init__(self)
@@ -287,6 +291,8 @@ class TrackObject(View, goocanvas.Group, Zoomable):
self.add_child(thing)
self.element = element
+ self.element.get_timeline_object().max_duration = self.element.get_timeline_object().get_property("duration")
+ self.element.selected = False
self.settings = instance.settings
self.unfocus()
@@ -335,7 +341,6 @@ class TrackObject(View, goocanvas.Group, Zoomable):
self.end_handle.props.visibility = goocanvas.ITEM_VISIBLE
self.raise_(None)
for transition in self.uTrack.transitions:
- print "transition raised"
transition.raise_(None)
def unfocus(self):
@@ -425,18 +430,6 @@ class TrackObject(View, goocanvas.Group, Zoomable):
goocanvas.ITEM_INVISIBLE
def _update(self):
- objects = self.app.projectManager.current.timeline.get_layers()[0].get_objects()
- lastStart = 0
- for obj in objects:
- for tr_obj in obj.get_track_objects():
- if tr_obj.get_property("duration") > lastStart:
- lastStart = tr_obj.get_property("start")
- print lastStart, "connard"
-
- for layer in self.app.projectManager.current.timeline.get_layers():
- if layer.get_priority() == 99:
- layer.get_objects()[0].set_property("duration", lastStart)
-
try:
x = self.nsToPixel(self.element.get_start())
except Exception, e:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]