From aed44005b26eb359025b33f10c8d588ab732d096 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 23 Nov 2011 00:55:25 +0000 Subject: Merge some linux/windows VST GUI code. git-svn-id: svn://localhost/ardour2/branches/3.0@10783 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_controller.h | 1 + gtk2_ardour/lxvst_plugin_ui.h | 55 +++-------- gtk2_ardour/plugin_ui.h | 2 + gtk2_ardour/vstfxwin.cc | 52 ----------- gtk2_ardour/windows_vst_plugin_ui.cc | 173 +++++++++++------------------------ gtk2_ardour/windows_vst_plugin_ui.h | 28 +++--- gtk2_ardour/wscript | 5 +- libs/ardour/ardour/vstfx.h | 2 - libs/fst/fst.h | 1 - libs/fst/vstwin.c | 6 -- 10 files changed, 82 insertions(+), 243 deletions(-) diff --git a/gtk2_ardour/automation_controller.h b/gtk2_ardour/automation_controller.h index bb1c0d443c..0392d8c9a4 100644 --- a/gtk2_ardour/automation_controller.h +++ b/gtk2_ardour/automation_controller.h @@ -26,6 +26,7 @@ #include "gtkmm2ext/barcontroller.h" #include "pbd/signals.h" +#include "evoral/Parameter.hpp" namespace ARDOUR { class Session; diff --git a/gtk2_ardour/lxvst_plugin_ui.h b/gtk2_ardour/lxvst_plugin_ui.h index fc46ede8a3..5ddc68e33e 100755 --- a/gtk2_ardour/lxvst_plugin_ui.h +++ b/gtk2_ardour/lxvst_plugin_ui.h @@ -1,16 +1,8 @@ #ifndef __lxvst_plugin_ui_h__ #define __lxvst_plugin_ui_h__ -#include -#include -#include - #include -#include - -#include -#include -#include "plugin_ui.h" +#include "vst_plugin_ui.h" #ifdef LXVST_SUPPORT @@ -19,49 +11,26 @@ namespace ARDOUR { class LXVSTPlugin; } -class LXVSTPluginUI : public PlugUIBase, public Gtk::VBox +class LXVSTPluginUI : public VSTPluginUI { public: - LXVSTPluginUI (boost::shared_ptr, boost::shared_ptr); + LXVSTPluginUI (boost::shared_ptr, boost::shared_ptr); ~LXVSTPluginUI (); - gint get_preferred_height (); - gint get_preferred_width (); - bool start_updating(GdkEventAny*); - bool stop_updating(GdkEventAny*); + int get_preferred_height (); + + bool start_updating (GdkEventAny *); + bool stop_updating (GdkEventAny *); int package (Gtk::Window&); void forward_key_event (GdkEventKey *); - bool non_gtk_gui() const { return true; } + bool non_gtk_gui () const { return true; } - private: - boost::shared_ptr lxvst; - Gtk::Socket socket; - Gtk::HBox preset_box; - Gtk::VBox vpacker; - - sigc::connection _screen_update_connection; - - bool configure_handler (GdkEventConfigure*, Gtk::Socket*); - void save_plugin_setting (); - - struct PresetModelColumns : public Gtk::TreeModel::ColumnRecord { - PresetModelColumns() { - add (name); - add (number); - } - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn number; - }; +private: + void resize_callback (); + int get_XID (); - PresetModelColumns preset_columns; - Glib::RefPtr preset_model; - Gtk::ComboBox lxvst_preset_combo; - - void create_preset_store (); - void preset_chosen (); - void preset_selected (); - void resize_callback(); + sigc::connection _screen_update_connection; }; #endif //LXVST_SUPPORT diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 95be14ceee..587001fcfe 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -46,6 +46,7 @@ #include #include "ardour/types.h" +#include "ardour/plugin.h" #include "automation_controller.h" #include "ardour_button.h" @@ -57,6 +58,7 @@ namespace ARDOUR { class LXVSTPlugin; class IOProcessor; class AUPlugin; + class Processor; } namespace PBD { diff --git a/gtk2_ardour/vstfxwin.cc b/gtk2_ardour/vstfxwin.cc index 526bd68daa..c8c11a1809 100755 --- a/gtk2_ardour/vstfxwin.cc +++ b/gtk2_ardour/vstfxwin.cc @@ -712,18 +712,6 @@ vstfx_launch_editor (VSTState* vstfx) return 0; } -/*May not be needed in the XLib version*/ - -void -vstfx_move_window_into_view (VSTState* vstfx) -{ - /* This is probably the equivalent of Mapping an XWindow - but we most likely don't need it because the window - will be Mapped by XReparentWindow - */ - -} - /** Destroy the editor window */ void vstfx_destroy_editor (VSTState* vstfx) @@ -764,46 +752,6 @@ vstfx_event_loop_remove_plugin (VSTState* vstfx) } } -/*Get the XID of the plugin editor window*/ - -int -vstfx_get_XID (VSTState* vstfx) -{ - int id; - - /* Wait for the lock to become free - otherwise - the window might be in the process of being - created and we get bad Window errors when trying - to embed it in the GTK UI - */ - - pthread_mutex_lock(&vstfx->lock); - - /* The Window may be scheduled for creation - but not actually created by the gui_event_loop yet - - spin here until it has been activated. Possible - deadlock if the window never gets activated but - should not be called here if the window doesn't - exist or will never exist - */ - - while (!(vstfx->been_activated)) { - usleep (1000); - } - - id = vstfx->xid; - - pthread_mutex_unlock (&vstfx->lock); - - /* Finally it might be safe to return the ID - - problems will arise if we return either a zero ID - and GTK tries to socket it or if we return an ID - which hasn't yet become real to the server - */ - - return id; -} - float htonf (float v) { diff --git a/gtk2_ardour/windows_vst_plugin_ui.cc b/gtk2_ardour/windows_vst_plugin_ui.cc index 3c80951ff0..6288ba50e1 100644 --- a/gtk2_ardour/windows_vst_plugin_ui.cc +++ b/gtk2_ardour/windows_vst_plugin_ui.cc @@ -31,25 +31,11 @@ using namespace Gtk; using namespace ARDOUR; using namespace PBD; -WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr pi, boost::shared_ptr vp) - : PlugUIBase (pi), - vst (vp) +WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr pi, boost::shared_ptr vp) + : VSTPluginUI (pi, vp) { - fst_run_editor (vst->state()); + fst_run_editor (_vst->state()); - preset_box.set_spacing (6); - preset_box.set_border_width (6); - preset_box.pack_end (focus_button, false, false); - preset_box.pack_end (bypass_button, false, false, 10); - preset_box.pack_end (delete_button, false, false); - preset_box.pack_end (save_button, false, false); - preset_box.pack_end (add_button, false, false); - preset_box.pack_end (_preset_box, false, false); - - bypass_button.set_active (!insert->active()); - - pack_start (preset_box, false, false); - pack_start (socket, true, true); pack_start (plugin_analysis_expander, true, true); } @@ -59,126 +45,71 @@ WindowsVSTPluginUI::~WindowsVSTPluginUI () // and then our PluginUIWindow does the rest } -void -WindowsVSTPluginUI::preset_selected () -{ - socket.grab_focus (); - PlugUIBase::preset_selected (); -} - -int -WindowsVSTPluginUI::get_preferred_height () -{ - return vst->state()->height; -} - -int -WindowsVSTPluginUI::get_preferred_width () -{ - return vst->state()->width; -} - int WindowsVSTPluginUI::package (Gtk::Window& win) { - /* forward configure events to plugin window */ + VSTPluginUI::package (win); - win.signal_configure_event().connect (sigc::bind (sigc::mem_fun (*this, &WindowsVSTPluginUI::configure_handler), &socket), false); + /* This assumes that the window's owner understands the XEmbed protocol */ - /* - this assumes that the window's owner understands the XEmbed protocol. - */ + _socket.add_id (fst_get_XID (_vst->state ())); - socket.add_id (fst_get_XID (vst->state ())); - - fst_move_window_into_view (vst->state ()); + fst_move_window_into_view (_vst->state ()); return 0; } -bool -WindowsVSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket) +void +WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev) { - XEvent event; - gint x, y; - GdkWindow* w; - - if (socket == 0 || ((w = socket->gobj()->plug_window) == 0)) { - return false; + if (ev->type != GDK_KEY_PRESS) { + return; } - event.xconfigure.type = ConfigureNotify; - event.xconfigure.event = GDK_WINDOW_XWINDOW (w); - event.xconfigure.window = GDK_WINDOW_XWINDOW (w); - - /* The ICCCM says that synthetic events should have root relative - * coordinates. We still aren't really ICCCM compliant, since - * we don't send events when the real toplevel is moved. - */ - gdk_error_trap_push (); - gdk_window_get_origin (w, &x, &y); - gdk_error_trap_pop (); - - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = GTK_WIDGET(socket->gobj())->allocation.width; - event.xconfigure.height = GTK_WIDGET(socket->gobj())->allocation.height; - - event.xconfigure.border_width = 0; - event.xconfigure.above = None; - event.xconfigure.override_redirect = False; + VSTState* fst = _vst->state (); + pthread_mutex_lock (&fst->lock); - gdk_error_trap_push (); - XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event); - gdk_error_trap_pop (); - - return false; + if (fst->n_pending_keys == (sizeof (fst->pending_keys) * sizeof (VSTKey))) { + /* buffer full */ + return; + } + + int special_windows_key = 0; + int character_windows_key = 0; + + switch (ev->keyval) { + case GDK_Left: + special_windows_key = 0x25; + break; + case GDK_Right: + special_windows_key = 0x27; + break; + case GDK_Up: + special_windows_key = 0x26; + break; + case GDK_Down: + special_windows_key = 0x28; + break; + case GDK_Return: + case GDK_KP_Enter: + special_windows_key = 0xd; + break; + default: + character_windows_key = ev->keyval; + break; + } + + fst->pending_keys[fst->n_pending_keys].special = special_windows_key; + fst->pending_keys[fst->n_pending_keys].character = character_windows_key; + fst->n_pending_keys++; + + pthread_mutex_unlock (&fst->lock); } -void -WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev) +int +WindowsVSTPluginUI::get_XID () { - if (ev->type == GDK_KEY_PRESS) { - - VSTState* fst = vst->state (); - pthread_mutex_lock (&fst->lock); - - if (fst->n_pending_keys == (sizeof (fst->pending_keys) * sizeof (VSTKey))) { - /* buffer full */ - return; - } - - int special_windows_key = 0; - int character_windows_key = 0; - - switch (ev->keyval) { - case GDK_Left: - special_windows_key = 0x25; - break; - case GDK_Right: - special_windows_key = 0x27; - break; - case GDK_Up: - special_windows_key = 0x26; - break; - case GDK_Down: - special_windows_key = 0x28; - break; - case GDK_Return: - case GDK_KP_Enter: - special_windows_key = 0xd; - break; - default: - character_windows_key = ev->keyval; - break; - } - - fst->pending_keys[fst->n_pending_keys].special = special_windows_key; - fst->pending_keys[fst->n_pending_keys].character = character_windows_key; - fst->n_pending_keys++; - - pthread_mutex_unlock (&fst->lock); - } + return _vst->state()->xid; } typedef int (*error_handler_t)( Display *, XErrorEvent *); @@ -187,7 +118,7 @@ static error_handler_t wine_error_handler; static error_handler_t gtk_error_handler; static int -fst_xerror_handler( Display *disp, XErrorEvent *ev ) +fst_xerror_handler (Display* disp, XErrorEvent* ev) { if (disp == the_gtk_display) { printf ("relaying error to gtk\n"); diff --git a/gtk2_ardour/windows_vst_plugin_ui.h b/gtk2_ardour/windows_vst_plugin_ui.h index 93b531f9dd..646d0c2993 100644 --- a/gtk2_ardour/windows_vst_plugin_ui.h +++ b/gtk2_ardour/windows_vst_plugin_ui.h @@ -17,31 +17,25 @@ */ -#include "plugin_ui.h" +#include "vst_plugin_ui.h" -class WindowsVSTPluginUI : public PlugUIBase, public Gtk::VBox +class WindowsVSTPluginUI : public VSTPluginUI { - public: - WindowsVSTPluginUI (boost::shared_ptr, boost::shared_ptr); +public: + WindowsVSTPluginUI (boost::shared_ptr, boost::shared_ptr); ~WindowsVSTPluginUI (); gint get_preferred_height (); gint get_preferred_width (); - bool start_updating(GdkEventAny*) {return false;} - bool stop_updating(GdkEventAny*) {return false;} + bool start_updating (GdkEventAny*) { return false; } + bool stop_updating (GdkEventAny*) { return false; } - int package (Gtk::Window&); + int package (Gtk::Window &); void forward_key_event (GdkEventKey *); - bool non_gtk_gui () const { return true; } - private: - boost::shared_ptr vst; - Gtk::Socket socket; - Gtk::HBox preset_box; - Gtk::VBox vpacker; - - bool configure_handler (GdkEventConfigure*, Gtk::Socket*); - void save_plugin_setting (); - void preset_selected (); +private: + + int get_XID (); + }; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 596776646c..65e1da5186 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -399,9 +399,12 @@ def build(bld): obj.uselib += ' X11 ' if bld.is_defined('LXVST_SUPPORT'): - obj.source += [ 'vstfxwin.cc', 'lxvst_pluginui.cc' ] + obj.source += [ 'vstfxwin.cc', 'lxvst_plugin_ui.cc' ] obj.defines += [ 'LXVST_SUPPORT' ] obj.uselib += ' X11 ' + + if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'): + obj.source += [ 'vst_plugin_ui.cc' ] if bld.is_defined('PHONE_HOME'): obj.defines += [ 'PHONE_HOME' ] diff --git a/libs/ardour/ardour/vstfx.h b/libs/ardour/ardour/vstfx.h index 0f8772230b..31f8bafe51 100755 --- a/libs/ardour/ardour/vstfx.h +++ b/libs/ardour/ardour/vstfx.h @@ -31,8 +31,6 @@ extern void vstfx_close (VSTState*); extern int vstfx_create_editor (VSTState *); extern int vstfx_run_editor (VSTState *); extern void vstfx_destroy_editor (VSTState *); -extern int vstfx_get_XID (VSTState *); -extern void vstfx_move_window_into_view (VSTState *); extern VSTInfo * vstfx_get_info (char *); extern void vstfx_free_info (VSTInfo *); diff --git a/libs/fst/fst.h b/libs/fst/fst.h index 5313f5ee03..ec36cf1360 100644 --- a/libs/fst/fst.h +++ b/libs/fst/fst.h @@ -44,7 +44,6 @@ extern void fst_close (VSTState *); extern int fst_create_editor (VSTState* fst); extern int fst_run_editor (VSTState *); extern void fst_destroy_editor (VSTState *); -extern int fst_get_XID (VSTState *); extern void fst_move_window_into_view (VSTState *); extern VSTInfo *fst_get_info (char *dllpathname); diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c index c175fcd823..e1132e5d94 100644 --- a/libs/fst/vstwin.c +++ b/libs/fst/vstwin.c @@ -661,12 +661,6 @@ fst_close (VSTState* fst) } } -int -fst_get_XID (VSTState* fst) -{ - return fst->xid; -} - float htonf (float v) { float result; -- cgit v1.2.3