[pitivi] Use MoveContext when dragging clips from the sourcelist to the timeline. Fixes #589695.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] Use MoveContext when dragging clips from the sourcelist to the timeline. Fixes #589695.
- Date: Mon, 27 Jul 2009 14:18:35 +0000 (UTC)
commit c80658faf13a8cd97fb240c019f83dd457851f4a
Author: Alessandro Decina <alessandro d gmail com>
Date: Mon Jul 27 15:47:37 2009 +0200
Use MoveContext when dragging clips from the sourcelist to the timeline. Fixes #589695.
pitivi/timeline/timeline.py | 26 ++++++++++++++++++--------
pitivi/ui/timeline.py | 14 +++++++++-----
2 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 068e07d..ca153a5 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -25,7 +25,7 @@ from bisect import bisect_left
from pitivi.signalinterface import Signallable
from pitivi.log.loggable import Loggable
from pitivi.utils import UNKNOWN_DURATION, closest_item, PropertyChangeTracker
-from pitivi.timeline.track import SourceTrackObject, TrackError
+from pitivi.timeline.track import TrackObject, SourceTrackObject, TrackError
from pitivi.stream import match_stream_groups_map
from pitivi.utils import start_insort_right, infinity, getPreviousObject, \
getNextObject
@@ -1045,15 +1045,21 @@ class MoveContext(EditingContext):
def __init__(self, timeline, focus, other):
EditingContext.__init__(self, timeline, focus, other)
- self.timeline_objects = set(track_object.timeline_object
- for track_object in other)
- self.timeline_objects.add(focus.timeline_object)
-
min_priority = infinity
earliest = infinity
latest = 0
self.default_originals = {}
- for timeline_object in self.timeline_objects:
+ self.timeline_objects = set([])
+ all_objects = set(other)
+ all_objects.add(focus)
+ for obj in all_objects:
+ if isinstance(obj, TrackObject):
+ timeline_object = obj.timeline_object
+ else:
+ timeline_object = obj
+
+ self.timeline_objects.add(timeline_object)
+
self.default_originals[timeline_object] = \
self._getTimelineObjectValues(timeline_object)
@@ -1112,8 +1118,12 @@ class MoveContext(EditingContext):
def finish(self):
EditingContext.finish(self)
- initial_position = self.default_originals[self.focus.timeline_object][0]
- initial_priority = self.default_originals[self.focus.timeline_object][-1]
+ if isinstance(self.focus, TrackObject):
+ focus_timeline_object = self.focus.timeline_object
+ else:
+ focus_timeline_object = self.focus
+ 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
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 0f8a137..b9cbfa1 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -38,6 +38,7 @@ from timelinecontrols import TimelineControls
from pitivi.receiver import receiver, handler
from zoominterface import Zoomable
from pitivi.ui.common import LAYER_HEIGHT_EXPANDED, LAYER_SPACING
+from pitivi.timeline.timeline import MoveContext
# tooltip text for toolbar
DELETE = _("Delete Selected")
@@ -288,6 +289,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
if not self._temp_objects:
self.timeline.disableUpdates()
self._add_temp_source()
+ focus = self._temp_objects[0]
+ self._move_context = MoveContext(self.timeline,
+ focus, set(self._temp_objects[1:]))
self._move_temp_source(x, y)
return True
@@ -304,7 +308,11 @@ class Timeline(gtk.Table, Loggable, Zoomable):
def _dragDropCb(self, widget, context, x, y, timestamp):
self.app.action_log.begin("add clip")
self._add_temp_source()
+ focus = self._temp_objects[0]
+ self._move_context = MoveContext(self.timeline,
+ focus, set(self._temp_objects[1:]))
self._move_temp_source(x, y)
+ self._move_context.finish()
self.app.action_log.commit()
context.drop_finish(True, timestamp)
self._factories = None
@@ -340,11 +348,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
x, y = self._canvas.convert_from_pixels(x - offset, y)
priority = int((y // (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)))
delta = Zoomable.pixelToNs(x)
- for obj in self._temp_objects:
- obj.setStart(max(0, delta), snap=True)
- obj.priority = priority
- delta += obj.duration
-
+ self._move_context.editTo(delta, priority)
## Zooming and Scrolling
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]