pitivi r1407 - in trunk/pitivi: timeline ui
- From: edwardrv svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1407 - in trunk/pitivi: timeline ui
- Date: Fri, 28 Nov 2008 17:35:53 +0000 (UTC)
Author: edwardrv
Date: Fri Nov 28 17:35:53 2008
New Revision: 1407
URL: http://svn.gnome.org/viewvc/pitivi?rev=1407&view=rev
Log:
moved splitting of sources into core
Modified:
trunk/pitivi/timeline/timeline.py
trunk/pitivi/ui/timelinecanvas.py
Modified: trunk/pitivi/timeline/timeline.py
==============================================================================
--- trunk/pitivi/timeline/timeline.py (original)
+++ trunk/pitivi/timeline/timeline.py Fri Nov 28 17:35:53 2008
@@ -114,7 +114,7 @@
self.emit("track-added", self.audiocomp)
- def addFactory(self, factory, time=gst.CLOCK_TIME_NONE, shift=False):
+ def addFactory(self, factory):
"""Add a factory to the timeline using the the specified time as the
start time. If shift is true, then move overlapping sources out of the
way."""
@@ -122,20 +122,56 @@
if not factory:
return
+ comp = None
#FIXME: need simple, generic, createFromFactory() type thing so we
# have to care about all of this...
if factory.is_video:
- video_source = TimelineFileSource(factory=factory,
+ source = TimelineFileSource(factory=factory,
media_type=MEDIA_TYPE_VIDEO,
name=factory.name)
- self.videocomp.appendSource(video_source)
+ comp = self.videocomp
# must be elif because of auto-linking, this just catches case where
# factory is only audio
elif factory.is_audio:
audio_source = TimelineFileSource(factory=factory,
media_type=MEDIA_TYPE_VIDEO,
name=factory.name)
- self.audiocomp.appendSource(audio_source)
+ comp = self.audiocomp
+ comp.appendSource(source)
+ return source
+
+ def splitObject(self, obj, editpoint):
+ # we want to divide obj in to objects A and B at edit point.
+ # [obj | ]
+ # [A ][B ]
+ # Sanity check:
+ start = obj.start
+ end = obj.start + obj.duration
+ assert (start < editpoint) and (editpoint < end)
+
+ # add source b
+ # FIXME: replace this with some kind of copyObject or cloneObject
+ # command
+ new = self.addFactory(obj.factory)
+ new.setStartDurationTime(obj.start, obj.duration)
+ new.setMediaStartDurationTime(obj.media_start, obj.media_duration)
+
+ # trim source b
+ new.setInTime(editpoint)
+ # trim source a
+ obj.setOutTime(editpoint)
+
+ def _selection_changed_cb(self, selected, deselected):
+ # TODO: filter this list for things other than sources, and put them
+ # into appropriate lists
+ for item in selected:
+ item.props.fill_color_rgba = item.get_data("selected_color")
+ parent = item.get_parent()
+ self._selected_sources.append(parent)
+ for item in deselected:
+ item.props.fill_color_rgba = item.get_data("normal_color")
+ parent = item.get_parent()
+ self._selected_sources.remove(parent)
def _newAudioPadCb(self, unused_audiocomp, pad):
asrc = gst.GhostPad("asrc", pad)
Modified: trunk/pitivi/ui/timelinecanvas.py
==============================================================================
--- trunk/pitivi/ui/timelinecanvas.py (original)
+++ trunk/pitivi/ui/timelinecanvas.py Fri Nov 28 17:35:53 2008
@@ -1,4 +1,7 @@
from track import Track
+from timelineobject import TimelineObject
+import controller
+import view
from point import Point
import goocanvas
from zoominterface import Zoomable
@@ -48,7 +51,6 @@
line_width=0,
fill_color="orange",
width=1)
- #manage_selection(self, self._marquee, True, self._selection_changed_cb)
self._razor = goocanvas.Rect(
stroke_color_rgba=0x33CCFF66,
@@ -62,106 +64,43 @@
event.window.set_cursor(self._cursor)
return True
-## Editing Operations
-
- # FIXME: the razor is the one toolbar tool that violates the noun-verb
- # principle. Do I really want to make an exception for this? What about
- # just double-clicking on the source like jokosher?
+## Razor Tool Implementation
def activateRazor(self, unused_action):
self._cursor = RAZOR_CURSOR
- # we don't want mouse events passing through to the canvas items
- # underneath, so we connect to the canvas's signals
self._razor_sigid = self.connect("button_press_event",
self._razorClickedCb)
+ self._razor_release_sigid = self.connect("button_release_event",
+ self._razorReleasedCb)
self._razor_motion_sigid = self.connect("motion_notify_event",
self._razorMovedCb)
self._razor.props.visibility = goocanvas.ITEM_VISIBLE
return True
def _razorMovedCb(self, canvas, event):
- x, y = event_coords(self, event)
+ x, y = self.convert_from_pixels(event.x, event.y)
self._razor.props.x = self.nsToPixel(self.pixelToNs(x))
return True
- def _razorClickedCb(self, unused_canvas, event):
+ def _razorReleasedCb(self, unused_canvas, event):
self._cursor = ARROW
event.window.set_cursor(ARROW)
self.disconnect(self._razor_sigid)
self.disconnect(self._razor_motion_sigid)
+ self.disconnect(self._razor_release_sigid)
self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
- # Find the topmost source under the mouse. This is tricky because not
- # all objects in the timeline are TimelineObjects. Some of them
- # are drag handles, for example. For now, only objects marked as
- # selectable should be sources
- x, y = event_coords(self, event)
- items = self.get_items_at(x, y, True)
- if not items:
- return True
- for item in items:
- if item.get_data("selectable"):
- parent = item.get_parent()
- gst.log("attempting to split source at position %d" % x)
- self._splitSource(parent, self.pixelToNs(x))
+ x, y = self.convert_from_pixels(event.x, event.y)
+ bounds = goocanvas.Bounds(x, y, x, y)
+ items = self.get_items_in_area(bounds, True, True, True)
+ if items:
+ for item in items:
+ if isinstance(item, TimelineObject):
+ self.timeline.splitObject(item.element, self.pixelToNs(x))
return True
- # FIXME: this DEFINITELY needs to be in the core. Also, do we always want
- # to split linked sources? Should the user be forced to un-link linked
- # sources when they only wisth to split one of them? If not,
-
- def _splitSource(self, obj, editpoint):
- comp = obj.comp
- element = obj.element
-
- # we want to divide element in elementA, elementB at the
- # edit point.
- a_start = element.start
- a_end = editpoint
- b_start = editpoint
- b_end = element.start + element.duration
-
- # so far so good, but we need this expressed in the form
- # start/duration.
- a_dur = a_end - a_start
- b_dur = b_end - b_start
- if not (a_dur and b_dur):
- gst.Log("cannot cut at existing edit point, aborting")
- return
-
- # and finally, we need the media-start/duration for both sources.
- # in this case, media-start = media-duration, but this would not be
- # true if timestretch were applied to either source. this is why I
- # really think we should not have to care about media-start /duratoin
- # here, and have a more abstract method for setting time stretch that
- # would keep media start/duration in sync for sources that have it.
- a_media_start = element.media_start
- b_media_start = a_media_start + a_dur
-
- # trim source a
- element.setMediaStartDurationTime(a_media_start, a_dur)
- element.setStartDurationTime(a_start, a_dur)
-
- # add source b
- # TODO: for linked sources, split linked and create brother
- # TODO: handle other kinds of sources
- new = TimelineFileSource(factory=element.factory,
- media_type=comp.media_type)
- new.setMediaStartDurationTime(b_media_start, b_dur)
- new.setStartDurationTime(b_start, b_dur)
- comp.addSource(new, 0, True)
-
- def _selection_changed_cb(self, selected, deselected):
- # TODO: filter this list for things other than sources, and put them
- # into appropriate lists
- for item in selected:
- item.props.fill_color_rgba = item.get_data("selected_color")
- parent = item.get_parent()
- self._selected_sources.append(parent)
- for item in deselected:
- item.props.fill_color_rgba = item.get_data("normal_color")
- parent = item.get_parent()
- self._selected_sources.remove(parent)
+ def _razorClickedCb(self, unused_canvas, unused_event):
+ return True
## Zoomable Override
@@ -188,6 +127,7 @@
w, h = br - tl
if (w > pw) or (h > ph):
self.set_bounds(0, 0, w + 200, h)
+ self._razor.props.height = h
@handler(timeline, "track-added")
def _trackAdded(self, unused_timeline, comp, position):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]