pitivi r1177 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1177 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Thu, 17 Jul 2008 03:54:52 +0000 (UTC)
Author: blewis
Date: Thu Jul 17 03:54:51 2008
New Revision: 1177
URL: http://svn.gnome.org/viewvc/pitivi?rev=1177&view=rev
Log:
* pitivi/ui/complextimeline.py:
cosmetic tweaks for complex timeline
* pitivi/ui/util.py:
fixed typo
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 Thu Jul 17 03:54:51 2008
@@ -25,7 +25,7 @@
import gtk
import gst
-
+import cairo
import pitivi.instance as instance
from pitivi.bin import SmartTimelineBin
@@ -37,6 +37,7 @@
import os.path
from urllib import unquote
from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
+from pitivi.utils import closest_item
VIDEO_TRACK_HEIGHT = 50
AUDIO_TRACK_HEIGHT = 20
@@ -44,24 +45,24 @@
goocanvas.Rect,
{
"height" : VIDEO_TRACK_HEIGHT,
- "fill_color_rgba" : 0x556633FF
+ "fill_color_rgba" : 0x709fb899,
+ "line_width" : 0
},
{
- "normal_color" : 0x556633FF,
- "selected_color" : 0x334411FF,
+ "normal_color" : 0x709fb899,
+ "selected_color" : 0xa6cee3FF,
}
)
-
AUDIO_SOURCE = (
goocanvas.Rect,
{
"height" : AUDIO_TRACK_HEIGHT,
- "stroke_color" : "black",
- "fill_color_rgba" : 0x556633FF
+ "fill_color_rgba" : 0x709fb899,
+ "line_width" : 0
},
{
- "normal_color" : 0x556633FF,
- "selected_color" : 0x334411FF,
+ "normal_color" : 0x709fb899,
+ "selected_color" : 0xa6cee3FF,
}
)
@@ -69,7 +70,7 @@
goocanvas.Rect,
{
"width" : 5,
- "fill_color_rgba" : 0x00000033,
+ "fill_color_rgba" : 0x00000022,
"line-width" : 0
},
{}
@@ -84,12 +85,21 @@
{}
)
+SPACER = (
+ goocanvas.Polyline,
+ {
+ "stroke_color_rgba" : 0xFFFFFFFF,
+ "line_width" : 1,
+ },
+ {}
+)
+
LABEL = (
Text,
{
"font" : "Sans 9",
"text" : "will be replaced",
- "fill_color_rgba" : 0x66AA66FF,
+ "fill_color_rgba" : 0x000000FF,
"anchor" : gtk.ANCHOR_NW
},
{}
@@ -107,6 +117,7 @@
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)
+DEADBAND = 5
class ComplexTrack(SmartGroup):
__gtype_name__ = 'ComplexTrack'
@@ -115,6 +126,7 @@
SmartGroup.__init__(self, *args, **kwargs)
self.widgets = {}
self.elements = {}
+ self._edges = []
self.sig_ids = None
self.comp = None
# more of a factor, really
@@ -124,6 +136,7 @@
self._zoom_adjustment.upper = 1000
self._zoom_adjustment.connect("value-changed", self._adjust_zoom)
self.set_zoom_ratio(10.0)
+ self._deadband = self.pixel_to_ns(DEADBAND)
self.object_style = None
self.bg = make_item(BACKGROUND)
self.add_child(self.bg)
@@ -133,6 +146,8 @@
def _adjust_zoom(self, adjustment):
self._zoom_ratio = adjustment.get_value()
+ self._deadband = self.pixel_to_ns(DEADBAND)
+ print self.ns_to_pixel(self._deadband)
self._zoom()
def set_zoom_ratio(self, ratio):
@@ -157,22 +172,26 @@
def _objectAdded(self, timeline, element):
w = ComplexTimelineObject(element, self.object_style)
- make_dragable(self.canvas, w, moved=self._move_source_cb)
+ make_dragable(self.canvas, w, start=self._start_drag,
+ 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_selectable(self.canvas, w.bg)
make_dragable(self.canvas, w.l_handle, moved=self._trim_source_start_cb,
cursor=LEFT_SIDE)
make_dragable(self.canvas, w.r_handle, moved=self._trim_source_end_cb,
cursor=RIGHT_SIDE)
+ self._update_edges()
def _objectRemoved(self, timeline, element):
w = self.widgets[element]
self.remove_child(w)
del self.widgets[element]
del self.elements[w]
+ self._update_edges()
def ns_to_pixel(self, time):
if time == gst.CLOCK_TIME_NONE:
@@ -182,13 +201,42 @@
def pixel_to_ns(self, pixel):
return long(pixel * gst.SECOND / self._zoom_ratio)
+ def _edge_snap(self, coord):
+ left_res, left_diff = closest_item(self._edges, coord)
+ right_res, right_diff = closest_item(self._edges, coord)
+
+ if left_diff <= right_diff:
+ res = left_res
+ diff = left_diff
+ else:
+ res = right_res - self._draging.duration
+ diff = right_diff
+ if diff <= self._deadband:
+ return res
+ return coord
+
def start_duration_cb(self, obj, start, duration, widget):
widget.props.width = self.ns_to_pixel(duration)
self.set_child_pos(widget, (self.ns_to_pixel(start), 0))
+ def _start_drag(self, item):
+ item.raise_(None)
+ self._draging = item
+ self._update_edges()
+
+ def _update_edges(self):
+ edges = {}
+ for element in self.widgets:
+ edges[element.start] = None
+ edges[element.start + element.duration] = None
+ self._edges = edges.keys()
+ self._edges.sort()
+ print self._edges
+
def _move_source_cb(self, item, pos):
element = item.element
- element.setStartDurationTime(max(self.pixel_to_ns(pos[0]), 0))
+ element.setStartDurationTime(max(self.pixel_to_ns(
+ pos[0]), 0))
def _trim_source_start_cb(self, item, pos):
element = item.element
@@ -235,8 +283,10 @@
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.children = [self.bg, self.name, self.l_handle, self.r_handle,
+ self.spacer]
for thing in self.children:
self.add_child(thing)
self.connect("notify::x", self.do_set_x)
@@ -259,12 +309,18 @@
ret.connect("leave-notify-event", self._set_cursor, ARROW)
return ret
+ def _size_spacer(self):
+ x = self.x + self.width
+ y = self.y + self.height
+ self.spacer.points = goocanvas.Points([(x, 0), (x, y)])
+
def do_set_x(self, *args):
x = self.x
self.bg.props.x = x
- self.name.props.x = x + 2
+ self.name.props.x = x + width(self.l_handle) + 2
self.l_handle.props.x = x
self.r_handle.props.x = x + self.width - width(self.r_handle)
+ self._size_spacer()
def do_set_y(self, *args):
y = self.y
@@ -272,10 +328,12 @@
self.name.props.y = y + 2
self.l_handle.props.y = y
self.r_handle.props.y = y
+ self._size_spacer()
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)
+ self._size_spacer()
def do_set_height(self, *args):
height = self.height
@@ -283,6 +341,7 @@
self.l_handle.props.height = height
self.r_handle.props.height = height
self.name.props.height = 2
+ self._size_spacer()
class CompositionLayers(goocanvas.Canvas, ZoomableWidgetInterface):
""" Souped-up VBox that contains the timeline's CompositionLayer """
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 Thu Jul 17 03:54:51 2008
@@ -129,8 +129,8 @@
def magnetize(obj, coord, magnets, deadband):
# remember that objects have two ends
- left_res, left_diff = closest_magnet(coord, magnets)
- right_res, right_diff = closest_magnet(coord + width(obj), magnets)
+ left_res, left_diff = closest_item(magnets, coord)
+ right_res, right_diff = closest_item(magnets, coord)
if left_diff <= right_diff:
res = left_res
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]