Add API to check for plugin-presets with description
authorRobin Gareus <robin@gareus.org>
Thu, 10 Oct 2019 20:31:19 +0000 (22:31 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 10 Oct 2019 20:31:19 +0000 (22:31 +0200)
gtk2_ardour/generic_pluginui.cc
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h

index 8a5207da73ca763339161d1306fd5e26253ca897..1fbe2278a8392a40fa2b0a531a567765998c4194 100644 (file)
@@ -424,15 +424,7 @@ GenericPluginUI::build ()
        }
 
        if (control_uis.empty ()) {
-               std::vector<Plugin::PresetRecord> presets = insert->plugin()->get_presets();
-               bool show_preset_browser = false;
-               for (std::vector<Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
-                       if (i->valid && !i->description.empty()) {
-                               show_preset_browser = true;
-                               break;
-                       }
-               }
-               if (show_preset_browser) {
+               if (has_descriptive_presets ()) {
                        preset_gui = new PluginPresetsUI (insert);
                        hpacker.pack_start (*preset_gui, true, true);
                }
index a5962c140f465791bcb6020e36873c480977ad01..5d0f2606152452fd70a28878e4c23441c545f3b9 100644 (file)
@@ -685,6 +685,18 @@ PlugUIBase::reset_plugin_parameters ()
        insert->reset_parameters_to_default ();
 }
 
+bool
+PlugUIBase::has_descriptive_presets () const
+{
+       std::vector<Plugin::PresetRecord> presets = insert->plugin()->get_presets();
+       for (std::vector<Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
+               if (i->valid && !i->description.empty()) {
+                       return true;
+               }
+       }
+       return false;
+}
+
 void
 PlugUIBase::manage_pins ()
 {
index 185b08a9f3c13d0ca114ededf41ab55848fbf051..08be65f2d4defbf2d550e081b7fcd98168ec4407 100644 (file)
@@ -188,6 +188,8 @@ protected:
        void preset_added_or_removed ();
        void update_preset_modified ();
 
+       bool has_descriptive_presets () const;
+
        PBD::ScopedConnection death_connection;
        PBD::ScopedConnection active_connection;
        PBD::ScopedConnection preset_added_connection;