Remove cruft
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 5232ab32cf6155f6e6fb2d591f81ff8c8201f9df..179acf8426fab0a02042bb79a4e95ea28c8a8a77 100644 (file)
@@ -111,6 +111,7 @@ Mixer_UI::Mixer_UI ()
        , _route_deletion_in_progress (false)
        , _maximised (false)
        , _show_mixer_list (true)
+       , _strip_selection_change_without_scroll (false)
        , myactions (X_("mixer"))
        , _selection (*this, *this)
 {
@@ -134,8 +135,17 @@ 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 ();
+       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 as last item of strip packer
        strip_packer.pack_end (scroller_base, true, true);
+       strip_packer.pack_end (*add_button, false, false);
 
        _group_tabs = new MixerGroupTabs (this);
        VBox* b = manage (new VBox);
@@ -187,36 +197,12 @@ Mixer_UI::Mixer_UI ()
        group_display_scroller.add (group_display);
        group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
 
-       HBox* route_group_display_button_box = manage (new HBox());
-
-       Button* route_group_add_button = manage (new Button ());
-       Button* route_group_remove_button = manage (new Button ());
-
-       Widget* w;
-
-       w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
-       w->show();
-       route_group_add_button->add (*w);
-
-       w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
-       w->show();
-       route_group_remove_button->add (*w);
-
-       route_group_display_button_box->set_homogeneous (true);
-
-       route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
-       route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
-
-       route_group_display_button_box->add (*route_group_add_button);
-       route_group_display_button_box->add (*route_group_remove_button);
 
        group_display_vbox.pack_start (group_display_scroller, true, true);
-       group_display_vbox.pack_start (*route_group_display_button_box, false, false);
-
-       group_display_sample.set_name ("BaseFrame");
-       group_display_sample.set_shadow_type (Gtk::SHADOW_IN);
-       group_display_sample.add (group_display_vbox);
 
+       group_display_frame.set_name ("BaseFrame");
+       group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
+       group_display_frame.add (group_display_vbox);
 
        list<TargetEntry> target_list;
        target_list.push_back (TargetEntry ("PluginPresetPtr"));
@@ -244,15 +230,19 @@ Mixer_UI::Mixer_UI ()
        favorite_plugins_scroller.add (favorite_plugins_display);
        favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
 
-       favorite_plugins_sample.set_name ("BaseFrame");
-       favorite_plugins_sample.set_shadow_type (Gtk::SHADOW_IN);
-       favorite_plugins_sample.add (favorite_plugins_scroller);
+       favorite_plugins_frame.set_name ("BaseFrame");
+       favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
+       favorite_plugins_frame.add (favorite_plugins_vbox);
 
-       rhs_pane1.add (favorite_plugins_sample);
-       rhs_pane1.add (track_display_sample);
+       favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
+       favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
+       favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
+
+       rhs_pane1.add (favorite_plugins_frame);
+       rhs_pane1.add (track_display_frame);
 
        rhs_pane2.add (rhs_pane1);
-       rhs_pane2.add (group_display_sample);
+       rhs_pane2.add (group_display_frame);
 
        list_vpacker.pack_start (rhs_pane2, true, true);
 
@@ -262,7 +252,6 @@ Mixer_UI::Mixer_UI ()
        vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
        vca_scroller_base.set_name (X_("MixerWindow"));
        vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
-       vca_hpacker.pack_end (vca_scroller_base, true, true);
 
        vca_scroller.add (vca_hpacker);
        vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
@@ -279,7 +268,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;
@@ -313,10 +302,6 @@ Mixer_UI::Mixer_UI ()
 
        update_title ();
 
-       route_group_display_button_box->show();
-       route_group_add_button->show();
-       route_group_remove_button->show();
-
        _content.show ();
        _content.set_name ("MixerWindow");
 
@@ -327,12 +312,11 @@ 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();
-       group_display_sample.show();
-       favorite_plugins_sample.show();
+       group_display_frame.show();
+       favorite_plugins_frame.show();
        rhs_pane1.show();
        rhs_pane2.show();
        strip_packer.show();
@@ -360,8 +344,8 @@ Mixer_UI::Mixer_UI ()
 #else
 #error implement deferred Plugin-Favorite list
 #endif
-       PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
-       PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
+
+       PluginManager::instance ().PluginListChanged.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());
 }
 
@@ -381,6 +365,12 @@ Mixer_UI::escape ()
        select_none ();
 }
 
+void
+Mixer_UI::tag_combo_changed ()
+{
+       refill_favorite_plugins();
+}
+
 Gtk::Window*
 Mixer_UI::use_own_window (bool and_fill_it)
 {
@@ -826,7 +816,7 @@ Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_chan
                        }
                }
 
-               if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll ()) {
+               if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
                        move_stripable_into_view ((*_selection.axes.begin())->stripable());
                }
 
@@ -918,6 +908,17 @@ struct MixerStripSorter {
 bool
 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
 {
+       /* Selecting a mixer-strip may also select grouped-tracks, and
+        * presentation_info_changed() being emitted and
+        * _selection.axes.begin() is being moved into view. This may
+        * effectively move the track that was clicked-on out of view.
+        *
+        * So here only the track that is actually clicked-on is moved into
+        * view (in case it's partially visible)
+        */
+       PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
+       move_stripable_into_view (strip->stripable());
+
        if (ev->button == 1) {
                if (_selection.selected (strip)) {
                        /* primary-click: toggle selection state of strip */
@@ -1024,6 +1025,7 @@ Mixer_UI::set_session (Session* sess)
        }
 
        refill_favorite_plugins();
+       refill_tag_combo();
 
        XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
        set_state (*node, 0);
@@ -1433,8 +1435,20 @@ Mixer_UI::redisplay_track_list ()
        uint32_t n_masters = 0;
 
        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);
 
+       add_vca_button->show ();
+       vca_scroller_base.show();
+       
        for (i = rows.begin(); i != rows.end(); ++i) {
 
                AxisView* s = (*i)[stripable_columns.strip];
@@ -2348,22 +2362,12 @@ Mixer_UI::setup_track_display ()
        v->show ();
        v->pack_start (track_display_scroller, true, true);
 
-       Button* b = manage (new Button);
-       b->show ();
-       Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
-       w->show ();
-       b->add (*w);
-
-       b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
-
-       v->pack_start (*b, false, false);
-
-       track_display_sample.set_name("BaseFrame");
-       track_display_sample.set_shadow_type (Gtk::SHADOW_IN);
-       track_display_sample.add (*v);
+       track_display_frame.set_name("BaseFrame");
+       track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
+       track_display_frame.add (*v);
 
        track_display_scroller.show();
-       track_display_sample.show();
+       track_display_frame.show();
        track_display.show();
 }
 
@@ -2561,9 +2565,24 @@ Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
 {
        PluginManager& manager (PluginManager::instance());
        for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
+
+               /* not a Favorite? skip it */
                if (manager.get_status (*i) != PluginManager::Favorite) {
                        continue;
                }
+
+               /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
+               string test = favorite_plugins_tag_combo.get_active_text();
+               if (test != _("Show All")) {
+                       vector<string> tags = manager.get_tags(*i);
+
+                       //does the selected tag match any of the tags in the plugin?
+                       vector<string>::iterator tt =  find (tags.begin(), tags.end(), test);
+                       if (tt == tags.end()) {
+                               continue;
+                       }
+               }
+
                result.push_back (*i);
        }
 }
@@ -2626,6 +2645,30 @@ Mixer_UI::refill_favorite_plugins ()
        sync_treeview_from_favorite_order ();
 }
 
+void
+Mixer_UI::plugin_list_changed ()
+{
+       refill_favorite_plugins();
+       refill_tag_combo();
+}
+
+void
+Mixer_UI::refill_tag_combo ()
+{
+       PluginManager& mgr (PluginManager::instance());
+
+       std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
+
+       favorite_plugins_tag_combo.clear();
+       favorite_plugins_tag_combo.append_text (_("Show All"));
+
+       for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
+               favorite_plugins_tag_combo.append_text (*t);
+       }
+
+       favorite_plugins_tag_combo.set_active_text (_("Show All"));
+}
+
 void
 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
 {
@@ -2712,7 +2755,7 @@ Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
 bool
 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
 {
-       if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
+       if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
                TreeModel::Path path;
                TreeViewColumn* column;
                int cellx, celly;