a-fluidsynth: implement LV2_BANKPATCH__notify
[ardour.git] / gtk2_ardour / plugin_ui.cc
index 19ea8ebc6c0c178c340b87dd58f667067fe1d6bc..011151e29b3c668d21edb54173d0be6e81d5c12a 100644 (file)
 #include "pbd/xml++.h"
 #include "pbd/failed_constructor.h"
 
-#include <gtkmm/widget.h>
-#include <gtkmm/box.h>
-#include <gtkmm2ext/click_box.h>
-#include <gtkmm2ext/fastmeter.h>
-#include <gtkmm2ext/barcontroller.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/doi.h>
-#include <gtkmm2ext/slider_controller.h>
-#include <gtkmm2ext/application.h>
+#include "gtkmm/widget.h"
+#include "gtkmm/box.h"
+
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/application.h"
+
+#include "widgets/tooltips.h"
+#include "widgets/fastmeter.h"
 
 #include "ardour/session.h"
 #include "ardour/plugin.h"
 #include "ardour/lxvst_plugin.h"
 #include "lxvst_plugin_ui.h"
 #endif
+#ifdef MACVST_SUPPORT
+#include "ardour/mac_vst_plugin.h"
+#include "vst_plugin_ui.h"
+#endif
 #ifdef LV2_SUPPORT
 #include "ardour/lv2_plugin.h"
 #include "lv2_plugin_ui.h"
@@ -59,7 +63,6 @@
 
 #include "ardour_window.h"
 #include "ardour_ui.h"
-#include "prompter.h"
 #include "plugin_ui.h"
 #include "utils.h"
 #include "gui_thread.h"
 #include "latency_gui.h"
 #include "plugin_eq_gui.h"
 #include "new_plugin_preset_dialog.h"
-#include "tooltips.h"
 
 #include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
 using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
@@ -88,8 +91,8 @@ PluginUIWindow::PluginUIWindow (
        , was_visible (false)
        , _keyboard_focused (false)
 #ifdef AUDIOUNIT_SUPPORT
-        , pre_deactivate_x (-1)
-        , pre_deactivate_y (-1)
+       , pre_deactivate_x (-1)
+       , pre_deactivate_y (-1)
 #endif
 
 {
@@ -107,6 +110,10 @@ PluginUIWindow::PluginUIWindow (
                        have_gui = create_lxvst_editor (insert);
                        break;
 
+               case ARDOUR::MacVST:
+                       have_gui = create_mac_vst_editor (insert);
+                       break;
+
                case ARDOUR::AudioUnit:
                        have_gui = create_audiounit_editor (insert);
                        break;
@@ -180,9 +187,9 @@ PluginUIWindow::on_show ()
 
        if (_pluginui) {
 #if defined (HAVE_AUDIOUNITS) && defined(__APPLE__)
-                if (pre_deactivate_x >= 0) {
-                        move (pre_deactivate_x, pre_deactivate_y);
-                }
+               if (pre_deactivate_x >= 0) {
+                       move (pre_deactivate_x, pre_deactivate_y);
+               }
 #endif
 
                if (_pluginui->on_window_show (_title)) {
@@ -195,7 +202,7 @@ void
 PluginUIWindow::on_hide ()
 {
 #if defined (HAVE_AUDIOUNITS) && defined(__APPLE__)
-        get_position (pre_deactivate_x, pre_deactivate_y);
+       get_position (pre_deactivate_x, pre_deactivate_y);
 #endif
 
        Window::on_hide ();
@@ -272,6 +279,35 @@ PluginUIWindow::create_lxvst_editor(boost::shared_ptr<PluginInsert>)
 #endif
 }
 
+bool
+#ifdef MACVST_SUPPORT
+PluginUIWindow::create_mac_vst_editor (boost::shared_ptr<PluginInsert> insert)
+#else
+PluginUIWindow::create_mac_vst_editor (boost::shared_ptr<PluginInsert>)
+#endif
+{
+#ifndef MACVST_SUPPORT
+       return false;
+#else
+       boost::shared_ptr<MacVSTPlugin> mvst;
+       if ((mvst = boost::dynamic_pointer_cast<MacVSTPlugin> (insert->plugin())) == 0) {
+               error << string_compose (_("unknown type of editor-supplying plugin (note: no MacVST support in this version of %1)"), PROGRAM_NAME)
+                     << endmsg;
+               throw failed_constructor ();
+       }
+       VSTPluginUI* vpu = create_mac_vst_gui (insert);
+       _pluginui = vpu;
+       _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused));
+       add (*vpu);
+       vpu->package (*this);
+
+       Application::instance()->ActivationChanged.connect (mem_fun (*this, &PluginUIWindow::app_activated));
+
+       return true;
+#endif
+}
+
+
 bool
 #ifdef AUDIOUNIT_SUPPORT
 PluginUIWindow::create_audiounit_editor (boost::shared_ptr<PluginInsert> insert)
@@ -305,15 +341,15 @@ PluginUIWindow::app_activated (bool)
                if (yn) {
                        if (was_visible) {
                                _pluginui->activate ();
-                                if (pre_deactivate_x >= 0) {
-                                        move (pre_deactivate_x, pre_deactivate_y);
-                                }
+                               if (pre_deactivate_x >= 0) {
+                                       move (pre_deactivate_x, pre_deactivate_y);
+                               }
                                present ();
                                was_visible = true;
                        }
                } else {
                        was_visible = is_visible();
-                        get_position (pre_deactivate_x, pre_deactivate_y);
+                       get_position (pre_deactivate_x, pre_deactivate_y);
                        hide ();
                        _pluginui->deactivate ();
                }
@@ -421,7 +457,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
        , delete_button (_("Delete"))
        , reset_button (_("Reset"))
        , bypass_button (ArdourButton::led_default_elements)
-       , pin_management_button (_("Pin Connections...")) // TODO use a shorter label once the string-freeze is over.
+       , pin_management_button (_("Pinout"))
        , description_expander (_("Description"))
        , plugin_analysis_expander (_("Plugin analysis"))
        , latency_gui (0)
@@ -435,9 +471,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
        set_tooltip (save_button, _("Save the current preset"));
        set_tooltip (delete_button, _("Delete the current preset"));
        set_tooltip (reset_button, _("Reset parameters to default (if no parameters are in automation play mode)"));
-#if 0 // string freeze is over
        set_tooltip (pin_management_button, _("Show Plugin Pin Management Dialog"));
-#endif
        set_tooltip (bypass_button, _("Disable signal processing by the plugin"));
        _no_load_preset = 0;