pitivi r1159 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1159 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Wed, 9 Jul 2008 12:54:30 +0000 (UTC)
Author: blewis
Date: Wed Jul 9 12:54:30 2008
New Revision: 1159
URL: http://svn.gnome.org/viewvc/pitivi?rev=1159&view=rev
Log:
* pitivi/ui/complextimeline.py:
clicking blank as of the timleine now activates an otherwise useless
selection marquee.
* pitivi/ui/util.py:
had to rewrite the code somewhat to take care of some pythong scoping
issues.
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 Wed Jul 9 12:54:30 2008
@@ -77,6 +77,15 @@
{}
)
+MARQUEE = (
+ goocanvas.Rect,
+ {
+ "stroke_color_rgba" : 0x33CCFF66,
+ "fill_color_rgba" : 0x33CCFF66,
+ },
+ {}
+)
+
class ComplexTrack(SmartGroup):
__gtype_name__ = 'ComplexTrack'
@@ -211,9 +220,14 @@
self.get_root_item().add_child(self.layers)
for layerinfo in self.layerInfoList:
self._layerAddedCb(layerinfo)
+ self._marquee = make_item(MARQUEE)
+ manage_selection(self, self._marquee, True, self._selection_changed_cb)
## ZoomableWidgetInterface overrides
+ def _selection_changed_cb(self, selected, deselected):
+ pass
+
def getDuration(self):
return max([layer.composition.duration for layer in
self.layerInfoList])
@@ -224,7 +238,6 @@
def zoomChanged(self):
ratio = self.getZoomRatio()
- print ratio
for layer in self.layers:
layer.set_zoom_ratio(ratio)
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 Wed Jul 9 12:54:30 2008
@@ -258,6 +258,48 @@
canvas.set_data("selected_objects", new)
canvas.get_data("selection_callback")(new, deselected)
+def objects_under_marquee(event, canvas, overlap):
+ pos, size = normalize_rect(canvas.mouse_down, event_coords(
+ canvas, event))
+ bounds = goocanvas.Bounds(*(pos + point_sum(pos, size)))
+ selected = canvas.get_items_in_area(bounds, True, overlap,
+ True)
+ if selected:
+ return set((found for found in selected if
+ found.get_data("selectable")))
+ return set()
+
+def selection_start(item, target, event, canvas, marquee):
+ root = canvas.get_root_item()
+ root.add_child(marquee)
+ cursor = event_coords(canvas, event)
+ set_pos(marquee, cursor)
+ canvas.selecting = True
+ canvas.mouse_down = cursor
+ set_pos(marquee, cursor)
+ set_size(marquee, (0, 0))
+ return True
+
+def selection_end(item, target, event, canvas, marquee, overlap, changed_cb):
+ canvas.selecting = False
+ marquee.remove()
+ prev = canvas.get_data("selected_objects")
+ selected = objects_under_marquee(event, canvas, overlap)
+ canvas.set_data("selected_objects", selected)
+ if changed_cb:
+ changed_cb(selected, prev.difference(selected))
+ return True
+
+def selection_drag(item, target, event, canvas, marquee):
+ if canvas.selecting:
+ pos_, size_ = normalize_rect(canvas.mouse_down,
+ event_coords(canvas, event))
+ set_size(marquee, size_)
+ set_pos(marquee, pos_)
+ return True
+ return False
+
+
def manage_selection(canvas, marquee, overlap, changed_cb=None):
"""Keep track of the current selection in canvas, including
* providing a rectangular selection marquee
@@ -273,55 +315,14 @@
- changed_cb: a callback with signature (selected, deselected)
"""
- def objects_under_marquee(event):
- pos, size = normalize_rect(mouse_down[0], event_coords(
- canvas, event))
- bounds = goocanvas.Bounds(*(pos + point_sum(pos, size)))
- selected = canvas.get_items_in_area(bounds, True, overlap,
- containers)
- if selected:
- return set((found for found in selected if
- found.get_data("selectable")))
- return set()
-
- def selection_start(item, target, event):
- root.add_child(marquee)
- cursor = event_coords(canvas, event)
- set_pos(marquee, cursor)
- selecting[0] = True
- mouse_down[0] = cursor
- set_pos(marquee, cursor)
- set_size(marquee, (0, 0))
- return True
-
- def selection_end(item, target, event):
- selecting[0] = False
- marquee.remove()
- prev = canvas.get_data("selected_objects")
- selected = objects_under_marquee(event)
- canvas.set_data("selected_objects", selected)
- if changed_cb:
- changed_cb(selected, prev.difference(selected))
- return True
-
- def selection_drag(item, target, event):
- if selecting[0]:
- pos_, size_ = normalize_rect(mouse_down[0],
- event_coords(canvas, event))
- set_size(marquee, size_)
- set_pos(marquee, pos_)
- return True
- return False
-
+ canvas.selecting = False
+ canvas.mouse_down = None
canvas.set_data("selected_objects", set())
canvas.set_data("selection_callback", changed_cb)
- containers = True
- selecting = [False]
- mouse_down = [None]
root = canvas.get_root_item()
- root.connect("button_press_event", selection_start)
- root.connect("button_release_event", selection_end)
- root.connect("motion_notify_event", selection_drag)
+ root.connect("button_press_event", selection_start, canvas, marquee)
+ root.connect("button_release_event", selection_end, canvas, marquee, overlap, changed_cb)
+ root.connect("motion_notify_event", selection_drag, canvas, marquee)
class Text(goocanvas.Text):
'''adds the "missing" height property to goocanvas.Text'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]