Add plugin tag-filter to Mixer-favorites sidebar
authorRobin Gareus <robin@gareus.org>
Mon, 29 Jan 2018 23:45:42 +0000 (00:45 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 30 Jan 2018 00:34:37 +0000 (01:34 +0100)
gtk2_ardour/mixer_ui.cc
gtk2_ardour/mixer_ui.h

index 0e067e6df84205be9e3f0d933f9bfae3002993da..daf0cf46b5628caa10db785c5f5d1069329b4a67 100644 (file)
@@ -247,7 +247,11 @@ Mixer_UI::Mixer_UI ()
 
        favorite_plugins_frame.set_name ("BaseFrame");
        favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
-       favorite_plugins_frame.add (favorite_plugins_scroller);
+       favorite_plugins_frame.add (favorite_plugins_vbox);
+
+       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);
@@ -362,8 +366,10 @@ Mixer_UI::Mixer_UI ()
 #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::plugin_status_changed, this, _1, _2, _3), gui_context());
+       PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_status_changed, this, _1, _2, _3), gui_context());
        ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
+
+       PluginManager::instance ().PluginTagsChanged.connect(*this, invalidator (*this), boost::bind (&Mixer_UI::tags_changed, this, _1, _2, _3), gui_context());
 }
 
 Mixer_UI::~Mixer_UI ()
@@ -382,6 +388,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)
 {
@@ -1036,6 +1048,7 @@ Mixer_UI::set_session (Session* sess)
        }
 
        refill_favorite_plugins();
+       refill_tag_combo();
 
        XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
        set_state (*node, 0);
@@ -2573,9 +2586,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);
        }
 }
@@ -2638,6 +2666,36 @@ Mixer_UI::refill_favorite_plugins ()
        sync_treeview_from_favorite_order ();
 }
 
+void
+Mixer_UI::plugin_status_changed (PluginType, std::string, PluginManager::PluginStatusType)
+{
+       refill_favorite_plugins();
+       refill_tag_combo();
+}
+
+void
+Mixer_UI::tags_changed (PluginType t, std::string unique_id, std::string tag)
+{
+       refill_tag_combo();
+}
+
+void
+Mixer_UI::refill_tag_combo ()
+{
+       PluginManager& mgr (PluginManager::instance());
+
+       std::vector<std::string> tags = mgr.get_all_tags (true);
+
+       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&)
 {
@@ -2724,7 +2782,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;
index 137913038ec65dedf78e591c44827f59f4848101..49e60c1b6ee3025b43ef44ec3cb72cbb76bc8e49 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtkmm/scrolledwindow.h>
 #include <gtkmm/eventbox.h>
 #include <gtkmm/label.h>
+#include <gtkmm/comboboxtext.h>
 #include <gtkmm/button.h>
 #include <gtkmm/frame.h>
 #include <gtkmm/menu.h>
@@ -154,6 +155,8 @@ private:
        Gtk::Frame            track_display_frame;
        Gtk::Frame            group_display_frame;
        Gtk::Frame            favorite_plugins_frame;
+       Gtk::VBox             favorite_plugins_vbox;
+       Gtk::ComboBoxText     favorite_plugins_tag_combo;
        ArdourWidgets::VPane  rhs_pane1;
        ArdourWidgets::VPane  rhs_pane2;
        ArdourWidgets::HPane  inner_pane;
@@ -365,7 +368,13 @@ private:
 
        void store_current_favorite_order();
        void refiller (ARDOUR::PluginInfoList& result, const ARDOUR::PluginInfoList& plugs);
+       void plugin_status_changed (ARDOUR::PluginType t, std::string unique_id, ARDOUR::PluginManager::PluginStatusType s);
        void refill_favorite_plugins ();
+
+       void refill_tag_combo ();
+       void tags_changed (ARDOUR::PluginType t, std::string unique_id, std::string tag);
+       void tag_combo_changed ();
+
        void sync_treeview_from_favorite_order ();
        void sync_treeview_favorite_ui_state (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
        void save_favorite_ui_state (const Gtk::TreeModel::iterator& iter, const Gtk::TreeModel::Path& path);