Fix VCA pane being made visible when redisplaying tracks
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 23bc8c52db523f073344e8669ca1f8320abb51db..5e9126e08af4a8ec51c1f8aae83dd52578e6183f 100644 (file)
@@ -135,17 +135,31 @@ Mixer_UI::Mixer_UI ()
        scroller_base.drag_dest_set (target_table);
        scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
 
-       //create a button to add mixer strips ( replaces the old buttons in the mixer list )
-       Button* add_button = manage (new Button);
-       add_button->show ();
+       /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
        Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
        w->show ();
-       add_button->add (*w);
-       add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
+       add_vca_button.add (*w);
+       add_vca_button.set_can_focus(false);
+       add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
 
-       // add as last item of strip packer
+       /* create a button to add mixer strips */
+       w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
+       w->show ();
+       add_button.add (*w);
+       add_button.set_can_focus(false);
+       add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
+
+       /* add as last item of strip packer */
        strip_packer.pack_end (scroller_base, true, true);
-       strip_packer.pack_end (*add_button, false, false);
+       strip_packer.pack_end (add_button, false, false);
+
+#ifdef MIXBUS
+       /* create a drop-shadow at the end of the mixer strips */
+       mb_shadow.set_size_request( 4, -1 );
+       mb_shadow.set_name("EditorWindow");
+       mb_shadow.show();
+       strip_packer.pack_end (mb_shadow, false, false);
+#endif
 
        _group_tabs = new MixerGroupTabs (this);
        VBox* b = manage (new VBox);
@@ -268,7 +282,7 @@ Mixer_UI::Mixer_UI ()
        list_hpane.set_check_divider_position (true);
        list_hpane.add (list_vpacker);
        list_hpane.add (global_hpacker);
-       list_hpane.set_child_minsize (list_vpacker, 1);
+       list_hpane.set_child_minsize (list_vpacker, 30);
 
        XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
        float fract;
@@ -312,7 +326,6 @@ Mixer_UI::Mixer_UI ()
        mixer_scroller_vpacker.show();
        list_vpacker.show();
        group_display_button_label.show();
-       group_display_button.show();
        group_display_scroller.show();
        favorite_plugins_scroller.show();
        group_display_vbox.show();
@@ -332,6 +345,7 @@ Mixer_UI::Mixer_UI ()
        list_hpane.show();
        group_display.show();
        favorite_plugins_display.show();
+       add_button.show ();
 
        MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
        VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
@@ -347,6 +361,7 @@ Mixer_UI::Mixer_UI ()
 #endif
 
        PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
+       PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
        ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
 }
 
@@ -577,7 +592,12 @@ Mixer_UI::add_stripables (StripableList& slist)
 
                                show_strip (strip);
 
-                               if (!route->is_master()) {
+                               if (route->is_master()) {
+
+                                       out_packer.pack_start (*strip, false, false);
+                                       strip->set_packed (true);
+
+                               } else {
 
                                        TreeModel::Row row = *(track_model->insert (insert_iter));
 
@@ -585,11 +605,6 @@ Mixer_UI::add_stripables (StripableList& slist)
                                        row[stripable_columns.visible] = strip->marked_for_display();
                                        row[stripable_columns.stripable] = route;
                                        row[stripable_columns.strip] = strip;
-
-                               } else {
-
-                                       out_packer.pack_start (*strip, false, false);
-                                       strip->set_packed (true);
                                }
 
                                strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
@@ -1437,19 +1452,12 @@ Mixer_UI::redisplay_track_list ()
 
        container_clear (vca_hpacker);
 
-       //create a button to add mixer strips ( replaces the old buttons in the mixer list )
-       Button* add_vca_button = manage (new Button);
-       Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
-       w->show ();
-       add_vca_button->add (*w);
-       add_vca_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
-
        vca_hpacker.pack_end (vca_scroller_base, true, true);
-       vca_hpacker.pack_end (*add_vca_button, false, false);
+       vca_hpacker.pack_end (add_vca_button, false, false);
 
-       add_vca_button->show ();
+       add_vca_button.show ();
        vca_scroller_base.show();
-       
+
        for (i = rows.begin(); i != rows.end(); ++i) {
 
                AxisView* s = (*i)[stripable_columns.strip];
@@ -1507,7 +1515,14 @@ Mixer_UI::redisplay_track_list ()
                vca_vpacker.hide ();
        } else {
                UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
-               vca_vpacker.show ();
+
+               Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleVCAPane");
+               if (act) {
+                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+                       showhide_vcas (tact->get_active());
+               } else {
+                       vca_vpacker.show ();
+               }
        }
 
        _group_tabs->set_dirty ();
@@ -2154,12 +2169,12 @@ Mixer_UI::set_state (const XMLNode& node, int version)
                show_monitor_section (yn);
        }
 
-
-       XMLNode* plugin_order;
-       if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
+       //check for the user's plugin_order file
+       XMLNode plugin_order_new(X_("PO"));
+       if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
                store_current_favorite_order ();
                std::list<string> order;
-               const XMLNodeList& kids = plugin_order->children("PluginInfo");
+               const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
                XMLNodeConstIterator i;
                for (i = kids.begin(); i != kids.end(); ++i) {
                        std::string unique_id;
@@ -2173,10 +2188,59 @@ Mixer_UI::set_state (const XMLNode& node, int version)
                PluginStateSorter cmp (order);
                favorite_order.sort (cmp);
                sync_treeview_from_favorite_order ();
+
+       } else {
+               //if there is no user file, then use an existing one from instant.xml
+               //NOTE: if you are loading an old session, this might come from the session's instant.xml
+               //Todo:  in the next major version, we should probably stop doing the instant.xml check, and just use the new file
+               XMLNode* plugin_order;
+               if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
+                       store_current_favorite_order ();
+                       std::list<string> order;
+                       const XMLNodeList& kids = plugin_order->children("PluginInfo");
+                       XMLNodeConstIterator i;
+                       for (i = kids.begin(); i != kids.end(); ++i) {
+                               std::string unique_id;
+                               if ((*i)->get_property ("unique-id", unique_id)) {
+                                       order.push_back (unique_id);
+                                       if ((*i)->get_property ("expanded", yn)) {
+                                               favorite_ui_state[unique_id] = yn;
+                                       }
+                               }
+                       }
+
+                       PluginStateSorter cmp (order);
+                       favorite_order.sort (cmp);
+                       sync_treeview_from_favorite_order ();
+               }
        }
+
        return 0;
 }
 
+void
+Mixer_UI::save_plugin_order_file ()
+{
+       //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
+
+       //NOTE:  this replaces the old code that stores info in instant.xml
+       //why?  because instant.xml prefers the per-session settings, and we want this to be a global pref
+
+       store_current_favorite_order ();
+       XMLNode plugin_order ("PluginOrder");
+       uint32_t cnt = 0;
+       for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
+               XMLNode* p = new XMLNode ("PluginInfo");
+               p->set_property ("sort", cnt);
+               p->set_property ("unique-id", (*i)->unique_id);
+               if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
+                       p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
+               }
+               plugin_order.add_child_nocopy (*p);
+       }
+       PluginManager::instance().save_plugin_order_file( plugin_order );
+}
+
 XMLNode&
 Mixer_UI::get_state ()
 {
@@ -2199,20 +2263,6 @@ Mixer_UI::get_state ()
        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;
-       for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
-               XMLNode* p = new XMLNode ("PluginInfo");
-               p->set_property ("sort", cnt);
-               p->set_property ("unique-id", (*i)->unique_id);
-               if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
-                       p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
-               }
-               plugin_order->add_child_nocopy (*p);
-       }
-       node->add_child_nocopy (*plugin_order);
-
        return *node;
 }
 
@@ -2231,6 +2281,14 @@ Mixer_UI::scroll_left ()
        using namespace Gtk::Box_Helpers;
        const BoxList& strips = strip_packer.children();
        for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
+               if (i->get_widget() == & add_button) {
+                       continue;
+               }
+#ifdef MIXBUS
+               if (i->get_widget() == &mb_shadow) {
+                       continue;
+               }
+#endif
                lm += i->get_widget()->get_width ();
                if (lm >= lp) {
                        lm -= i->get_widget()->get_width ();
@@ -2255,6 +2313,14 @@ Mixer_UI::scroll_right ()
        using namespace Gtk::Box_Helpers;
        const BoxList& strips = strip_packer.children();
        for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
+               if (i->get_widget() == & add_button) {
+                       continue;
+               }
+#ifdef MIXBUS
+               if (i->get_widget() == &mb_shadow) {
+                       continue;
+               }
+#endif
                lm += i->get_widget()->get_width ();
                if (lm > lp + 1) {
                        break;