ensure that when mixer is shown in its own tab, it has a default focus widget, so...
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 05c2a51f628a631f59b1c5a4c663e6889ec1f741..f197ba34a29332c37436c2900cc1dd10203dfadd 100644 (file)
@@ -390,13 +390,16 @@ Mixer_UI::use_own_window (bool and_fill_it)
 
        Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
 
-
        if (win && new_window) {
                win->set_name ("MixerWindow");
                ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
                win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
                win->set_data ("ardour-bindings", bindings);
                update_title ();
+               if (!win->get_focus()) {
+                       /* set focus widget to something, anything */
+                       win->set_focus (scroller);
+               }
        }
 
        return win;
@@ -765,13 +768,20 @@ Mixer_UI::sync_presentation_info_from_treeview ()
                SortByNewDisplayOrder cmp;
                sort (sorted.begin(), sorted.end(), cmp);
                for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
+                       if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) {
+                               ++n;
+                       }
                        if (sr->old_display_order != n) {
                                change = true;
+                               break;
                        }
                }
                if (change) {
                        n = 0;
                        for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
+                               if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) {
+                                       ++n;
+                               }
                                if (sr->stripable->presentation_info().order() != n) {
                                        sr->stripable->set_presentation_order (n);
                                }
@@ -850,7 +860,7 @@ Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_chan
                        }
                }
 
-               if (!_selection.axes.empty()) {
+               if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll ()) {
                        move_stripable_into_view ((*_selection.axes.begin())->stripable());
                }
        }
@@ -1333,6 +1343,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
 
                AxisView* av = (*i)[stripable_columns.strip];
                MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
+               bool const visible = (*i)[stripable_columns.visible];
 
                if (!strip) {
                        /* we're in the middle of changing a row, don't worry */
@@ -1356,7 +1367,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
                        }
                }
 
-               if (slaved) {
+               if (slaved && visible) {
 
                        if (strip->packed()) {
                                strip_packer.reorder_child (*strip, -1); /* put at end */
@@ -1585,11 +1596,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
 #endif
        bool found = false;
        int x0 = 0;
+       Gtk::Allocation alloc;
        for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
                if ((*i)->route() == s) {
                        int y;
                        found = true;
                        (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
+                       alloc = (*i)->get_allocation ();
                        break;
                }
        }
@@ -1598,7 +1611,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
        }
 
        Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
-       scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
+
+       if (x0 < adj->get_value()) {
+               adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
+       } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
+               int x1 = x0 + alloc.get_width() - adj->get_page_size();
+               adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
+       }
 }
 
 void
@@ -3079,26 +3098,22 @@ void
 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
 {
        set_axis_targets_for_operation ();
-#if 0
        BOOST_FOREACH(AxisView* r, _axis_targets) {
                MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
                if (ms) {
                        ms->vca_assign (vca);
                }
        }
-#endif
 }
 
 void
 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
 {
        set_axis_targets_for_operation ();
-#if 0
        BOOST_FOREACH(AxisView* r, _axis_targets) {
                MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
                if (ms) {
                        ms->vca_unassign (vca);
                }
        }
-#endif
 }