From 0e6e6cfde6e7053dfd4f963cff6c1317acf21f59 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 May 2017 18:32:04 +0200 Subject: [PATCH] Remember Monitor-section state (show/hide, attached/detached) --- gtk2_ardour/mixer_ui.cc | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index aa4dc1bd20..bd679e42e5 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -564,7 +564,11 @@ Mixer_UI::add_stripables (StripableList& slist) _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached)); _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached)); - monitor_section_attached (); + if (_monitor_section->tearoff().torn_off()) { + monitor_section_detached (); + } else { + monitor_section_attached (); + } route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context()); @@ -2130,6 +2134,14 @@ Mixer_UI::set_state (const XMLNode& node, int version) tact->set_active (yn); } + if (node.get_property ("monitor-section-visible", yn)) { + Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + /* do it twice to force the change */ + tact->set_active (yn); + show_monitor_section (yn); + } + XMLNode* plugin_order; if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) { @@ -2171,6 +2183,11 @@ Mixer_UI::get_state () node->set_property ("show-mixer-list", _show_mixer_list); node->set_property ("maximised", _maximised); + Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + assert (tact); + node->set_property ("monitor-section-visible", tact->get_active ()); + store_current_favorite_order (); XMLNode* plugin_order = new XMLNode ("PluginOrder"); uint32_t cnt = 0; @@ -2280,10 +2297,6 @@ Mixer_UI::parameter_changed (string const & p) for (list::iterator i = strips.begin(); i != strips.end(); ++i) { (*i)->set_width_enum (s ? Narrow : Wide, this); } - } else if (p == "use-monitor-bus") { - if (_session && !_session->monitor_out()) { - monitor_section_detached (); - } } } @@ -2432,6 +2445,22 @@ void Mixer_UI::monitor_section_going_away () { if (_monitor_section) { + XMLNode* ui_node = Config->extra_xml(X_("UI")); + /* immediate state save. + * + * Tearoff settings are otherwise only stored during + * save_ardour_state(). The mon-section may or may not + * exist at that point. + * */ + if (ui_node) { + XMLNode* tearoff_node = ui_node->child (X_("Tearoffs")); + if (tearoff_node) { + tearoff_node->remove_nodes_and_delete (X_("monitor-section")); + XMLNode* t = new XMLNode (X_("monitor-section")); + _monitor_section->tearoff().add_state (*t); + tearoff_node->add_child_nocopy (*t); + } + } monitor_section_detached (); out_packer.remove (_monitor_section->tearoff()); _monitor_section->set_session (0); @@ -2496,7 +2525,7 @@ Mixer_UI::monitor_section_attached () Glib::RefPtr act = ActionManager::get_action ("Common", "ToggleMonitorSection"); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); act->set_sensitive (true); - tact->set_active (); + show_monitor_section (tact->get_active ()); } void -- 2.30.2