Add "Description" pane to generic plugin UI for LV2 plugins with documentation (rdfs...
[ardour.git] / gtk2_ardour / plugin_ui.cc
index f7410bba3c2e5c38975232ae06ce9eb33ad86df0..9357fc7136ce5bb919fcce785e3ceb72b5afd3ba 100644 (file)
@@ -46,9 +46,9 @@
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
 #include "ardour/ladspa_plugin.h"
-#ifdef VST_SUPPORT
-#include "ardour/vst_plugin.h"
-#include "vst_pluginui.h"
+#ifdef WINDOWS_VST_SUPPORT
+#include "ardour/windows_vst_plugin.h"
+#include "windows_vst_plugin_ui.h"
 #endif
 #ifdef LXVST_SUPPORT
 #include "ardour/lxvst_plugin.h"
@@ -99,8 +99,8 @@ PluginUIWindow::PluginUIWindow (
                  << " editor: " << editor << std::endl;
        if (editor && insert->plugin()->has_editor()) {
                switch (insert->type()) {
-               case ARDOUR::VST:
-                       have_gui = create_vst_editor (insert);
+               case ARDOUR::Windows_VST:
+                       have_gui = create_windows_vst_editor (insert);
                        break;
                        
                case ARDOUR::LXVST:
@@ -120,7 +120,7 @@ PluginUIWindow::PluginUIWindow (
                        break;
 
                default:
-#ifndef VST_SUPPORT
+#ifndef WINDOWS_VST_SUPPORT
                        error << _("unknown type of editor-supplying plugin (note: no VST support in this version of ardour)")
                              << endmsg;
 #else
@@ -156,14 +156,10 @@ PluginUIWindow::PluginUIWindow (
 
        if (scrollable) {
                if (h > 600) h = 600;
-               if (w > 600) w = 600;
-
-               if (w < 0) {
-                       w = 450;
-               }
        }
 
        set_default_size (w, h);
+       set_resizable (_pluginui->resizable());
 }
 
 PluginUIWindow::~PluginUIWindow ()
@@ -253,24 +249,24 @@ PluginUIWindow::set_title(const std::string& title)
 }
 
 bool
-#ifdef VST_SUPPORT
-PluginUIWindow::create_vst_editor(boost::shared_ptr<PluginInsert> insert)
+#ifdef WINDOWS_VST_SUPPORT
+PluginUIWindow::create_windows_vst_editor(boost::shared_ptr<PluginInsert> insert)
 #else
-PluginUIWindow::create_vst_editor(boost::shared_ptr<PluginInsert>)
+PluginUIWindow::create_windows_vst_editor(boost::shared_ptr<PluginInsert>)
 #endif
 {
-#ifndef VST_SUPPORT
+#ifndef WINDOWS_VST_SUPPORT
        return false;
 #else
 
-       boost::shared_ptr<VSTPlugin> vp;
+       boost::shared_ptr<WindowsVSTPlugin> vp;
 
-       if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (insert->plugin())) == 0) {
+       if ((vp = boost::dynamic_pointer_cast<WindowsVSTPlugin> (insert->plugin())) == 0) {
                error << _("unknown type of editor-supplying plugin (note: no VST support in this version of ardour)")
                              << endmsg;
                throw failed_constructor ();
        } else {
-               VSTPluginUI* vpu = new VSTPluginUI (insert, vp);
+               WindowsVSTPluginUI* vpu = new WindowsVSTPluginUI (insert, vp);
 
                _pluginui = vpu;
                _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused));
@@ -313,13 +309,13 @@ PluginUIWindow::create_lxvst_editor(boost::shared_ptr<PluginInsert>)
 }
 
 bool
-#ifdef GTKOSX
+#ifdef AUDIOUNIT_SUPPORT
 PluginUIWindow::create_audiounit_editor (boost::shared_ptr<PluginInsert> insert)
 #else
 PluginUIWindow::create_audiounit_editor (boost::shared_ptr<PluginInsert>)
 #endif
 {
-#ifndef GTKOSX
+#ifndef AUDIOUNIT_SUPPORT
        return false;
 #else
        VBox* box;
@@ -340,7 +336,7 @@ PluginUIWindow::app_activated (bool yn)
 PluginUIWindow::app_activated (bool)
 #endif
 {
-#ifdef GTKOSX
+#ifdef AUDIOUNIT_SUPPORT
        if (_pluginui) {
                if (yn) {
                        if (was_visible) {
@@ -456,12 +452,12 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
        , save_button (_("Save"))
        , delete_button (_("Delete"))
        , bypass_button (ArdourButton::led_default_elements)
+       , description_expander (_("Description"))
+       , plugin_analysis_expander (_("Plugin analysis"))
        , latency_gui (0)
        , latency_dialog (0)
-       , plugin_analysis_expander (_("Plugin analysis"))
        , eqgui (0)
 {
-       _preset_combo.set_size_request (100, -1);
        _preset_modified.set_size_request (16, -1);
        _preset_combo.signal_changed().connect(sigc::mem_fun(*this, &PlugUIBase::preset_selected));
        ARDOUR_UI::instance()->set_tip (_preset_combo, _("Presets (if any) for this plugin\n(Both factory and user-created)"));
@@ -471,9 +467,6 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
        ARDOUR_UI::instance()->set_tip (bypass_button, _("Disable signal processing by the plugin"));
        _no_load_preset = 0;
 
-       _preset_box.pack_start (_preset_combo);
-       _preset_box.pack_start (_preset_modified);
-
        update_preset_list ();
        update_preset ();
 
@@ -490,13 +483,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
 
        bypass_button.set_name ("plugin bypass button");
        bypass_button.set_text (_("Bypass"));
-
-       if (!pi->active()) {
-               bypass_button.set_active_state (Gtkmm2ext::Active);
-       } else {
-               bypass_button.unset_active_state ();
-       }
-
+       bypass_button.set_active (!pi->active());
        bypass_button.signal_button_release_event().connect (sigc::mem_fun(*this, &PlugUIBase::bypass_button_release));
        focus_button.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
 
@@ -513,6 +500,9 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
        ARDOUR_UI::instance()->set_tip (focus_button, string_compose (_("Click to allow the plugin to receive keyboard events that %1 would normally use as a shortcut"), PROGRAM_NAME));
        ARDOUR_UI::instance()->set_tip (bypass_button, _("Click to enable/disable this plugin"));
 
+       description_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &PlugUIBase::toggle_description));
+       description_expander.set_expanded(false);
+
        plugin_analysis_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &PlugUIBase::toggle_plugin_analysis));
        plugin_analysis_expander.set_expanded(false);
 
@@ -576,11 +566,7 @@ PlugUIBase::processor_active_changed (boost::weak_ptr<Processor> weak_p)
        boost::shared_ptr<Processor> p (weak_p.lock());
 
        if (p) {
-               if (!p->active()) {
-                       bypass_button.set_active_state (Gtkmm2ext::Active);
-               } else {
-                       bypass_button.unset_active_state ();
-               }
+               bypass_button.set_active (!p->active());
        }
 }
 
@@ -680,11 +666,34 @@ PlugUIBase::focus_toggled (GdkEventButton*)
        return true;
 }
 
+void
+PlugUIBase::toggle_description()
+{
+       if (description_expander.get_expanded() &&
+           !description_expander.get_child()) {
+               const std::string text = plugin->get_docs();
+               if (text.empty()) {
+                       return;
+               }
+
+               Gtk::Label* label = manage(new Gtk::Label(text));
+               label->set_line_wrap(true);
+               label->set_line_wrap_mode(Pango::WRAP_WORD);
+               description_expander.add(*label);
+               description_expander.show_all();
+       }
+       
+       if (!description_expander.get_expanded()) {
+               description_expander.remove();
+       }
+}
+
+
 void
 PlugUIBase::toggle_plugin_analysis()
 {
        if (plugin_analysis_expander.get_expanded() &&
-            !plugin_analysis_expander.get_child()) {
+           !plugin_analysis_expander.get_child()) {
                // Create the GUI
                if (eqgui == 0) {
                        eqgui = new PluginEqGui (insert);
@@ -702,7 +711,6 @@ PlugUIBase::toggle_plugin_analysis()
        }
 
        if (!plugin_analysis_expander.get_expanded()) {
-
                // Hide & remove from expander
 
                eqgui->hide ();