pitivi r1395 - in trunk/pitivi: timeline ui



Author: edwardrv
Date: Fri Nov 28 17:35:00 2008
New Revision: 1395
URL: http://svn.gnome.org/viewvc/pitivi?rev=1395&view=rev

Log:
moved selection code to core (timeline/timeline.py), TimelineController now selects objects on click

Modified:
   trunk/pitivi/timeline/objects.py
   trunk/pitivi/timeline/timeline.py
   trunk/pitivi/ui/timelinecanvas.py
   trunk/pitivi/ui/timelineobject.py

Modified: trunk/pitivi/timeline/objects.py
==============================================================================
--- trunk/pitivi/timeline/objects.py	(original)
+++ trunk/pitivi/timeline/objects.py	Fri Nov 28 17:35:00 2008
@@ -340,7 +340,8 @@
     __requires_factory__ = True
 
     __signals__ = {
-        "start-duration-changed" : ["start", "duration"]
+        "start-duration-changed" : ["start", "duration"],
+        "selected-changed" : [],
         }
 
     def __init__(self, factory=None, start=gst.CLOCK_TIME_NONE,
@@ -384,6 +385,13 @@
     factory = property(_get_factory, _set_factory,
                        doc="ObjectFactory used for this object")
 
+    def __get_selected(self):
+        return self._selected
+
+    def __set_selected(self, value):
+        self._selected = value
+        self.emit("selected-changed")
+    selected = property(__get_selected, __set_selected)
 
     ## read-only properties
 

Modified: trunk/pitivi/timeline/timeline.py
==============================================================================
--- trunk/pitivi/timeline/timeline.py	(original)
+++ trunk/pitivi/timeline/timeline.py	Fri Nov 28 17:35:00 2008
@@ -53,6 +53,7 @@
         self.timeline = gst.Bin("timeline-" + name)
         self.audiocomp = None
         self.videocomp = None
+        self.__selection = set()
         self._fillContents()
 
     def _fillContents(self):
@@ -145,6 +146,52 @@
     def getDuration(self):
         return max(self.audiocomp.duration, self.videocomp.duration)
 
+## code for managing the selection
+
+    __selection = None
+
+    def addToSelection(self, objs):
+        self.__selection.update(objs)
+        for obj in objs:
+            obj.selected = True
+
+    def removeFromSelection(self, objs):
+        self.__selection.difference_update(objs)
+        for obj in objs:
+            obj.selected = False
+
+    def setSelectionTo(self, objs):
+        for obj in self.__selection:
+            obj.selected = False
+        for obj in objs:
+            obj.selected = True
+        self.__selection = objs
+
+    def setSelectionToObj(self, obj):
+        self.setSelectionTo(set((obj,)))
+
+    def deleteSelection(self):
+        for obj in self.__selection:
+            if obj.isaudio:
+                self.audiocomp.removeSource(obj, remove_linked=True,
+                    collapse_neighbours=False)
+            else:
+                self.videocomp.removeSource(obj, remove_linked=True,
+                    collapse_neighbours=False)
+        self.__selection = set()
+
+    def unlinkSelection(self, obj):
+        pass
+
+    def relinkSelection(self, obj):
+        pass
+
+    def selectBefore(self):
+        pass
+
+    def selectAfter(self):
+        pass
+
 ## code for keeping track of edit points, and snapping timestamps to the
 ## nearest edit point. We do this here so we can keep track of edit points
 ## for all layers/tracks.

Modified: trunk/pitivi/ui/timelinecanvas.py
==============================================================================
--- trunk/pitivi/ui/timelinecanvas.py	(original)
+++ trunk/pitivi/ui/timelinecanvas.py	Fri Nov 28 17:35:00 2008
@@ -80,20 +80,8 @@
 
 ## Editing Operations
 
-    # FIXME: here once again we're doing something that would be better done
-    # in the core. As we add different types of objects in the Core, we'll
-    # have to modify this code here (maybe there are different ways of
-    # deleting different objects: you might delete() a source, but unset() a
-    # keyframe)
-
     def deleteSelected(self, unused_action):
-        for obj in self._selected_sources:
-            if obj.comp:
-                obj.comp.removeSource(obj.element, remove_linked=True, 
-                    collapse_neighbours=False)
-        set_selection(self, set())
-        return True
-
+        instance.PiTiVi.current.timeline.deleteSelection()
 
     # FIXME: the razor is the one toolbar tool that violates the noun-verb
     # principle. Do I really want to make an exception for this? What about

Modified: trunk/pitivi/ui/timelineobject.py
==============================================================================
--- trunk/pitivi/ui/timelineobject.py	(original)
+++ trunk/pitivi/ui/timelineobject.py	Fri Nov 28 17:35:00 2008
@@ -28,6 +28,10 @@
         self._view.element.snapStartDurationTime(max(
             self._view.pixelToNs(pos[0]), 0))
 
+    def click(self, pos):
+        instance.PiTiVi.current.timeline.setSelectionToObj(
+            self._view.element)
+
 class TrimHandle(View, goocanvas.Rect, Zoomable):
 
     """A component of a TimelineObject which manage's the source's edit
@@ -88,6 +92,7 @@
 
         self.bg = goocanvas.Rect(
             height=self.__HEIGHT__, 
+            fill_color_rgba=self.__NORMAL__,
             line_width=0)
 
         self.name = goocanvas.Text(
@@ -109,12 +114,6 @@
             self.add_child(thing)
         self.normal()
 
-    def select(self):
-        self.bg.props.fill_color_rgba = self.__SELECTED__
-
-    def normal(self):
-        self.bg.props.fill_color_rgba = self.__NORMAL__
-
     def zoomChanged(self):
         self._start_duration_cb(self.element, self.element.start,
             self.element.duration)
@@ -133,3 +132,10 @@
         self.bg.props.width = width
         # place end handle at appropriate distance
         self.end_handle.props.x = w
+
+    @handler(element, "selected-changed")
+    def _selected_changed(self, element):
+        if element.selected:
+            self.bg.props.fill_color_rgba = self.__SELECTED__
+        else:
+            self.bg.props.fill_color_rgba = self.__NORMAL__



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