Select another track when one is deleted, thereby allowing the editor mixer to stick...
authorCarl Hetherington <carl@carlh.net>
Sun, 4 Nov 2007 23:18:15 +0000 (23:18 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 4 Nov 2007 23:18:15 +0000 (23:18 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2588 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.h
gtk2_ardour/editor_mixer.cc
gtk2_ardour/editor_route_list.cc

index 5f18d36e67aac44856f4d5c1dc9622292142bb4d..96c1d1004da3a86617baa5a240f2bd376052e5da 100644 (file)
@@ -1877,6 +1877,7 @@ class Editor : public PublicEditor
        MixerStrip *current_mixer_strip;
        bool show_editor_mixer_when_tracks_arrive;
        Gtk::VBox current_mixer_strip_vbox;
+       void cms_new (boost::shared_ptr<ARDOUR::Route>);
        void cms_deleted ();
        void current_mixer_strip_hidden ();
        void current_mixer_strip_removed ();
index dee928b62f5c3eff346453313fe6f9e931fae5ca..669297b6e49c8ae775e6a8f88ca48270dc78bede 100644 (file)
@@ -57,6 +57,13 @@ Editor::editor_list_button_toggled ()
        }
 }
 
+void
+Editor::cms_new (boost::shared_ptr<ARDOUR::Route> r)
+{
+       current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(), *session, r);
+       current_mixer_strip->GoingAway.connect (mem_fun (*this, &Editor::cms_deleted));
+}
+
 void
 Editor::cms_deleted ()
 {
@@ -83,12 +90,7 @@ Editor::show_editor_mixer (bool yn)
                                        AudioTimeAxisView* atv;
 
                                        if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
-                                               
-                                               current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                                                                     *session,
-                                                                                     atv->route(), false);
-
-                                               current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
+                                               cms_new (atv->route ());
                                                break;
                                        }
                                }
@@ -101,11 +103,7 @@ Editor::show_editor_mixer (bool yn)
                                        AudioTimeAxisView* atv;
 
                                        if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
-
-                                               current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                                                                     *session,
-                                                                                     atv->route(), false);
-                                               current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));                                          
+                                               cms_new (atv->route ());
                                                break;
                                        }
                                }
@@ -175,10 +173,7 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
                current_mixer_strip = 0;
        }
 
-       current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
-                                             *session,
-                                             rt->route());
-       current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
+       cms_new (rt->route ());
        
        if (show) {
                show_editor_mixer (true);
@@ -390,3 +385,4 @@ Editor::maybe_add_mixer_strip_width (XMLNode& node)
                node.add_property ("mixer-width", enum_2_string (current_mixer_strip->get_width()));
        }
 }
+
index 5e10a578f55e899fcc8bc8663f348b441632dfca..e941b4c1cea4e6cf9cb15db9628b450be7df2f49 100644 (file)
@@ -155,13 +155,40 @@ Editor::remove_route (TimeAxisView *tv)
 {
        ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
 
-       
-       TrackViewList::iterator i;
        TreeModel::Children rows = route_display_model->children();
        TreeModel::Children::iterator ri;
 
-       if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
+       /* find the track view that's being deleted */
+       TrackViewList::iterator i = find (track_views.begin(), track_views.end(), tv);
+
+       /* set up `nearby' to be a suitable nearby track to select once
+          this one has gong */
+       TrackViewList::iterator nearby = track_views.end ();
+       if (i != track_views.end()) {
+
+               nearby = i;
+
+               if (nearby != track_views.begin()) {
+                       /* go to the previous track if there is one */
+                       nearby--;
+               } else {
+                       /* otherwise the next track */
+                       nearby++;
+               }
+
+               /* and remove the track view that's going */
                track_views.erase (i);
+
+               if (nearby != track_views.end()) {
+                       /* we've got another track to select, so select it */
+                       set_selected_track (**nearby, Selection::Set);
+               } else {
+                       /* we've got no other track, so the editor mixer will disappear */
+                       editor_mixer_button.set_active (false);
+                       ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
+                       editor_mixer_button.set_sensitive (false);
+                       editor_list_button.set_sensitive (false);
+               }
        }
 
        for (ri = rows.begin(); ri != rows.end(); ++ri) {
@@ -170,21 +197,6 @@ Editor::remove_route (TimeAxisView *tv)
                        break;
                }
        }
-       /* since the editor mixer goes away when you remove a route, set the
-        * button to inactive and untick the menu option
-        */
-       editor_mixer_button.set_active(false);
-       ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
-
-       /* and disable if all tracks and/or routes are gone */
-
-       if (track_views.size() == 0) {
-               editor_mixer_button.set_sensitive(false);
-               
-               editor_list_button.set_active(false);
-               ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-list");
-               editor_list_button.set_sensitive(false);
-       }
 }
 
 void