2 Copyright (C) 2000-2006 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.
20 #ifndef __ardour_plugin_ui_h__
21 #define __ardour_plugin_ui_h__
24 #include "gtk2ardour-config.h"
31 #include <sigc++/signal.h>
33 #include <gtkmm/button.h>
34 #include <gtkmm/box.h>
35 #include <gtkmm/table.h>
36 #include <gtkmm/eventbox.h>
37 #include <gtkmm/viewport.h>
38 #include <gtkmm/scrolledwindow.h>
39 #include <gtkmm/label.h>
40 #include <gtkmm/menu.h>
41 #include <gtkmm/image.h>
42 #include <gtkmm/adjustment.h>
43 #include <gtkmm/togglebutton.h>
44 #include <gtkmm/socket.h>
45 #include <gtkmm/comboboxtext.h>
46 #include <gtkmm/socket.h>
48 #include "ardour/types.h"
49 #include "ardour/plugin.h"
51 #include "automation_controller.h"
52 #include "ardour_button.h"
53 #include "ardour_window.h"
58 class WindowsVSTPlugin;
70 class HSliderController;
81 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
84 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
85 virtual ~PlugUIBase();
87 virtual gint get_preferred_height () = 0;
88 virtual gint get_preferred_width () = 0;
89 virtual bool resizable () { return true; }
90 virtual bool start_updating(GdkEventAny*) = 0;
91 virtual bool stop_updating(GdkEventAny*) = 0;
93 virtual void activate () {}
94 virtual void deactivate () {}
96 void update_preset_list ();
97 void update_preset ();
99 void latency_button_clicked ();
101 virtual bool on_window_show(const std::string& /*title*/) { return true; }
102 virtual void on_window_hide() {}
104 virtual void forward_key_event (GdkEventKey*) {}
105 virtual bool non_gtk_gui() const { return false; }
107 sigc::signal<void,bool> KeyboardFocused;
110 boost::shared_ptr<ARDOUR::PluginInsert> insert;
111 boost::shared_ptr<ARDOUR::Plugin> plugin;
113 /* UI elements that can subclasses can add to their widgets */
115 /** a ComboBoxText which lists presets and manages their selection */
116 Gtk::ComboBoxText _preset_combo;
117 /** a label which has a * in if the current settings are different from the preset being shown */
118 Gtk::Label _preset_modified;
119 /** a button to add a preset */
120 Gtk::Button add_button;
121 /** a button to save the current settings as a new user preset */
122 Gtk::Button save_button;
123 /** a button to delete the current preset (if it is a user one) */
124 Gtk::Button delete_button;
125 /** a button to bypass the plugin */
126 ArdourButton bypass_button;
127 /** a button to acquire keyboard focus */
128 Gtk::EventBox focus_button;
129 /** an expander containing the plugin description */
130 Gtk::Expander description_expander;
131 /** an expander containing the plugin analysis graph */
132 Gtk::Expander plugin_analysis_expander;
133 /** a label indicating the plugin latency */
134 Gtk::Label latency_label;
135 /** a button which, when clicked, opens the latency GUI */
136 Gtk::Button latency_button;
138 void set_latency_label ();
140 LatencyGUI* latency_gui;
141 ArdourWindow* latency_dialog;
144 Gtk::Requisition pre_eq_size;
146 Gtk::Image* focus_out_image;
147 Gtk::Image* focus_in_image;
150 virtual void preset_selected ();
151 void add_plugin_setting ();
152 void save_plugin_setting ();
153 void delete_plugin_setting ();
154 bool focus_toggled(GdkEventButton*);
155 bool bypass_button_release(GdkEventButton*);
156 void toggle_description ();
157 void toggle_plugin_analysis ();
158 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
159 void plugin_going_away ();
160 virtual void parameter_changed (uint32_t, float);
161 void preset_added_or_removed ();
162 void update_preset_modified ();
164 PBD::ScopedConnection death_connection;
165 PBD::ScopedConnection active_connection;
166 PBD::ScopedConnection preset_added_connection;
167 PBD::ScopedConnection preset_removed_connection;
168 PBD::ScopedConnectionList control_connections;
171 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
174 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
177 gint get_preferred_height () { return prefheight; }
178 gint get_preferred_width () { return -1; }
180 bool start_updating(GdkEventAny*);
181 bool stop_updating(GdkEventAny*);
184 Gtk::VBox main_contents;
186 Gtk::HBox settings_box;
189 Gtk::Table button_table;
190 Gtk::Table output_table;
192 Gtk::ScrolledWindow scroller;
193 Gtk::Adjustment hAdjustment;
194 Gtk::Adjustment vAdjustment;
195 Gtk::Viewport scroller_view;
196 Gtk::Menu* automation_menu;
202 Gtkmm2ext::FastMeter *meter;
210 MeterInfo (int /*i*/) {
220 static const int32_t initial_button_rows = 12;
221 static const int32_t initial_button_cols = 1;
222 static const int32_t initial_output_rows = 1;
223 static const int32_t initial_output_cols = 4;
225 /* FIXME: Unify with AutomationController */
226 struct ControlUI : public Gtk::HBox {
229 boost::shared_ptr<ARDOUR::AutomationControl> control;
231 Evoral::Parameter parameter() { return control->parameter(); }
235 Gtk::ComboBoxText* combo;
236 boost::shared_ptr<ARDOUR::Plugin::ScalePoints> scale_points;
237 Gtk::ToggleButton* button;
238 boost::shared_ptr<AutomationController> controller;
239 Gtkmm2ext::ClickBox* clickbox;
243 Gtk::Button automate_button;
247 Gtk::EventBox* display;
248 Gtk::Label* display_label;
252 MeterInfo* meterinfo;
258 std::vector<ControlUI*> input_controls;
259 std::vector<ControlUI*> output_controls;
260 sigc::connection screen_update_connection;
261 void output_update();
264 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
265 void ui_parameter_changed (ControlUI* cui);
266 void toggle_parameter_changed (ControlUI* cui);
267 void update_control_display (ControlUI* cui);
268 void control_port_toggled (ControlUI* cui);
269 void control_combo_changed (ControlUI* cui);
271 void astate_clicked (ControlUI*, uint32_t parameter);
272 void automation_state_changed (ControlUI*);
273 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
274 void start_touch (ControlUI*);
275 void stop_touch (ControlUI*);
278 void print_parameter (char *buf, uint32_t len, uint32_t param);
279 bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *);
280 bool midinote_printer(char* buf, Gtk::Adjustment &, ControlUI *);
283 class PluginUIWindow : public ArdourWindow
286 PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert,
287 bool scrollable=false,
291 PlugUIBase& pluginui() { return *_pluginui; }
293 void resize_preferred();
294 void set_parent (Gtk::Window*);
295 void set_title(const std::string& title);
298 bool on_key_press_event (GdkEventKey*);
299 bool on_key_release_event (GdkEventKey*);
305 PlugUIBase* _pluginui;
306 PBD::ScopedConnection death_connection;
310 bool _keyboard_focused;
311 #ifdef AUDIOUNIT_SUPPORT
312 int pre_deactivate_x;
313 int pre_deactivate_y;
316 void keyboard_focused (bool yn);
318 void app_activated (bool);
319 void plugin_going_away ();
321 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
322 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
323 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
324 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
327 #ifdef AUDIOUNIT_SUPPORT
328 /* this function has to be in a .mm file */
329 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
332 #endif /* __ardour_plugin_ui_h__ */