remove cruft (old cvsignore files)
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / dndvbox.h
index a5b85234c4941c8e1766f79dd927a1cfa66538a1..bc5ca6c7255dbef61a2272cd7574f97e32e400f7 100644 (file)
@@ -57,8 +57,8 @@ public:
                        Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
                        );
 
-               signal_button_press_event().connect (bind (mem_fun (*this, &DnDVBox::button_press), (T *) 0));
-               signal_button_release_event().connect (bind (mem_fun (*this, &DnDVBox::button_release), (T *) 0));
+               signal_button_press_event().connect (sigc::bind (mem_fun (*this, &DnDVBox::button_press), (T *) 0));
+               signal_button_release_event().connect (sigc::bind (mem_fun (*this, &DnDVBox::button_release), (T *) 0));
                signal_drag_motion().connect (mem_fun (*this, &DnDVBox::drag_motion));
                signal_drag_leave().connect (mem_fun (*this, &DnDVBox::drag_leave));
 
@@ -218,6 +218,24 @@ public:
        sigc::signal<void> SelectionChanged;
 
 private:
+
+       /** @return the bottom y position of a child, pretending any placeholder
+        *  is not there.
+        */
+       double bottom_of_child_ignoring_placeholder (T* child) const
+       {
+               Gtk::Allocation const a = child->widget().get_allocation ();
+               double bottom = a.get_y() + a.get_height();
+
+               if (_placeholder) {
+                       Gtk::Allocation const b = _placeholder->get_allocation ();
+                       if (b.get_y() < a.get_y()) {
+                               bottom -= (b.get_height () + _internal_vbox.get_spacing ());
+                       }
+               }
+
+               return bottom;
+       }
        
        /** Look at a y coordinate and find the children below y, and the ones either side.
         *  @param y y position.
@@ -242,8 +260,7 @@ private:
                /* top of current child */
                double top = 0;
                /* bottom of current child */
-               Gtk::Allocation const a = (*j)->widget().get_allocation();
-               double bottom = a.get_y() + a.get_height();
+               double bottom = bottom_of_child_ignoring_placeholder (*j);
 
                while (y >= bottom && j != _children.end()) {
 
@@ -254,8 +271,7 @@ private:
                        ++j;
 
                        if (j != _children.end()) {
-                               Gtk::Allocation const a = (*j)->widget().get_allocation();
-                               bottom = a.get_y() + a.get_height();
+                               bottom = bottom_of_child_ignoring_placeholder (*j);
                        }
                }
 
@@ -270,7 +286,7 @@ private:
                ++j;
                *after = j != _children.end() ? *j : 0;
 
-               return i + ((y - top) / (*at)->widget().get_allocation().get_height());
+               return i + ((y - top) / (bottom - top));
        }
 
        void drag_begin (Glib::RefPtr<Gdk::DragContext> const & context, T* child)
@@ -555,8 +571,9 @@ private:
        {
                typename std::list<T*>::iterator x = find (_selection.begin(), _selection.end(), child);
                if (x != _selection.end()) {
+                       T* c = *x;
                        _selection.erase (x);
-                       setup_child_state (*x);
+                       setup_child_state (c);
                }
        }