Assorted doxygen fixes; no functional changes.
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / dndvbox.h
index 27aec2a29e55f1b714bf9eb928857136657202d2..e0b1c6ea1338adcf0447c6dc6ba066a5d232bcec 100644 (file)
@@ -127,7 +127,7 @@ public:
                }
        }
 
-       /** @param Child
+       /** @param child Child
         *  @return true if the child is selected, otherwise false.
         */
        bool selected (T* child) const {
@@ -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 {