[pitivi: 3/12] timeline.py: implement SELECT_BETWEEN selection mode



commit c3ebdd450dc4e8758a0f176fb4d4148fec94d661
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Wed Nov 25 10:47:28 2009 -0800

    timeline.py: implement SELECT_BETWEEN selection mode

 pitivi/timeline/timeline.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index caabf10..8e1edab 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -38,6 +38,8 @@ UNSELECT = 1
 """Remove the given set from the selection."""
 SELECT_ADD = 2
 """Extend the selection with the given set"""
+SELECT_BETWEEN = 3
+"""Select a range of clips"""
 
 class TimelineError(Exception):
     """Base Exception for errors happening in L{Timeline}s or L{TimelineObject}s"""
@@ -457,6 +459,7 @@ class Selection(Signallable):
 
     def __init__(self):
         self.selected = set([])
+        self.last_single_obj = None
 
     def setToObj(self, obj, mode):
         """
@@ -508,6 +511,9 @@ class Selection(Signallable):
             selection = self.selected - selection
         self.selected = selection
 
+        if len(self.selected) == 1:
+            self.last_single_obj = iter(selection).next()
+
         for obj in self.selected - old_selection:
             obj.selected = True
         for obj in old_selection - self.selected:
@@ -1669,6 +1675,19 @@ class Timeline(Signallable, Loggable):
 
         @see: L{Selection.setToObj}
         """
+        if mode == SELECT_BETWEEN:
+            if self.selection.last_single_obj:
+                last = self.selection.last_single_obj
+                earliest = min(last.start, obj.start)
+                latest = max(last.start + last.duration,
+                    obj.start + obj.duration)
+                min_priority = min(last.priority, obj.priority)
+                max_priority = max(last.priority, obj.priority)
+                objs = self.getObjsInRegion(earliest, latest,
+                    min_priority, max_priority)
+                self.setSelectionTo(objs, SELECT)
+                return
+
         self.selection.setToObj(obj, mode)
 
     def setSelectionTo(self, selection, mode):



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