From dfa9f92e531bd08170afb9c69fb9f79f832722ea Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 16 Mar 2021 00:36:22 +0100 Subject: [PATCH] Fix tab-button state and cycling through tabs The initial calls in `we_have_dependents()` was redundantly setting all widows to "Hidden", before the actual state was known. tabbable_state_change() is initially called for all Tabs: ARDOUR_UI::setup_windows -> add_to_notebook() -> attach(), or for detached windows Tabbable::set_state() -> hide_tab(). Step_up/down_through_tabs used window visibility to determine candidates. This incorrectly considered detached visible tabs. Detached windows cannot be cycled to. This also addressed an issue where tab-buttons state was incorrectly unset what unrelated tab state changed. ImplicitActive of the currently active tab is now retained when some other window is attached/detached. --- gtk2_ardour/ardour_ui_dependents.cc | 9 ----- gtk2_ardour/ardour_ui_dialogs.cc | 57 ++++++++++++----------------- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 1335622663..b69302111a 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -112,15 +112,6 @@ ARDOUR_UI::we_have_dependents () editor->setup_tooltips (); editor->UpdateAllTransportClocks.connect (sigc::mem_fun (*this, &ARDOUR_UI::update_transport_clocks)); - /* catch up on tabbable state, in the right order to leave the editor - * selected by default - */ - - tabbable_state_change (*rc_option_editor); - tabbable_state_change (*mixer); - tabbable_state_change (*editor); - tabbable_state_change (*recorder); - /* all actions are defined */ ActionManager::load_menus (ARDOUR_COMMAND_LINE::menus_file); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index c682b821d0..d85f06c1cd 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -467,19 +467,19 @@ ARDOUR_UI::step_up_through_tabs () /* this list must match the order of visibility buttons */ - if (!recorder->window_visible()) { + if (recorder->tabbed()) { candidates.push_back (recorder); } - if (!editor->window_visible()) { + if (editor->tabbed()) { candidates.push_back (editor); } - if (!mixer->window_visible()) { + if (mixer->tabbed()) { candidates.push_back (mixer); } - if (!rc_option_editor->window_visible()) { + if (rc_option_editor->tabbed()) { candidates.push_back (rc_option_editor); } @@ -512,19 +512,19 @@ ARDOUR_UI::step_down_through_tabs () /* this list must match the order of visibility buttons */ - if (!recorder->window_visible()) { + if (recorder->tabbed()) { candidates.push_back (recorder); } - if (!editor->window_visible()) { + if (editor->tabbed()) { candidates.push_back (editor); } - if (!mixer->window_visible()) { + if (mixer->tabbed()) { candidates.push_back (mixer); } - if (!rc_option_editor->window_visible()) { + if (rc_option_editor->tabbed()) { candidates.push_back (rc_option_editor); } @@ -823,48 +823,37 @@ ARDOUR_UI::tabbable_state_change (Tabbable& t) } ArdourButton* vis_button = 0; - std::vector other_vis_buttons; if (&t == editor) { vis_button = &editor_visibility_button; - other_vis_buttons.push_back (&mixer_visibility_button); - other_vis_buttons.push_back (&prefs_visibility_button); - other_vis_buttons.push_back (&recorder_visibility_button); } else if (&t == mixer) { vis_button = &mixer_visibility_button; - other_vis_buttons.push_back (&editor_visibility_button); - other_vis_buttons.push_back (&prefs_visibility_button); - other_vis_buttons.push_back (&recorder_visibility_button); } else if (&t == rc_option_editor) { vis_button = &prefs_visibility_button; - other_vis_buttons.push_back (&editor_visibility_button); - other_vis_buttons.push_back (&mixer_visibility_button); - other_vis_buttons.push_back (&recorder_visibility_button); } else if (&t == recorder) { vis_button = &recorder_visibility_button; - other_vis_buttons.push_back (&editor_visibility_button); - other_vis_buttons.push_back (&mixer_visibility_button); - other_vis_buttons.push_back (&prefs_visibility_button); } if (!vis_button) { + assert (0); return; } - switch (vs) { - case Tabbed: - vis_button->set_active_state (Gtkmm2ext::ImplicitActive); - break; - case Windowed: - vis_button->set_active_state (Gtkmm2ext::ExplicitActive); - break; - case Hidden: - vis_button->set_active_state (Gtkmm2ext::Off); - break; - } + /* First update button states for (other) tabbed windows. + * (Gtkmm2ext::Off or Gtkmm2ext::ImplicitActive) + */ + tabs_switch (NULL, _tabs.get_current_page ()); - for (std::vector::iterator b = other_vis_buttons.begin(); b != other_vis_buttons.end(); ++b) { - (*b)->set_active_state (Gtkmm2ext::Off); + switch (vs) { + case Tabbed: + /* nothing to do */ + break; + case Windowed: + vis_button->set_active_state (Gtkmm2ext::ExplicitActive); + break; + case Hidden: + vis_button->set_active_state (Gtkmm2ext::Off); + break; } }