summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-02-01 23:21:28 +0000
committerCarl Hetherington <carl@carlh.net>2011-02-01 23:21:28 +0000
commitd3a4b2df743ec6455ce0aa8940a3435a48d6488c (patch)
tree71fe2a0622f30f142ec731ca906fccac2e67b331 /libs
parent6c7d8c6877e8e8f0312a4ef641d4a42f3ba88ddc (diff)
Fix drop location for drag-and-drop in some cases.
git-svn-id: svn://localhost/ardour2/branches/3.0@8672 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/dndvbox.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h
index 27aec2a29e..fab955925e 100644
--- a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h
+++ b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h
@@ -312,18 +312,36 @@ private:
{
/* work out where it was dropped */
std::pair<T*, double> const drop = get_child_at_position (y);
+
+
if (_drag_source == this) {
/* dropped from ourselves onto ourselves */
-
+
T* child = *((T **) selection_data.get_data());
-
- /* reorder child widgets accordingly */
+
if (drop.first == 0) {
_internal_vbox.reorder_child (child->widget(), -1);
} else {
- _internal_vbox.reorder_child (child->widget(), int (drop.second));
+
+ /* where in the list this child should be dropped */
+ int target = drop.second + 0.5;
+
+ /* find out whether the child was `picked up' from before the drop position */
+ int n = 0;
+ typename std::list<T*>::const_iterator i = _children.begin ();
+ while (i != _children.end() && *i != child && n < target) {
+ ++i;
+ ++n;
+ }
+
+ /* if so, adjust the drop position to account for this */
+ if (n < target) {
+ --target;
+ }
+
+ _internal_vbox.reorder_child (child->widget(), target);
}
} else {