pitivi r1145 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1145 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Sun, 22 Jun 2008 15:42:25 +0000 (UTC)
Author: blewis
Date: Sun Jun 22 15:42:25 2008
New Revision: 1145
URL: http://svn.gnome.org/viewvc/pitivi?rev=1145&view=rev
Log:
reviewed by: <delete if not using a buddy>
* pitivi/ui/testcomplex.py:
make_timeline_object now calls make_dragable with new "moved" callback
parameter. Fixe bug which prevented objects from being moved to the left
of their initial position.
* pitivi/ui/util.py:
made make_dragable function a bit more MVC-friendly, by adding additional
"moved" callback parameter in addition to "transform". Defaults to
set_pos, so older code should still work.
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
branches/SOC_2008_BLEWIS/pitivi/ui/util.py
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py Sun Jun 22 15:42:25 2008
@@ -149,39 +149,32 @@
widget.props.width = duration
self.set_child_pos(widget, (start, 0))
- def _child_mouse_down(self, item, target, event):
- item.raise_(None)
-
- def _child_mouse_up(self, item, target, event):
- pass
-
- def drag_cb(self, item, target, event, element):
- if item.get_data("dragging"):
- x,y = point_sum(item.get_data("pendown"), event_coords(self.canvas,
- event))
- element.setStartDurationTime(max(x, 0), -1)
- return True
- return False
+ def _drag_cb(self, item, pos):
+ x, y = pos
+ pos_label.props.text = "(%g, %g)" % pos
+ element = item.get_data("element")
+ element.setStartDurationTime(max(x, 0), -1)
def make_element_widget(self, element):
text = make_item(label)
text.props.text = os.path.basename(element.factory.name)
rect = make_item(box)
rect.props.width = element.props.duration
- rect.props.x = element.props.start
set_pos(text, center(rect))
ret = group(rect, text)
+ ret.set_data("element", element)
+ make_dragable(self.canvas, ret, moved=self._drag_cb)
element.connect("start-duration-changed", self.start_duration_cb, ret)
- ret.connect("button-press-event", drag_start, self.canvas, None, None)
- ret.connect("button-release-event", drag_end, None)
- ret.connect("motion-notify-event", self.drag_cb, element)
+ ret.props.x = element.props.start
return ret
c = goocanvas.Canvas()
t = ComplexTrack(c)
model = TestComposition()
t.set_composition(model)
+pos_label = goocanvas.Text(x=0, y=0, anchor=gtk.ANCHOR_NW)
c.get_root_item().add_child(t)
+c.get_root_item().add_child(pos_label)
cur = 0
for name, duration in SOURCES:
model.addSource(TestTimelineObject(name, cur, duration), None)
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 Sun Jun 22 15:42:25 2008
@@ -167,28 +167,30 @@
end_cb(item)
return True
-def translate_item_group(item, target, event, canvas, transform):
+def drag_move(item, target, event, canvas, transform, move_cb):
"""A callback which handles updating the position during a drag
operation"""
if item.get_data("dragging"):
pos = point_sum(item.get_data("pendown"),
event_coords(canvas, event))
if transform:
- set_pos(item, transform(pos))
+ move_cb(item, transform(pos))
return True
- set_pos(item, pos)
+ move_cb(item, pos)
return True
return False
-def make_dragable(canvas, item, transform=None, start=None, end=None):
+def make_dragable(canvas, item, transform=None, start=None, end=None,
+ moved=set_pos):
"""Make item dragable with respect to the canvas. Call this
after make_selectable, or it will prevent the latter from working.
"""
item.set_data("dragging", False)
- dwn = item.connect("button_press_event", drag_start, canvas, start, transform)
- up = item.connect("button_release_event", drag_end, end)
- mv = item.connect("motion_notify_event", translate_item_group, canvas,
+ dwn = item.connect("button_press_event", drag_start, canvas, start,
transform)
+ up = item.connect("button_release_event", drag_end, end)
+ mv = item.connect("motion_notify_event", drag_move, canvas, transform,
+ moved)
item.set_data("drag_sigids", (up, dwn, mv))
def unmake_dragable(item):
@@ -197,7 +199,8 @@
for sig in signals:
item.disconnect(sig)
-def make_resizable(horizontal, vertical, canvas, item):
+def make_resizable(canvas, item, transform=None, start=None, stop=None,
+ moved=None):
pass
def unmake_resizable(item):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]