From 1f8e12a1b1cd5d6e4d2ec4961f6c50c671bf75b1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 6 Jan 2011 00:29:40 +0000 Subject: Another try at prettifying the processor list with different colours pre- and post-fader, a border etc. All colours should now be configurable from the UI RC file. git-svn-id: svn://localhost/ardour2/branches/3.0@8453 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/gtkmm2ext/gtkmm2ext/dndvbox.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'libs/gtkmm2ext/gtkmm2ext') diff --git a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h index 9afec560fc..582696ffe5 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h @@ -162,9 +162,9 @@ public: /** Look at a y coordinate and find the children below y, and the ones either side. * @param y y position. * @param before Filled in with the child before, or 0. - * @param before Filled in with the child under y, or 0. + * @param at Filled in with the child under y, or 0. * @param after Filled in with the child after, or 0. - * @return Fractional position in terms of child height. + * @return Fractional position in terms of child height, or -1 if not over a child. */ double get_children_around_position (int y, T** before, T** at, T** after) const { @@ -173,17 +173,28 @@ public: return -1; } - /* fractional position in terms of children */ - double const nf = double (y) / _children.front()->widget().get_allocation().get_height (); - *before = 0; - int i = 0; typename std::list::const_iterator j = _children.begin (); - while (i < int (nf) && j != _children.end()) { + + /* index of current child */ + int i = 0; + /* top of current child */ + double top = 0; + /* bottom of current child */ + double bottom = (*j)->widget().get_allocation().get_height (); + + while (y >= bottom && j != _children.end()) { + + top = bottom; + *before = *j; ++i; ++j; + + if (j != _children.end()) { + bottom += (*j)->widget().get_allocation().get_height (); + } } if (j == _children.end()) { @@ -197,7 +208,7 @@ public: ++j; *after = j != _children.end() ? *j : 0; - return nf; + return i + ((y - top) / (*at)->widget().get_allocation().get_height()); } /** @param y y coordinate. @@ -214,6 +225,10 @@ public: return r; } + + void set_spacing (int s) { + _internal_vbox.set_spacing (s); + } /** Children have been reordered by a drag */ sigc::signal Reordered; -- cgit v1.2.3