2 Copyright (C) 2000-2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/vst_plugin.h"
22 #include "ardour/vst_types.h"
23 #include "vst_plugin_ui.h"
25 #ifdef PLATFORM_WINDOWS
26 #include <gdk/gdkwin32.h>
27 #elif defined __APPLE__
33 VSTPluginUI::VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> insert, boost::shared_ptr<ARDOUR::VSTPlugin> plugin)
37 Gtk::HBox* box = manage (new Gtk::HBox);
39 box->set_border_width (6);
40 box->pack_end (focus_button, false, false);
41 box->pack_end (bypass_button, false, false, 10);
42 box->pack_end (delete_button, false, false);
43 box->pack_end (save_button, false, false);
44 box->pack_end (add_button, false, false);
45 box->pack_end (_preset_combo, false, false);
47 bypass_button.set_active (!insert->active ());
49 pack_start (*box, false, false);
50 #ifdef GDK_WINDOWING_X11
51 pack_start (_socket, true, true);
52 _socket.set_border_width (0);
56 VSTPluginUI::~VSTPluginUI ()
62 VSTPluginUI::preset_selected ()
64 #ifdef GDK_WINDOWING_X11
65 _socket.grab_focus ();
67 PlugUIBase::preset_selected ();
71 VSTPluginUI::get_preferred_height ()
73 return _vst->state()->height + _vst->state()->voffset;
77 VSTPluginUI::get_preferred_width ()
79 return _vst->state()->width + _vst->state()->hoffset;
83 VSTPluginUI::package (Gtk::Window& win)
85 #ifdef GDK_WINDOWING_X11
86 /* Forward configure events to plugin window */
87 win.signal_configure_event().connect (sigc::mem_fun (*this, &VSTPluginUI::configure_handler), false);
89 /* This assumes that the window's owner understands the XEmbed protocol */
90 _socket.add_id (get_XID ());
91 _socket.set_size_request(
92 _vst->state()->width + _vst->state()->hoffset,
93 _vst->state()->height + _vst->state()->voffset);
100 VSTPluginUI::on_window_show(const std::string& title)
102 _vst->state()->gui_shown = 1;
103 return PlugUIBase::on_window_show(title);
107 VSTPluginUI::on_window_hide()
109 _vst->state()->gui_shown = 0;
110 PlugUIBase::on_window_hide();
115 VSTPluginUI::configure_handler (GdkEventConfigure*)
117 #ifdef GDK_WINDOWING_X11
122 if ((w = _socket.gobj()->plug_window) == 0) {
126 event.xconfigure.type = ConfigureNotify;
127 event.xconfigure.event = GDK_WINDOW_XWINDOW (w);
128 event.xconfigure.window = GDK_WINDOW_XWINDOW (w);
130 /* The ICCCM says that synthetic events should have root relative
131 * coordinates. We still aren't really ICCCM compliant, since
132 * we don't send events when the real toplevel is moved.
134 gdk_error_trap_push ();
135 gdk_window_get_origin (w, &x, &y);
136 gdk_error_trap_pop ();
138 event.xconfigure.x = x;
139 event.xconfigure.y = y;
140 event.xconfigure.width = GTK_WIDGET (_socket.gobj())->allocation.width;
141 event.xconfigure.height = GTK_WIDGET (_socket.gobj())->allocation.height;
143 event.xconfigure.border_width = 0;
144 event.xconfigure.above = None;
145 event.xconfigure.override_redirect = False;
147 gdk_error_trap_push ();
148 XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event);
149 gdk_error_trap_pop ();