pitivi r1212 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1212 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Tue, 22 Jul 2008 19:53:09 +0000 (UTC)
Author: blewis
Date: Tue Jul 22 19:53:09 2008
New Revision: 1212
URL: http://svn.gnome.org/viewvc/pitivi?rev=1212&view=rev
Log:
* pitivi/ui/complextimeline.py:
razor tool actually trims source now.
* pitivi/ui/util.py:
it is also now possible to abort a drag operation by returning True
from the drag_start callback. currently, this feature is untested.
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
branches/SOC_2008_BLEWIS/pitivi/ui/util.py
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py Tue Jul 22 19:53:09 2008
@@ -29,6 +29,7 @@
import pitivi.instance as instance
from pitivi.bin import SmartTimelineBin
+from pitivi.timeline.source import TimelineFileSource
from complexlayer import LayerInfoList
from layerwidgets import TimelineToolBar
import ruler
@@ -276,6 +277,7 @@
new_end = max(cur_start, self.canvas.snap_time_to_edit(
self.pixel_to_ns(pos[0] + width(item))))
new_duration = new_end - element.start
+
element.setStartDurationTime(gst.CLOCK_TIME_NONE, new_duration)
#FIXME: only for sources
element.setMediaStartDurationTime(gst.CLOCK_TIME_NONE, new_duration)
@@ -302,13 +304,14 @@
self.element = element
self.comp = composition
self.bg = make_item(style)
+ self.bg.element = element
+ self.bg.comp = composition
self.name = make_item(LABEL)
self.name.props.text = os.path.basename(unquote(
element.factory.name))
self.l_handle = self._make_handle(LEFT_SIDE)
self.r_handle = self._make_handle(RIGHT_SIDE)
self.spacer = make_item(SPACER)
- # for the moment, not labeling sources
self.children = [self.bg, self.name, self.l_handle, self.r_handle,
self.spacer]
for thing in self.children:
@@ -510,11 +513,59 @@
self.disconnect(self._razor_sigid)
self.disconnect(self._razor_motion_sigid)
self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
- #TODO: actually cut the source
+
+ # Find the topmost source under the mouse. This is tricky because not
+ # all objects in the timeline are ComplexTimelineObjects. Some of them
+ # are drag handles, for example. For now, only objects marked as
+ # selectable should be sources
x, y = event_coords(self, event)
- source = self.get_item_at(x, y, True)
+ items = self.get_items_at(x, y, 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, x)
return True
+ def _splitSource(self, obj, x):
+ comp = obj.comp
+ element = obj.element
+ editpoint = self.pixelToNs(x)
+
+ # 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
+
+ # 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.setStartDurationTime(a_start, a_dur)
+ element.setMediaStartDurationTime(a_media_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.setStartDurationTime(b_start, b_dur)
+ new.setMediaStartDurationTime(b_media_start, b_dur)
+ comp.addSource(new, 0, True)
+
def selectBeforeCurrent(self, unused_action):
pass
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/util.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/util.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/util.py Tue Jul 22 19:53:09 2008
@@ -178,7 +178,8 @@
canvas.pointer_grab(item, mask, cursor, event.time)
item.set_data("dragging", True)
if start_cb:
- start_cb(item)
+ if start_cb(item):
+ drag_end(item, target, event, canvas, None)
if transform:
coords = transform(event_coords(canvas, event))
else:
@@ -211,6 +212,17 @@
moved=set_pos, cursor=None):
"""Make item dragable with respect to the canvas. Call this
after make_selectable, or it will prevent the latter from working.
+
+ - canvas : the goocanvas.Canvas that contains item
+ - item : the item which will become dragable
+ - transform : callback which preforms arbitrary transformation
+ on mouse coordinates, or None
+ - start : callback to prepare object for draging, or None.
+ if start() returns True, drag will be aborted and end()
+ will not be called.
+ - end : callback to clean up after draging, or None
+ - moved : what to do with coordinates after transform() is called,
+ default is set_pos(item, coords)
"""
item.set_data("dragging", False)
dwn = item.connect("button_press_event", drag_start, canvas, start,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]