[pitivi] Moving an effect on a TimelineObject doesn't actually adds the effect to it. And enhance the way we
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Moving an effect on a TimelineObject doesn't actually adds the effect to it. And enhance the way we
- Date: Wed, 22 Sep 2010 13:43:42 +0000 (UTC)
commit 47fe13bcab87b97bb6d335901e802b57d1f5d504
Author: Thibault Saunier <tsaunier gnome org>
Date: Tue Jul 27 17:33:30 2010 +0200
Moving an effect on a TimelineObject doesn't actually adds the effect to it. And enhance the way we fin on which TimelineObject to add effects
TimelineObject
pitivi/ui/timeline.py | 53 ++++++++++--------------------------------
pitivi/ui/timelinecanvas.py | 8 ++++++
2 files changed, 21 insertions(+), 40 deletions(-)
---
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 2670930..b42ebbf 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -215,7 +215,6 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.ui_manager = ui_manager
self.app = instance
self._temp_objects = None
- self._temp_effect = None
self._factories = None
self._finish_drag = False
self._position = 0
@@ -412,11 +411,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
## Drag and Drop callbacks
def _dragMotionCb(self, unused, context, x, y, timestamp):
- self.warning("self._factories:%r, self._temp_objects:%r, \
- self._temp_effect %r",
+ self.warning("self._factories:%r, self._temp_objects:%r",
not not self._factories,
- not not self._temp_objects,
- not not self._temp_effect)
+ not not self._temp_objects)
if self._factories is None:
if context.targets in DND_EFFECT_LIST:
@@ -427,21 +424,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.drag_get_data(context, atom, timestamp)
self.drag_highlight()
else:
- if context.targets in DND_EFFECT_LIST:
-
- priority = self._getPriority(y, context.targets)
-
- if self._temp_effect:
- #We change the TimelineObject to add the effect to when needed
- tmp_timeline_objs = [obj[0] for obj in self._temp_effect]
- if self.timeline.getObjsToAddEffectTo(self.pixelToNs(x), priority) != tmp_timeline_objs:
- for timeline_obj, track_obj in self._temp_effect:
- timeline_obj.removeTrackObject(track_obj)
- track_obj.track.removeTrackObject(track_obj)
- self._addEffect(x, y, context.targets)
- else:
- self._addEffect(x, y, context.targets)
- else:
+ if context.targets not in DND_EFFECT_LIST:
if not self._temp_objects:
self.timeline.disableUpdates()
self._add_temp_source()
@@ -451,29 +434,13 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self._move_temp_source(self.hadj.props.value + x, y)
return True
- def _getPriority(self, y, effectTuple):
- #TODO find a way to get the good priority for audio effects
- if effectTuple == VIDEO_EFFECT_LIST:
- priority = y // (LAYER_HEIGHT_EXPANDED + TRACK_SPACING + LAYER_SPACING)
- else:
- priority = y // (LAYER_HEIGHT_EXPANDED + TRACK_SPACING + LAYER_SPACING)
-
- return priority
-
- def _dragLeaveCb(self, unused_layout, unused_context, unused_tstamp):
+ def _dragLeaveCb(self, unused_layout, context, unused_tstamp):
if self._temp_objects:
try:
for obj in self._temp_objects:
self.timeline.removeTimelineObject(obj, deep=True)
finally:
self._temp_objects = None
- elif self._temp_effect:
- try:
- for timeline_obj, track_obj in self._temp_effect:
- timeline_obj.removeTrackObject(track_obj)
- track_obj.track.removeTrackObject(track_obj)
- finally:
- self._temp_effect = None
self.drag_unhighlight()
self.timeline.enableUpdates()
@@ -502,7 +469,6 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self._addEffect(x, y, context.targets)
self.app.action_log.commit()
self._factories = None
- self._temp_effect = None
self.app.current.seeker.seek(self._position) #FIXME
context.drop_finish(True, timestamp)
@@ -536,9 +502,16 @@ class Timeline(gtk.Table, Loggable, Zoomable):
return True
def _addEffect(self, x, y, effectTuple):
- priority = self._getPriority(y, effectTuple)
+ timeline_objs = []
factory = self._factories[0]
- self._temp_effect = self.timeline.addEffectFactoryOnObject(factory, self.pixelToNs(x), priority)
+ track_objects = [obj for obj in self._canvas.getItemsInArea(x,y, x+1, y+1)]
+ for track_object in track_objects:
+ for timeline_obj in self.timeline.timeline_objects:
+ if track_objects in timeline_obj.track_objects:
+ timeline_objs = timeline_obj
+
+ self.timeline.addEffectFactoryOnObject(factory,
+ timeline_objects = timeline_objs)
def _add_temp_source(self):
self._temp_objects = [self.timeline.addSourceFactory(factory)
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index 31f3595..8678a78 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -201,6 +201,14 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
_marquee = None
_got_motion_notify = False
+ def getItemsInArea(self, x1, y1, x2, y2):
+ items = self.get_items_in_area(goocanvas.Bounds(x1, y1, x2, y2), True, True,
+ True)
+ if items:
+ return set((item.element for item in items if isinstance(item,
+ TrackObject)))
+ return set()
+
def _normalize(self, p1, p2):
w, h = p2 - p1
x, y = p1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]