[pitivi] Properly limit the position calculation for drag'n'drop feedback
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Properly limit the position calculation for drag'n'drop feedback
- Date: Sat, 21 Jul 2012 20:01:38 +0000 (UTC)
commit fb42c79272e237bff16408f0b74fd6f41c243e7d
Author: Paul Lange <palango gmx de>
Date: Sun Jul 15 20:18:11 2012 +0200
Properly limit the position calculation for drag'n'drop feedback
pitivi/timeline/timeline.py | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 842883c..bccae4b 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -754,13 +754,13 @@ class TimelineControls(gtk.VBox, Loggable):
for child in self.get_children():
child.setSeparatorHighlight(False)
- self.moveControlWidget(widget, self._getIndexForPosition(y))
+ self.moveControlWidget(widget, self._getIndexForPosition(y, widget))
def _dragMotionCb(self, widget, context, x, y, timestamp):
"""
Highlight separator where control would go when dropping
"""
- index = self._getIndexForPosition(y)
+ index = self._getIndexForPosition(y, context.get_source_widget())
for child in self.get_children():
child.setSeparatorHighlight(False)
@@ -771,7 +771,7 @@ class TimelineControls(gtk.VBox, Loggable):
else:
self.get_children()[index - 1].setSeparatorHighlight(True)
- def _getIndexForPosition(self, y):
+ def _getIndexForPosition(self, y, widget):
"""
Calculates the new index for a dragged layer
"""
@@ -782,12 +782,22 @@ class TimelineControls(gtk.VBox, Loggable):
for child in self.get_children():
next = counter + child.getHeight()
if y >= counter and y < next:
- return index
+ return self._limitPositionIndex(index, widget)
counter = next
index += 1
- return index
+ return self._limitPositionIndex(index, widget)
+
+ def _limitPositionIndex(self, index, widget):
+ """
+ Limit the index depending on the type of widget
+ """
+ limit = len(self.get_children()) / 2
+ if type(widget) == AudioLayerControl:
+ return max(index, limit)
+ else:
+ return min(index, limit)
def moveControlWidget(self, control, index):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]