pitivi r1409 - trunk/pitivi/ui
- From: edwardrv svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1409 - trunk/pitivi/ui
- Date: Fri, 28 Nov 2008 17:36:02 +0000 (UTC)
Author: edwardrv
Date: Fri Nov 28 17:36:02 2008
New Revision: 1409
URL: http://svn.gnome.org/viewvc/pitivi?rev=1409&view=rev
Log:
re-impmemented the selection marquee...now it supports shift and control click modifieres
Modified:
trunk/pitivi/ui/timelinecanvas.py
Modified: trunk/pitivi/ui/timelinecanvas.py
==============================================================================
--- trunk/pitivi/ui/timelinecanvas.py (original)
+++ trunk/pitivi/ui/timelinecanvas.py Fri Nov 28 17:36:02 2008
@@ -42,53 +42,113 @@
def _createUI(self):
self._cursor = ARROW
root = self.get_root_item()
-
self.tracks = goocanvas.Group()
root.add_child(self.tracks)
-
- root.connect("enter_notify_event", self._mouseEnterCb)
- self._marquee = goocanvas.Rect(
+ self.__marquee = goocanvas.Rect(
+ stroke_color_rgba=0x33CCFF66,
+ fill_color_rgba=0x33CCFF66,
+ visibility = goocanvas.ITEM_INVISIBLE)
+ self.__razor = goocanvas.Rect(
line_width=0,
fill_color="orange",
- width=1)
+ width=0,
+ visibility=goocanvas.ITEM_INVISIBLE)
+ root.add_child(self.__marquee)
+ root.add_child(self.__razor)
+ root.connect("motion-notify-event", self.__selectionDrag)
+ root.connect("button-press-event", self.__selectionStart)
+ root.connect("button-release-event", self.__selectionEnd)
- self._razor = goocanvas.Rect(
- stroke_color_rgba=0x33CCFF66,
- fill_color_rgba=0x33CCFF66)
- self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
- root.add_child(self._razor)
+ def from_event(self, event):
+ return Point(*self.convert_from_pixels(event.x, event.y))
-## mouse callbacks
+## sets the cursor as appropriate
def _mouseEnterCb(self, unused_item, unused_target, event):
event.window.set_cursor(self._cursor)
return True
+## implements selection marquee
+
+ __selecting = False
+
+ def __normalize(self, p1, p2):
+ w, h = p2 - p1
+ x, y = p1
+ if w < 0:
+ w = abs(w)
+ x -= w
+ if h < 0:
+ h = abs(h)
+ y -= h
+ return (x, y), (w, h)
+
+
+ def __selectionDrag(self, item, target, event):
+ if self.__selecting:
+ cur = self.from_event(event)
+ pos, size = self.__normalize(self.__mousedown, cur)
+ m = self.__marquee
+ m.props.x, m.props.y = pos
+ m.props.width, m.props.height = size
+ return True
+ return False
+
+ def __selectionStart(self, item, target, event):
+ self.__selecting = True
+ self.__marquee.props.visibility = goocanvas.ITEM_VISIBLE
+ self.__mousedown = self.from_event(event)
+ self.__marquee.props.width = 0
+ self.__marquee.props.height = 0
+ self.pointer_grab(self.get_root_item(), gtk.gdk.POINTER_MOTION_MASK |
+ gtk.gdk.BUTTON_RELEASE_MASK, self._cursor, event.time)
+ return True
+
+ def __selectionEnd(self, item, target, event):
+ self.pointer_ungrab(self.get_root_item(), event.time)
+ self.__selecting = False
+ self.__marquee.props.visibility = goocanvas.ITEM_INVISIBLE
+ mode = 0
+ if event.get_state() & gtk.gdk.SHIFT_MASK:
+ mode = 1
+ if event.get_state() & gtk.gdk.CONTROL_MASK:
+ mode = 2
+ self.timeline.setSelectionTo(self.__objectsUnderMarquee(), mode)
+ return True
+
+ def __objectsUnderMarquee(self):
+ items = self.get_items_in_area(self.__marquee.get_bounds(), True, True,
+ True)
+ if items:
+ return set((item.element for item in items if isinstance(item,
+ TimelineObject)))
+ return set()
+
## Razor Tool Implementation
def activateRazor(self, unused_action):
self._cursor = RAZOR_CURSOR
- self._razor_sigid = self.connect("button_press_event",
- self._razorClickedCb)
- self._razor_release_sigid = self.connect("button_release_event",
- self._razorReleasedCb)
- self._razor_motion_sigid = self.connect("motion_notify_event",
- self._razorMovedCb)
- self._razor.props.visibility = goocanvas.ITEM_VISIBLE
+ self.__razor_sigid = self.connect("button_press_event",
+ self.__razorClickedCb)
+ self.__razor_release_sigid = self.connect("button_release_event",
+ self.__razorReleasedCb)
+ self.__razor_motion_sigid = self.connect("motion_notify_event",
+ self.__razorMovedCb)
+ self.__razor.props.visibility = goocanvas.ITEM_VISIBLE
return True
def _razorMovedCb(self, canvas, event):
x, y = self.convert_from_pixels(event.x, event.y)
- self._razor.props.x = self.nsToPixel(self.pixelToNs(x))
+ self.__razor.props.x = self.nsToPixel(self.pixelToNs(x))
return True
def _razorReleasedCb(self, unused_canvas, event):
self._cursor = ARROW
event.window.set_cursor(ARROW)
- self.disconnect(self._razor_sigid)
- self.disconnect(self._razor_motion_sigid)
- self.disconnect(self._razor_release_sigid)
- self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.disconnect(self.__razor_sigid)
+ self.disconnect(self.__razor_motion_sigid)
+ self.disconnect(self.__razor_release_sigid)
+ self.__razor.props.visibility = goocanvas.ITEM_INVISIBLE
x, y = self.convert_from_pixels(event.x, event.y)
bounds = goocanvas.Bounds(x, y, x, y)
@@ -127,11 +187,11 @@
w, h = br - tl
if (w > pw) or (h > ph):
self.set_bounds(0, 0, w + 200, h)
- self._razor.props.height = h
+ self.__razor.props.height = h
@handler(timeline, "track-added")
- def _trackAdded(self, unused_timeline, comp, position):
- track = Track(comp=comp)
+ def _trackAdded(self, timeline, comp, position):
+ track = Track(comp, self.timeline)
self.__tracks.append(track)
track.set_canvas(self)
self.tracks.add_child(track)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]