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/adjustment.h>
34 #include <gtkmm/box.h>
35 #include <gtkmm/button.h>
36 #include <gtkmm/eventbox.h>
37 #include <gtkmm/expander.h>
38 #include <gtkmm/filechooserbutton.h>
39 #include <gtkmm/image.h>
40 #include <gtkmm/label.h>
41 #include <gtkmm/menu.h>
42 #include <gtkmm/scrolledwindow.h>
43 #include <gtkmm/socket.h>
44 #include <gtkmm/table.h>
45 #include <gtkmm/togglebutton.h>
46 #include <gtkmm/viewport.h>
48 #include "ardour/types.h"
49 #include "ardour/plugin.h"
50 #include "ardour/variant.h"
52 #include "widgets/ardour_button.h"
53 #include "widgets/ardour_dropdown.h"
54 #include "widgets/ardour_spinner.h"
56 #include "ardour_window.h"
57 #include "automation_controller.h"
58 #include "gtk_pianokeyboard.h"
63 class WindowsVSTPlugin;
74 namespace ArdourWidgets {
84 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
87 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
88 virtual ~PlugUIBase();
90 virtual gint get_preferred_height () = 0;
91 virtual gint get_preferred_width () = 0;
92 virtual bool resizable () { return true; }
93 virtual bool start_updating(GdkEventAny*) = 0;
94 virtual bool stop_updating(GdkEventAny*) = 0;
96 virtual void activate () {}
97 virtual void deactivate () {}
99 void update_preset_list ();
100 void update_preset ();
102 void latency_button_clicked ();
104 virtual bool on_window_show(const std::string& /*title*/) { return true; }
105 virtual void on_window_hide() {}
107 virtual void forward_key_event (GdkEventKey*) {}
108 virtual void grab_focus () {}
109 virtual bool non_gtk_gui() const { return false; }
111 sigc::signal<void,bool> KeyboardFocused;
114 boost::shared_ptr<ARDOUR::PluginInsert> insert;
115 boost::shared_ptr<ARDOUR::Plugin> plugin;
117 /* UI elements that can subclasses can add to their widgets */
119 /** a ComboBoxText which lists presets and manages their selection */
120 ArdourWidgets::ArdourDropdown _preset_combo;
121 /** a label which has a * in if the current settings are different from the preset being shown */
122 Gtk::Label _preset_modified;
123 /** a button to add a preset */
124 ArdourWidgets::ArdourButton add_button;
125 /** a button to save the current settings as a new user preset */
126 ArdourWidgets::ArdourButton save_button;
127 /** a button to delete the current preset (if it is a user one) */
128 ArdourWidgets::ArdourButton delete_button;
129 /** a button to delete the reset the plugin params */
130 ArdourWidgets::ArdourButton reset_button;
131 /** a button to bypass the plugin */
132 ArdourWidgets::ArdourButton bypass_button;
133 /** and self-explaining button :) */
134 ArdourWidgets::ArdourButton pin_management_button;
135 /** a button to acquire keyboard focus */
136 Gtk::EventBox focus_button;
137 /** an expander containing the plugin description */
138 Gtk::Expander description_expander;
139 /** an expander containing the plugin analysis graph */
140 Gtk::Expander plugin_analysis_expander;
141 /** a button which, when clicked, opens the latency GUI */
142 ArdourWidgets::ArdourButton latency_button;
143 /** a button which sets all controls' automation setting to Manual */
144 ArdourWidgets::ArdourButton automation_manual_all_button;
145 /** a button which sets all controls' automation setting to Play */
146 ArdourWidgets::ArdourButton automation_play_all_button;
147 /** a button which sets all controls' automation setting to Write */
148 ArdourWidgets::ArdourButton automation_write_all_button;
149 /** a button which sets all controls' automation setting to Touch */
150 ArdourWidgets::ArdourButton automation_touch_all_button;
151 /** a button which sets all controls' automation setting to Latch */
152 ArdourWidgets::ArdourButton automation_latch_all_button;
154 void set_latency_label ();
156 LatencyGUI* latency_gui;
157 ArdourWindow* latency_dialog;
161 Gtk::Image* focus_out_image;
162 Gtk::Image* focus_in_image;
165 virtual void preset_selected (ARDOUR::Plugin::PresetRecord preset);
166 void add_plugin_setting ();
167 void save_plugin_setting ();
168 void delete_plugin_setting ();
169 void reset_plugin_parameters ();
171 bool focus_toggled(GdkEventButton*);
172 bool bypass_button_release(GdkEventButton*);
173 void toggle_description ();
174 void toggle_plugin_analysis ();
175 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
176 void plugin_going_away ();
177 void automation_state_changed ();
178 void preset_added_or_removed ();
179 void update_preset_modified ();
181 PBD::ScopedConnection death_connection;
182 PBD::ScopedConnection active_connection;
183 PBD::ScopedConnection preset_added_connection;
184 PBD::ScopedConnection preset_removed_connection;
185 PBD::ScopedConnectionList control_connections;
188 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
191 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
194 gint get_preferred_height () { return prefheight; }
195 gint get_preferred_width () { return -1; }
197 bool start_updating(GdkEventAny*);
198 bool stop_updating(GdkEventAny*);
201 Gtk::VBox main_contents;
202 Gtk::HBox settings_box;
204 Gtk::Menu* automation_menu;
210 ArdourWidgets::FastMeter* meter;
219 /* FIXME: Unify with AutomationController */
220 struct ControlUI : public Gtk::HBox {
222 const Evoral::Parameter parameter() const { return param; }
224 Evoral::Parameter param;
225 boost::shared_ptr<ARDOUR::AutomationControl> control;
229 boost::shared_ptr<ARDOUR::ScalePoints> scale_points;
230 boost::shared_ptr<AutomationController> controller;
232 ArdourWidgets::ArdourButton automate_button;
234 ArdourWidgets::ArdourDropdown* combo;
235 ArdourWidgets::ClickBox* clickbox;
236 Gtk::FileChooserButton* file_button;
237 ArdourWidgets::ArdourSpinner* spin_box;
246 Gtk::EventBox* display;
247 Gtk::Label* display_label;
251 MeterInfo* meterinfo;
253 ControlUI (const Evoral::Parameter& param);
257 Gtk::Table* knobtable;
260 bool short_autostate; // modify with set_short_autostate below
263 void set_short_autostate(ControlUI* cui, bool value);
265 std::vector<ControlUI*> input_controls; // workaround for preset load
266 std::vector<ControlUI*> input_controls_with_automation;
267 std::vector<ControlUI*> output_controls;
269 sigc::connection screen_update_connection;
271 void output_update();
274 void automatic_layout (const std::vector<ControlUI *>& control_uis);
275 void custom_layout (const std::vector<ControlUI *>& control_uis);
277 ControlUI* build_control_ui (const Evoral::Parameter& param,
278 const ARDOUR::ParameterDescriptor& desc,
279 boost::shared_ptr<ARDOUR::AutomationControl> mcontrol,
282 bool use_knob = false);
284 void ui_parameter_changed (ControlUI* cui);
285 void update_control_display (ControlUI* cui);
286 void update_input_displays (); // workaround for preset load
287 void control_combo_changed (ControlUI* cui, float value);
289 bool astate_button_event (GdkEventButton* ev, ControlUI*);
290 void automation_state_changed (ControlUI*);
291 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
292 void set_all_automation (ARDOUR::AutoState state);
294 void knob_size_request(Gtk::Requisition* req, ControlUI* cui);
297 void print_parameter (char *buf, uint32_t len, uint32_t param);
298 bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *);
299 bool midinote_printer(char* buf, Gtk::Adjustment &, ControlUI *);
301 typedef std::map<uint32_t, Gtk::FileChooserButton*> FilePathControls;
302 FilePathControls _filepath_controls;
303 void set_path_property (const ARDOUR::ParameterDescriptor& desc,
304 Gtk::FileChooserButton* widget);
305 void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
307 void scroller_size_request (Gtk::Requisition*);
308 Gtk::ScrolledWindow scroller;
310 Gtk::Expander _plugin_pianokeyboard_expander;
311 PianoKeyboard* _piano;
312 Gtk::Widget* _pianomm;
314 Gtk::SpinButton _piano_velocity;
315 Gtk::SpinButton _piano_channel;
317 static void _note_on_event_handler (GtkWidget*, int, gpointer);
318 static void _note_off_event_handler (GtkWidget*, int, gpointer);
319 void note_on_event_handler (int);
320 void note_off_event_handler (int);
322 void toggle_pianokeyboard ();
323 void build_midi_table ();
324 void midi_refill_patches ();
325 void midi_bank_patch_change (uint8_t chn);
326 void midi_bank_patch_select (uint8_t chn, uint32_t bankpgm);
327 std::vector<ArdourWidgets::ArdourDropdown*> midi_pgmsel;
328 PBD::ScopedConnectionList midi_connections;
329 std::map<uint32_t, std::string> pgm_names;
332 class PluginUIWindow : public ArdourWindow
335 PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert,
336 bool scrollable=false,
340 PlugUIBase& pluginui() { return *_pluginui; }
342 void resize_preferred();
343 void set_parent (Gtk::Window*);
344 void set_title(const std::string& title);
347 bool on_key_press_event (GdkEventKey*);
348 bool on_key_release_event (GdkEventKey*);
354 PlugUIBase* _pluginui;
355 PBD::ScopedConnection death_connection;
359 bool _keyboard_focused;
360 #ifdef AUDIOUNIT_SUPPORT
361 int pre_deactivate_x;
362 int pre_deactivate_y;
365 void keyboard_focused (bool yn);
367 void app_activated (bool);
368 void plugin_going_away ();
370 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
371 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
372 bool create_mac_vst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
373 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
374 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
377 #ifdef MACVST_SUPPORT
378 /* this function has to be in a .mm file
379 * because MacVSTPluginUI has Cocoa members
381 extern VSTPluginUI* create_mac_vst_gui (boost::shared_ptr<ARDOUR::PluginInsert>);
384 #ifdef AUDIOUNIT_SUPPORT
385 /* this function has to be in a .mm file */
386 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
389 #endif /* __ardour_plugin_ui_h__ */