New Route dialog: add fallback default selection
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 6f11e59900beeead23a65ccb3f4760125cc6db51..c9cff7a7cdd31169d2a0063eda34852841edb19c 100644 (file)
@@ -106,6 +106,7 @@ Mixer_UI::Mixer_UI ()
        , _monitor_section (0)
        , _plugin_selector (0)
        , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
+       , _spill_scroll_position (0)
        , ignore_reorder (false)
        , _in_group_rebuild_or_clear (false)
        , _route_deletion_in_progress (false)
@@ -656,60 +657,18 @@ Mixer_UI::select_none ()
        deselect_all_strip_processors();
 }
 
- void
+void
 Mixer_UI::select_next_strip ()
 {
        deselect_all_strip_processors();
-       strips.sort (MixerStripSorter());
-
-       if (_selection.empty()) {
-               _selection.set (strips.front());
-               return;
-       }
-
-       bool select_me = false;
-
-       for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
-
-               if (select_me) {
-                       _selection.set (*i);
-                       return;
-               }
-
-               if ((*i)->selected()) {
-                       select_me = true;
-               }
-       }
-
-       _selection.set (strips.front());
+       _session->selection().select_next_stripable (true, false);
 }
 
 void
 Mixer_UI::select_prev_strip ()
 {
        deselect_all_strip_processors();
-       strips.sort (MixerStripSorter());
-
-       if (_selection.empty()) {
-               _selection.set (strips.back());
-               return;
-       }
-
-       bool select_me = false;
-
-       for (list<MixerStrip*>::reverse_iterator i = strips.rbegin(); i != strips.rend(); ++i) {
-
-               if (select_me) {
-                       _selection.set (*i);
-                       return;
-               }
-
-               if ((*i)->selected()) {
-                       select_me = true;
-               }
-       }
-
-       _selection.set (strips.back());
+       _session->selection().select_prev_stripable (true, false);
 }
 
 void
@@ -1492,6 +1451,9 @@ Mixer_UI::redisplay_track_list ()
        if (ss) {
                boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
                if (sv) {
+                       if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
+                               _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
+                       }
                        spill_redisplay (sv);
                        return;
                }
@@ -1583,6 +1545,13 @@ Mixer_UI::redisplay_track_list ()
        }
 
        _group_tabs->set_dirty ();
+
+       if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
+               Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
+               adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
+       }
+       _spill_scroll_position = 0;
+
 }
 
 void
@@ -1740,10 +1709,10 @@ Mixer_UI::build_track_menu ()
        items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
        items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
        items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
-       items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
-       items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
        items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
        items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
+       items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
+       items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
 
 }