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"
57 class WindowsVSTPlugin;
69 class HSliderController;
80 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
83 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
84 virtual ~PlugUIBase();
86 virtual gint get_preferred_height () = 0;
87 virtual gint get_preferred_width () = 0;
88 virtual bool start_updating(GdkEventAny*) = 0;
89 virtual bool stop_updating(GdkEventAny*) = 0;
91 virtual void activate () {}
92 virtual void deactivate () {}
94 void update_preset_list ();
95 void update_preset ();
97 void latency_button_clicked ();
99 virtual bool on_window_show(const std::string& /*title*/) { return true; }
100 virtual void on_window_hide() {}
102 virtual void forward_key_event (GdkEventKey*) {}
103 virtual bool non_gtk_gui() const { return false; }
105 sigc::signal<void,bool> KeyboardFocused;
108 boost::shared_ptr<ARDOUR::PluginInsert> insert;
109 boost::shared_ptr<ARDOUR::Plugin> plugin;
111 /* UI elements that can subclasses can add to their widgets */
113 /** a ComboBoxText which lists presets and manages their selection */
114 Gtk::ComboBoxText _preset_combo;
115 /** a label which has a * in if the current settings are different from the preset being shown */
116 Gtk::Label _preset_modified;
117 /** a button to add a preset */
118 Gtk::Button add_button;
119 /** a button to save the current settings as a new user preset */
120 Gtk::Button save_button;
121 /** a button to delete the current preset (if it is a user one) */
122 Gtk::Button delete_button;
123 /** a button to bypass the plugin */
124 ArdourButton bypass_button;
125 /** a button to acquire keyboard focus */
126 Gtk::EventBox focus_button;
127 /** an expander containing the plugin analysis graph */
128 Gtk::Expander plugin_analysis_expander;
129 /** a label indicating the plugin latency */
130 Gtk::Label latency_label;
131 /** a button which, when clicked, opens the latency GUI */
132 Gtk::Button latency_button;
134 void set_latency_label ();
136 LatencyGUI* latency_gui;
137 ArdourWindow* latency_dialog;
140 Gtk::Requisition pre_eq_size;
142 Gtk::Image* focus_out_image;
143 Gtk::Image* focus_in_image;
146 virtual void preset_selected ();
147 void add_plugin_setting ();
148 void save_plugin_setting ();
149 void delete_plugin_setting ();
150 bool focus_toggled(GdkEventButton*);
151 bool bypass_button_release(GdkEventButton*);
152 void toggle_plugin_analysis ();
153 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
154 void plugin_going_away ();
155 virtual void parameter_changed (uint32_t, float);
156 void preset_added_or_removed ();
157 void update_preset_modified ();
159 PBD::ScopedConnection death_connection;
160 PBD::ScopedConnection active_connection;
161 PBD::ScopedConnection preset_added_connection;
162 PBD::ScopedConnection preset_removed_connection;
163 PBD::ScopedConnectionList control_connections;
166 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
169 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
172 gint get_preferred_height () { return prefheight; }
173 gint get_preferred_width () { return -1; }
175 bool start_updating(GdkEventAny*);
176 bool stop_updating(GdkEventAny*);
179 Gtk::VBox main_contents;
181 Gtk::HBox settings_box;
184 Gtk::Table button_table;
185 Gtk::Table output_table;
187 Gtk::ScrolledWindow scroller;
188 Gtk::Adjustment hAdjustment;
189 Gtk::Adjustment vAdjustment;
190 Gtk::Viewport scroller_view;
191 Gtk::Menu* automation_menu;
197 Gtkmm2ext::FastMeter *meter;
205 MeterInfo (int /*i*/) {
215 static const int32_t initial_button_rows = 12;
216 static const int32_t initial_button_cols = 1;
217 static const int32_t initial_output_rows = 1;
218 static const int32_t initial_output_cols = 4;
220 /* FIXME: Unify with AutomationController */
221 struct ControlUI : public Gtk::HBox {
224 boost::shared_ptr<ARDOUR::AutomationControl> control;
226 Evoral::Parameter parameter() { return control->parameter(); }
230 Gtk::ComboBoxText* combo;
231 boost::shared_ptr<ARDOUR::Plugin::ScalePoints> scale_points;
232 Gtk::ToggleButton* button;
233 boost::shared_ptr<AutomationController> controller;
234 Gtkmm2ext::ClickBox* clickbox;
238 Gtk::Button automate_button;
242 Gtk::EventBox* display;
243 Gtk::Label* display_label;
247 MeterInfo* meterinfo;
253 std::vector<ControlUI*> input_controls;
254 std::vector<ControlUI*> output_controls;
255 sigc::connection screen_update_connection;
256 void output_update();
259 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
260 void ui_parameter_changed (ControlUI* cui);
261 void toggle_parameter_changed (ControlUI* cui);
262 void update_control_display (ControlUI* cui);
263 void control_port_toggled (ControlUI* cui);
264 void control_combo_changed (ControlUI* cui);
266 void astate_clicked (ControlUI*, uint32_t parameter);
267 void automation_state_changed (ControlUI*);
268 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
269 void start_touch (ControlUI*);
270 void stop_touch (ControlUI*);
272 void print_parameter (char *buf, uint32_t len, uint32_t param);
275 class PluginUIWindow : public Gtk::Window
278 PluginUIWindow (Gtk::Window*,
279 boost::shared_ptr<ARDOUR::PluginInsert> insert,
280 bool scrollable=false,
284 PlugUIBase& pluginui() { return *_pluginui; }
286 void resize_preferred();
287 void set_parent (Gtk::Window*);
288 void set_title(const std::string& title);
291 bool on_enter_notify_event (GdkEventCrossing*);
292 bool on_leave_notify_event (GdkEventCrossing*);
293 bool on_focus_in_event (GdkEventFocus*);
294 bool on_focus_out_event (GdkEventFocus*);
295 bool on_key_press_event (GdkEventKey*);
296 bool on_key_release_event (GdkEventKey*);
303 PlugUIBase* _pluginui;
304 PBD::ScopedConnection death_connection;
308 bool _keyboard_focused;
309 void keyboard_focused (bool yn);
311 void app_activated (bool);
312 void plugin_going_away ();
314 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
315 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
316 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
317 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
320 #ifdef AUDIOUNIT_SUPPORT
321 /* this function has to be in a .mm file */
322 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
325 #endif /* __ardour_plugin_ui_h__ */