From 5292a8f4ae1469d6287a75814c8661f4fb8ba311 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 4 Jul 2017 17:07:47 +0200 Subject: [PATCH] Allow DnDVbox to sort the selection, using original order In preparation for Processors to be copy/pasted in the same order as they appear on the strip -- not order in which they are selected. --- libs/gtkmm2ext/gtkmm2ext/dndvbox.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h index 750ba5c056..c695765ea8 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h @@ -127,8 +127,19 @@ public: } /** @return Selected children */ - std::list selection () const { - return _selection; + std::list selection (bool sorted = false) const { + if (!sorted) { + return _selection; + } else { + /* simple insertion-sort */ + std::list rv; + for (typename std::list::const_iterator i = _children.begin(); i != _children.end(); ++i) { + if (selected (*i)) { + rv.push_back (*i); + } + } + return rv; + } } /** Set the `active' child; this is simply a child which is set to have the @@ -406,8 +417,6 @@ private: } else { /* drag started in another DnDVBox; raise a signal to say what happened */ - - std::list dropped = _drag_source->selection (); DropFromAnotherBox (_drag_source, drop.first, context); }