Another try at fixing #4301.
authorCarl Hetherington <carl@carlh.net>
Wed, 31 Aug 2011 20:46:16 +0000 (20:46 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 31 Aug 2011 20:46:16 +0000 (20:46 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10045 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/group_tabs.cc
gtk2_ardour/group_tabs.h

index 4f194235e286251bad682b40220cabd0f79fb9f9..8deec1d70af39abee6463da2e2aadb829d7c91f1 100644 (file)
@@ -104,6 +104,7 @@ GroupTabs::on_button_press_event (GdkEventButton* ev)
 
                } else {
                        _dragging_new_tab = false;
+                       _initial_dragging_routes = routes_for_tab (t);
                }
 
                _dragging = t;
@@ -204,13 +205,15 @@ GroupTabs::on_button_release_event (GdkEventButton* ev)
                                boost::shared_ptr<RouteList> r = _session->get_routes ();
                                for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
 
-                                       if (find (routes.begin(), routes.end(), *i) == routes.end()) {
-                                               /* this route is not contained in the tab we are dragging ... */
-                                               if ((*i)->route_group() != _dragging->group) {
-                                                       /* and it's not in the dragged tab's group either */
-                                                       _dragging->group->remove (*i);
-                                               }
-                                       } else {
+                                       bool const was_in_tab = find (
+                                               _initial_dragging_routes.begin(), _initial_dragging_routes.end(), *i
+                                               ) != _initial_dragging_routes.end ();
+
+                                       bool const now_in_tab = find (routes.begin(), routes.end(), *i) != routes.end();
+
+                                       if (was_in_tab && !now_in_tab) {
+                                               _dragging->group->remove (*i);
+                                       } else if (!was_in_tab && now_in_tab) {
                                                _dragging->group->add (*i);
                                        }
                                }
@@ -222,6 +225,7 @@ GroupTabs::on_button_release_event (GdkEventButton* ev)
        }
 
        _dragging = 0;
+       _initial_dragging_routes.clear ();
 
        return true;
 }
index ed4a24709f50ab3c9c7e8d52e3ca2fd395ce0e8e..eaf03f6a228ce1086aa238b0b73b5a7febd7d49d 100644 (file)
@@ -113,6 +113,8 @@ private:
        Gtk::Menu* _menu;
        std::list<Tab> _tabs; ///< current list of tabs
        Tab* _dragging; ///< tab being dragged, or 0
+       /** routes that were in the tab that is being dragged when the drag started */
+       ARDOUR::RouteList _initial_dragging_routes;
        bool _dragging_new_tab; ///< true if we're dragging a new tab
        bool _drag_moved; ///< true if there has been movement during any current drag
        double _drag_fixed; ///< the position of the fixed end of the tab being dragged