pitivi r1207 - in branches/SOC_2008_BLEWIS: . pitivi/ui



Author: blewis
Date: Mon Jul 21 03:37:16 2008
New Revision: 1207
URL: http://svn.gnome.org/viewvc/pitivi?rev=1207&view=rev

Log:
* pitivi/ui/complextimeline.py:
started working on the razor tool. doesn't actually cut sources yet,
but clicking on the toolbar icon will make the line appear, and set
the cursor. clicking on the timeline disables the tool.


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	Mon Jul 21 03:37:16 2008
@@ -92,6 +92,16 @@
     {}
 )
 
+RAZOR_LINE = (
+    goocanvas.Rect,
+    {
+        "line_width" : 0,
+        "fill_color" : "orange",
+        "width" : 1,
+    },
+    {}
+)
+
 SPACER = (
     goocanvas.Polyline,
     {
@@ -126,6 +136,8 @@
 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)
+# TODO: replace this with custom cursor
+RAZOR_CURSOR = gtk.gdk.Cursor(gtk.gdk.XTERM)
 
 # default number of pixels to use for edge snaping
 DEADBAND = 5
@@ -311,12 +323,13 @@
         # wtf ? no get_cursor?
         #self._oldcursor = window.get_cursor()
         window.set_cursor(cursor)
+        return True
 
     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)
+        #ret.connect("leave-notify-event", self._set_cursor, ARROW)
         return ret
 
     def _size_spacer(self):
@@ -372,22 +385,32 @@
         self.connect("size_allocate", self._size_allocate)
        
     def _createUI(self):
+        self._cursor = ARROW
         self.set_border_width(2)
+
         self.layers = VList(canvas=self)
         self.layers.connect("notify::width", self._request_size)
         self.layers.connect("notify::height", self._request_size)
         set_pos(self.layers, (3.5, 0))
-        self.get_root_item().add_child(self.layers)
+
+        root = self.get_root_item()
+        root.add_child(self.layers)
+
+        root.connect("enter_notify_event", self._mouseEnterCb)
         self._marquee = make_item(MARQUEE)
         manage_selection(self, self._marquee, True, self._selection_changed_cb)
 
+        self._razor = make_item(RAZOR_LINE)
+        self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
+        root.add_child(self._razor)
+
 ## methods for dealing with updating the canvas size
 
     def block_size_request(self, status):
         self._block_size_request = status
 
     def _size_allocate(self, unused_layout, allocation):
-        width = max(allocation.width, self.layers.width)
+        self._razor.props.height = allocation.height
 
     def _request_size(self, unused_item, prop):
         #TODO: figure out why this doesn't work... (wtf?!?)
@@ -450,14 +473,46 @@
             return res
         return time
 
+## mouse callbacks
+
+    def _mouseEnterCb(self, item, target, event):
+        event.window.set_cursor(self._cursor)
+        return True
+
 ## Editing Operations
 
     def deleteSelected(self, unused_action):
         for obj in self._selected_sources:
-            obj.comp.removeSource(obj.element, False, False)
+            obj.comp.removeSource(obj.element, remove_linked=False, 
+                collapse_neighbours=False)
+        return True
 
     def activateRazor(self, unused_action):
-        pass
+        self._cursor = RAZOR_CURSOR
+        # we don't want mouse events passing through to the canvas items
+        # underneath, so we connect to the canvas's signals
+        self._razor_sigid = self.connect("button_press_event", 
+            self._razorClickedCb)
+        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 = event_coords(self, event)
+        self._razor.props.x = x
+        return True
+
+    def _razorClickedCb(self, canvas, event):
+        self._cursor = ARROW
+        event.window.set_cursor(ARROW)
+        self.disconnect(self._razor_sigid)
+        self.disconnect(self._razor_motion_sigid)
+        self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
+        #TODO: actually cut the source
+        x, y = event_coords(self, event)
+        source = self.get_item_at(x, y, True)
+        return True
 
     def selectBeforeCurrent(self, unused_action):
         pass
@@ -593,11 +648,11 @@
                 self.compositionLayers.selectBeforeCurrent),
             ("SelectAfter", gtk.STOCK_GOTO_LAST, None, None, SELECT_AFTER,
                 self.compositionLayers.selectAfterCurrent),
+            ("Razor", gtk.STOCK_CUT, None, None, RAZOR,
+                self.compositionLayers.activateRazor)
         )
         self.actiongroup = gtk.ActionGroup("complextimeline")
         self.actiongroup.add_actions(actions)
-        self.actiongroup.add_toggle_actions((("Razor", gtk.STOCK_CUT, None, None,
-            RAZOR, self.compositionLayers.activateRazor),))
         self.actiongroup.set_visible(False)
         instance.PiTiVi.uimanager.insert_action_group(self.actiongroup, 0)
         instance.PiTiVi.uimanager.add_ui_from_string(ui)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]