pitivi r1170 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1170 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Tue, 15 Jul 2008 08:56:03 +0000 (UTC)
Author: blewis
Date: Tue Jul 15 08:56:03 2008
New Revision: 1170
URL: http://svn.gnome.org/viewvc/pitivi?rev=1170&view=rev
Log:
reviewed by: <delete if not using a buddy>
* pitivi/ui/complextimeline.py:
complex source widgets now have visible drag handles, and the name is set
properly. some code to support resizing in the timeline exists, but it is
buggy an slow, and therefore not used in this commit.
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.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 15 08:56:03 2008
@@ -34,6 +34,8 @@
from complexinterface import ZoomableWidgetInterface
import goocanvas
from util import *
+import os.path
+from urllib import unquote
from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
VIDEO_TRACK_HEIGHT = 50
@@ -63,6 +65,16 @@
}
)
+DRAG_HANDLE = (
+ goocanvas.Rect,
+ {
+ "width" : 5,
+ "fill_color_rgba" : 0x00000033,
+ "line-width" : 0
+ },
+ {}
+)
+
BACKGROUND = (
goocanvas.Rect,
{
@@ -78,7 +90,7 @@
"font" : "Sans 9",
"text" : "will be replaced",
"fill_color_rgba" : 0x66AA66FF,
- "anchor" : gtk.ANCHOR_CENTER
+ "anchor" : gtk.ANCHOR_NW
},
{}
)
@@ -92,6 +104,10 @@
{}
)
+LEFT_SIDE = gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE)
+RIGHT_SIDE = gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE)
+ARROW = gtk.gdk.Cursor(gtk.gdk.ARROW)
+
class ComplexTrack(SmartGroup):
__gtype_name__ = 'ComplexTrack'
@@ -139,12 +155,16 @@
self.object_style = AUDIO_SOURCE
self.bg.props.height = AUDIO_TRACK_HEIGHT
-
def _objectAdded(self, timeline, element):
- w = self.make_element_widget(element)
+ w = ComplexTimelineObject(element, self.object_style)
+ make_dragable(self.canvas, w, moved=self._move_source_cb)
+ element.connect("start-duration-changed", self.start_duration_cb, w)
self.widgets[element] = w
self.elements[w] = element
+ self.start_duration_cb(element, element.start, element.duration, w)
self.add_child(w, (0, 0))
+ #make_dragable(self.canvas, w.l_handle, moved=self._trim_source_start_cb)
+ #make_dragable(self.canvas, w.r_handle, moved=self._trim_source_end_cb)
def _objectRemoved(self, timeline, element):
w = self.widgets[element]
@@ -164,10 +184,28 @@
widget.props.width = self.ns_to_pixel(duration)
self.set_child_pos(widget, (self.ns_to_pixel(start), 0))
- def _drag_cb(self, item, pos):
- x, y = pos
- element = self.elements[item]
- element.setStartDurationTime(max(self.pixel_to_ns(x), 0), -1)
+ def _move_source_cb(self, item, pos):
+ element = item.element
+ element.setStartDurationTime(max(self.pixel_to_ns(pos[0]), 0))
+
+ def _trim_source_start_cb(self, item, pos):
+ element = item.element
+ cur_end = element.start + element.duration
+ new_start = min(cur_end, max(0, self.pixel_to_ns(pos[0])))
+ new_duration = cur_end - new_start
+ new_media_start = element.media_start + (new_start - element.media_start)
+ element.setStartDurationTime(new_start, new_duration)
+ #FIXME: only for sources
+ element.setMediaStartDurationTime(new_media_start, new_duration)
+
+ def _trim_source_end_cb(self, item, pos):
+ element = item.element
+ cur_start = element.start
+ new_end = max(cur_start, self.pixel_to_ns(pos[0]))
+ new_duration = new_end - element.start
+ element.setStartDurationTime(-1, new_duration)
+ #FIXME: only for sources
+ element.setMediaStartDurationTime(-1, new_duration)
def _zoom(self):
"""Force resize if zoom ratio changes"""
@@ -177,18 +215,73 @@
duration = element.duration
self.start_duration_cb(self, start, duration, child)
- def make_element_widget(self, element):
- rect = make_item(self.object_style)
- rect.props.width = self.ns_to_pixel(element.duration)
+class ComplexTimelineObject(goocanvas.Group):
+
+ __gtype_name__ = 'ComplexTimelineObject'
+
+ x = gobject.property(type=float)
+ y = gobject.property(type=float)
+ height = gobject.property(type=float)
+ width = gobject.property(type=float)
+
+ def __init__(self, element, style):
+ goocanvas.Group.__init__(self)
+ self.element = element
+ self.bg = make_item(style)
+ 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)
# for the moment, not labeling sources
- ret = rect
- make_selectable(self.canvas, ret)
- # must be called after make_selectable
- make_dragable(self.canvas, ret, moved=self._drag_cb)
- element.connect("start-duration-changed", self.start_duration_cb, ret)
- ret.props.x = self.ns_to_pixel(element.start)
+ self.children = [self.bg, self.name, self.l_handle, self.r_handle]
+ for thing in self.children:
+ self.add_child(thing)
+ self.connect("notify::x", self.do_set_x)
+ self.connect("notify::y", self.do_set_y)
+ self.connect("notify::width", self.do_set_width)
+ self.connect("notify::height", self.do_set_height)
+ self.width = self.bg.props.width
+ self.height = self.bg.props.height
+
+ def _set_cursor(self, item, target, event, cursor):
+ window = event.window
+ # wtf ? no get_cursor?
+ #self._oldcursor = window.get_cursor()
+ window.set_cursor(cursor)
+
+ def _make_handle(self, cursor):
+ ret = make_item(DRAG_HANDLE)
+ ret.element = self.element
+ ret.connect("enter-notify-event", self._set_cursor, cursor)
+ ret.connect("leave-notify-event", self._set_cursor, ARROW)
return ret
+ def do_set_x(self, *args):
+ x = self.x
+ self.bg.props.x = x
+ self.name.props.x = x + 2
+ self.l_handle.props.x = x
+ self.r_handle.props.x = x + self.width - width(self.r_handle)
+
+ def do_set_y(self, *args):
+ y = self.y
+ self.bg.props.y = y
+ self.name.props.y = y + 2
+ self.l_handle.props.y = y
+ self.r_handle.props.y = y
+
+ def do_set_width(self, *args):
+ self.bg.props.width = self.width
+ self.r_handle.props.x = self.x + self.width - width(self.r_handle)
+
+ def do_set_height(self, *args):
+ height = self.height
+ self.bg.props.height = height
+ self.l_handle.props.height = height
+ self.r_handle.props.height = height
+ self.name.props.height = 2
+
class CompositionLayers(goocanvas.Canvas, ZoomableWidgetInterface):
""" Souped-up VBox that contains the timeline's CompositionLayer """
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]