Merge some linux/windows VST GUI code.
git-svn-id: svn://localhost/ardour2/branches/3.0@10783 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
efe14fbd52
commit
aed44005b2
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "gtkmm2ext/barcontroller.h"
|
||||
#include "pbd/signals.h"
|
||||
#include "evoral/Parameter.hpp"
|
||||
|
||||
namespace ARDOUR {
|
||||
class Session;
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
#ifndef __lxvst_plugin_ui_h__
|
||||
#define __lxvst_plugin_ui_h__
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <sigc++/signal.h>
|
||||
#include <gtkmm/widget.h>
|
||||
|
||||
#include <ardour_dialog.h>
|
||||
#include <ardour/types.h>
|
||||
#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<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::LXVSTPlugin>);
|
||||
LXVSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
|
||||
~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:
|
||||
void resize_callback ();
|
||||
int get_XID ();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<ARDOUR::LXVSTPlugin> 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<Glib::ustring> name;
|
||||
Gtk::TreeModelColumn<int> number;
|
||||
};
|
||||
|
||||
PresetModelColumns preset_columns;
|
||||
Glib::RefPtr<Gtk::ListStore> preset_model;
|
||||
Gtk::ComboBox lxvst_preset_combo;
|
||||
|
||||
void create_preset_store ();
|
||||
void preset_chosen ();
|
||||
void preset_selected ();
|
||||
void resize_callback();
|
||||
};
|
||||
|
||||
#endif //LXVST_SUPPORT
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <gtkmm/socket.h>
|
||||
|
||||
#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 {
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -31,25 +31,11 @@ using namespace Gtk;
|
|||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<WindowsVSTPlugin> vp)
|
||||
: PlugUIBase (pi),
|
||||
vst (vp)
|
||||
WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<VSTPlugin> 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)
|
||||
{
|
||||
XEvent event;
|
||||
gint x, y;
|
||||
GdkWindow* w;
|
||||
|
||||
if (socket == 0 || ((w = socket->gobj()->plug_window) == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
gdk_error_trap_push ();
|
||||
XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event);
|
||||
gdk_error_trap_pop ();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev)
|
||||
{
|
||||
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);
|
||||
if (ev->type != GDK_KEY_PRESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int
|
||||
WindowsVSTPluginUI::get_XID ()
|
||||
{
|
||||
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");
|
||||
|
|
|
@ -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<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::WindowsVSTPlugin>);
|
||||
public:
|
||||
WindowsVSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
|
||||
~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<ARDOUR::WindowsVSTPlugin> 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 ();
|
||||
|
||||
};
|
||||
|
|
|
@ -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' ]
|
||||
|
|
|
@ -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 *);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -661,12 +661,6 @@ fst_close (VSTState* fst)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
fst_get_XID (VSTState* fst)
|
||||
{
|
||||
return fst->xid;
|
||||
}
|
||||
|
||||
float htonf (float v)
|
||||
{
|
||||
float result;
|
||||
|
|
Loading…
Reference in New Issue
Block a user