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/socket.h>
47 #include "ardour/types.h"
48 #include "ardour/plugin.h"
49 #include "ardour/variant.h"
51 #include "widgets/ardour_button.h"
52 #include "widgets/ardour_dropdown.h"
53 #include "widgets/ardour_spinner.h"
55 #include "ardour_window.h"
56 #include "automation_controller.h"
61 class WindowsVSTPlugin;
72 namespace ArdourWidgets {
82 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
85 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
86 virtual ~PlugUIBase();
88 virtual gint get_preferred_height () = 0;
89 virtual gint get_preferred_width () = 0;
90 virtual bool resizable () { return true; }
91 virtual bool start_updating(GdkEventAny*) = 0;
92 virtual bool stop_updating(GdkEventAny*) = 0;
94 virtual void activate () {}
95 virtual void deactivate () {}
97 void update_preset_list ();
98 void update_preset ();
100 void latency_button_clicked ();
102 virtual bool on_window_show(const std::string& /*title*/) { return true; }
103 virtual void on_window_hide() {}
105 virtual void forward_key_event (GdkEventKey*) {}
106 virtual void grab_focus () {}
107 virtual bool non_gtk_gui() const { return false; }
109 sigc::signal<void,bool> KeyboardFocused;
112 boost::shared_ptr<ARDOUR::PluginInsert> insert;
113 boost::shared_ptr<ARDOUR::Plugin> plugin;
115 /* UI elements that can subclasses can add to their widgets */
117 /** a ComboBoxText which lists presets and manages their selection */
118 ArdourWidgets::ArdourDropdown _preset_combo;
119 /** a label which has a * in if the current settings are different from the preset being shown */
120 Gtk::Label _preset_modified;
121 /** a button to add a preset */
122 ArdourWidgets::ArdourButton add_button;
123 /** a button to save the current settings as a new user preset */
124 ArdourWidgets::ArdourButton save_button;
125 /** a button to delete the current preset (if it is a user one) */
126 ArdourWidgets::ArdourButton delete_button;
127 /** a button to delete the reset the plugin params */
128 ArdourWidgets::ArdourButton reset_button;
129 /** a button to bypass the plugin */
130 ArdourWidgets::ArdourButton bypass_button;
131 /** and self-explaining button :) */
132 ArdourWidgets::ArdourButton pin_management_button;
133 /** a button to acquire keyboard focus */
134 Gtk::EventBox focus_button;
135 /** an expander containing the plugin description */
136 Gtk::Expander description_expander;
137 /** an expander containing the plugin analysis graph */
138 Gtk::Expander plugin_analysis_expander;
139 /** a button which, when clicked, opens the latency GUI */
140 ArdourWidgets::ArdourButton latency_button;
141 /** a button which sets all controls' automation setting to Manual */
142 ArdourWidgets::ArdourButton automation_manual_all_button;
143 /** a button which sets all controls' automation setting to Play */
144 ArdourWidgets::ArdourButton automation_play_all_button;
145 /** a button which sets all controls' automation setting to Write */
146 ArdourWidgets::ArdourButton automation_write_all_button;
147 /** a button which sets all controls' automation setting to Touch */
148 ArdourWidgets::ArdourButton automation_touch_all_button;
150 void set_latency_label ();
152 LatencyGUI* latency_gui;
153 ArdourWindow* latency_dialog;
157 Gtk::Image* focus_out_image;
158 Gtk::Image* focus_in_image;
161 virtual void preset_selected (ARDOUR::Plugin::PresetRecord preset);
162 void add_plugin_setting ();
163 void save_plugin_setting ();
164 void delete_plugin_setting ();
165 void reset_plugin_parameters ();
167 bool focus_toggled(GdkEventButton*);
168 bool bypass_button_release(GdkEventButton*);
169 void toggle_description ();
170 void toggle_plugin_analysis ();
171 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
172 void plugin_going_away ();
173 void automation_state_changed ();
174 void preset_added_or_removed ();
175 void update_preset_modified ();
177 PBD::ScopedConnection death_connection;
178 PBD::ScopedConnection active_connection;
179 PBD::ScopedConnection preset_added_connection;
180 PBD::ScopedConnection preset_removed_connection;
181 PBD::ScopedConnectionList control_connections;
184 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
187 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
190 gint get_preferred_height () { return prefheight; }
191 gint get_preferred_width () { return -1; }
193 bool start_updating(GdkEventAny*);
194 bool stop_updating(GdkEventAny*);
197 Gtk::VBox main_contents;
198 Gtk::HBox settings_box;
200 Gtk::Menu* automation_menu;
206 ArdourWidgets::FastMeter* meter;
215 /* FIXME: Unify with AutomationController */
216 struct ControlUI : public Gtk::HBox {
218 const Evoral::Parameter parameter() const { return param; }
220 Evoral::Parameter param;
221 boost::shared_ptr<ARDOUR::AutomationControl> control;
225 boost::shared_ptr<ARDOUR::ScalePoints> scale_points;
226 boost::shared_ptr<AutomationController> controller;
228 ArdourWidgets::ArdourButton automate_button;
230 ArdourWidgets::ArdourDropdown* combo;
231 ArdourWidgets::ClickBox* clickbox;
232 Gtk::FileChooserButton* file_button;
233 ArdourWidgets::ArdourSpinner* spin_box;
241 Gtk::EventBox* display;
242 Gtk::Label* display_label;
246 MeterInfo* meterinfo;
248 ControlUI (const Evoral::Parameter& param);
252 Gtk::Table* knobtable;
256 std::vector<ControlUI*> input_controls; // workaround for preset load
257 std::vector<ControlUI*> input_controls_with_automation;
258 std::vector<ControlUI*> output_controls;
260 sigc::connection screen_update_connection;
262 void output_update();
265 void automatic_layout (const std::vector<ControlUI *>& control_uis);
266 void custom_layout (const std::vector<ControlUI *>& control_uis);
268 ControlUI* build_control_ui (const Evoral::Parameter& param,
269 const ARDOUR::ParameterDescriptor& desc,
270 boost::shared_ptr<ARDOUR::AutomationControl> mcontrol,
273 bool use_knob = false);
275 void ui_parameter_changed (ControlUI* cui);
276 void update_control_display (ControlUI* cui);
277 void update_input_displays (); // workaround for preset load
278 void control_combo_changed (ControlUI* cui, float value);
280 bool astate_button_event (GdkEventButton* ev, ControlUI*);
281 void automation_state_changed (ControlUI*);
282 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
283 void set_all_automation (ARDOUR::AutoState state);
285 void knob_size_request(Gtk::Requisition* req, ControlUI* cui);
288 void print_parameter (char *buf, uint32_t len, uint32_t param);
289 bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *);
290 bool midinote_printer(char* buf, Gtk::Adjustment &, ControlUI *);
292 typedef std::map<uint32_t, Gtk::FileChooserButton*> FilePathControls;
293 FilePathControls _filepath_controls;
294 void set_path_property (const ARDOUR::ParameterDescriptor& desc,
295 Gtk::FileChooserButton* widget);
296 void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
300 class PluginUIWindow : public ArdourWindow
303 PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert,
304 bool scrollable=false,
308 PlugUIBase& pluginui() { return *_pluginui; }
310 void resize_preferred();
311 void set_parent (Gtk::Window*);
312 void set_title(const std::string& title);
315 bool on_key_press_event (GdkEventKey*);
316 bool on_key_release_event (GdkEventKey*);
322 PlugUIBase* _pluginui;
323 PBD::ScopedConnection death_connection;
327 bool _keyboard_focused;
328 #ifdef AUDIOUNIT_SUPPORT
329 int pre_deactivate_x;
330 int pre_deactivate_y;
333 void keyboard_focused (bool yn);
335 void app_activated (bool);
336 void plugin_going_away ();
338 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
339 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
340 bool create_mac_vst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
341 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
342 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
345 #ifdef MACVST_SUPPORT
346 /* this function has to be in a .mm file
347 * because MacVSTPluginUI has Cocoa members
349 extern VSTPluginUI* create_mac_vst_gui (boost::shared_ptr<ARDOUR::PluginInsert>);
352 #ifdef AUDIOUNIT_SUPPORT
353 /* this function has to be in a .mm file */
354 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
357 #endif /* __ardour_plugin_ui_h__ */