2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2015 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2009 Sampo Savolainen <v2@iki.fi>
5 * Copyright (C) 2007-2015 David Robillard <d@drobilla.net>
6 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
7 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2016-2017 Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __ardour_plugin_ui_h__
26 #define __ardour_plugin_ui_h__
29 #include "gtk2ardour-config.h"
36 #include <sigc++/signal.h>
38 #include <gtkmm/adjustment.h>
39 #include <gtkmm/box.h>
40 #include <gtkmm/button.h>
41 #include <gtkmm/eventbox.h>
42 #include <gtkmm/expander.h>
43 #include <gtkmm/filechooserbutton.h>
44 #include <gtkmm/image.h>
45 #include <gtkmm/label.h>
46 #include <gtkmm/menu.h>
47 #include <gtkmm/scrolledwindow.h>
48 #include <gtkmm/socket.h>
49 #include <gtkmm/table.h>
50 #include <gtkmm/togglebutton.h>
51 #include <gtkmm/viewport.h>
53 #include "ardour/types.h"
54 #include "ardour/plugin.h"
55 #include "ardour/variant.h"
57 #include "widgets/ardour_button.h"
58 #include "widgets/ardour_dropdown.h"
59 #include "widgets/ardour_spinner.h"
61 #include "ardour_window.h"
62 #include "automation_controller.h"
63 #include "pianokeyboard.h"
68 class WindowsVSTPlugin;
79 namespace ArdourWidgets {
86 class PluginLoadStatsGui;
87 class PluginPresetsUI;
90 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
93 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
94 virtual ~PlugUIBase();
96 virtual gint get_preferred_height () = 0;
97 virtual gint get_preferred_width () = 0;
98 virtual bool resizable () { return true; }
99 virtual bool start_updating(GdkEventAny*) = 0;
100 virtual bool stop_updating(GdkEventAny*) = 0;
102 virtual void activate () {}
103 virtual void deactivate () {}
105 void update_preset_list ();
106 void update_preset ();
108 void latency_button_clicked ();
110 virtual bool on_window_show(const std::string& /*title*/) { return true; }
111 virtual void on_window_hide() {}
113 virtual void forward_key_event (GdkEventKey*) {}
114 virtual void grab_focus () {}
115 virtual bool non_gtk_gui() const { return false; }
117 sigc::signal<void,bool> KeyboardFocused;
120 boost::shared_ptr<ARDOUR::PluginInsert> insert;
121 boost::shared_ptr<ARDOUR::Plugin> plugin;
123 /* UI elements that can subclasses can add to their widgets */
125 /** a ComboBoxText which lists presets and manages their selection */
126 ArdourWidgets::ArdourDropdown _preset_combo;
127 /** a label which has a * in if the current settings are different from the preset being shown */
128 Gtk::Label _preset_modified;
129 /** a button to add a preset */
130 ArdourWidgets::ArdourButton add_button;
131 /** a button to save the current settings as a new user preset */
132 ArdourWidgets::ArdourButton save_button;
133 /** a button to delete the current preset (if it is a user one) */
134 ArdourWidgets::ArdourButton delete_button;
135 /** a button to show a preset browser */
136 ArdourWidgets::ArdourButton preset_browser_button;
137 /** a button to delete the reset the plugin params */
138 ArdourWidgets::ArdourButton reset_button;
139 /** a button to bypass the plugin */
140 ArdourWidgets::ArdourButton bypass_button;
141 /** and self-explaining button :) */
142 ArdourWidgets::ArdourButton pin_management_button;
143 /** a button to acquire keyboard focus */
144 Gtk::EventBox focus_button;
145 /** an expander containing the plugin description */
146 Gtk::Expander description_expander;
147 /** an expander containing the plugin analysis graph */
148 Gtk::Expander plugin_analysis_expander;
149 /** an expander containing the plugin cpu profile */
150 Gtk::Expander cpuload_expander;
151 /** a button which, when clicked, opens the latency GUI */
152 ArdourWidgets::ArdourButton latency_button;
153 /** a button which sets all controls' automation setting to Manual */
154 ArdourWidgets::ArdourButton automation_manual_all_button;
155 /** a button which sets all controls' automation setting to Play */
156 ArdourWidgets::ArdourButton automation_play_all_button;
157 /** a button which sets all controls' automation setting to Write */
158 ArdourWidgets::ArdourButton automation_write_all_button;
159 /** a button which sets all controls' automation setting to Touch */
160 ArdourWidgets::ArdourButton automation_touch_all_button;
161 /** a button which sets all controls' automation setting to Latch */
162 ArdourWidgets::ArdourButton automation_latch_all_button;
164 void set_latency_label ();
165 LatencyGUI* latency_gui;
166 ArdourWindow* latency_dialog;
169 PluginLoadStatsGui* stats_gui;
170 PluginPresetsUI* preset_gui;
171 ArdourWindow* preset_dialog;
173 Gtk::Image* focus_out_image;
174 Gtk::Image* focus_in_image;
177 virtual void preset_selected (ARDOUR::Plugin::PresetRecord preset);
178 void add_plugin_setting ();
179 void save_plugin_setting ();
180 void delete_plugin_setting ();
181 void reset_plugin_parameters ();
182 void browse_presets ();
184 bool focus_toggled(GdkEventButton*);
185 bool bypass_button_release(GdkEventButton*);
186 void toggle_description ();
187 void toggle_plugin_analysis ();
188 void toggle_cpuload_display ();
189 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
190 void plugin_going_away ();
191 void automation_state_changed ();
192 void preset_added_or_removed ();
193 void update_preset_modified ();
195 bool has_descriptive_presets () const;
197 PBD::ScopedConnection death_connection;
198 PBD::ScopedConnection active_connection;
199 PBD::ScopedConnection preset_added_connection;
200 PBD::ScopedConnection preset_removed_connection;
201 PBD::ScopedConnectionList control_connections;
204 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
207 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
210 gint get_preferred_height () { return prefheight; }
211 gint get_preferred_width () { return -1; }
213 bool start_updating(GdkEventAny*);
214 bool stop_updating(GdkEventAny*);
217 Gtk::VBox main_contents;
218 Gtk::HBox settings_box;
220 Gtk::Menu* automation_menu;
226 ArdourWidgets::FastMeter* meter;
235 /* FIXME: Unify with AutomationController */
236 struct ControlUI : public Gtk::HBox {
238 const Evoral::Parameter parameter() const { return param; }
240 Evoral::Parameter param;
241 boost::shared_ptr<ARDOUR::AutomationControl> control;
245 boost::shared_ptr<ARDOUR::ScalePoints> scale_points;
246 boost::shared_ptr<AutomationController> controller;
248 ArdourWidgets::ArdourButton automate_button;
250 ArdourWidgets::ArdourDropdown* combo;
251 Gtk::FileChooserButton* file_button;
252 ArdourWidgets::ArdourSpinner* spin_box;
261 Gtk::EventBox* display;
262 Gtk::Label* display_label;
266 MeterInfo* meterinfo;
268 ControlUI (const Evoral::Parameter& param);
272 Gtk::Table* knobtable;
275 bool short_autostate; // modify with set_short_autostate below
278 void set_short_autostate(ControlUI* cui, bool value);
280 std::vector<ControlUI*> input_controls; // workaround for preset load
281 std::vector<ControlUI*> input_controls_with_automation;
282 std::vector<ControlUI*> output_controls;
284 sigc::connection screen_update_connection;
286 void output_update();
289 void automatic_layout (const std::vector<ControlUI *>& control_uis);
290 void custom_layout (const std::vector<ControlUI *>& control_uis);
292 ControlUI* build_control_ui (const Evoral::Parameter& param,
293 const ARDOUR::ParameterDescriptor& desc,
294 boost::shared_ptr<ARDOUR::AutomationControl> mcontrol,
297 bool use_knob = false);
299 void ui_parameter_changed (ControlUI* cui);
300 void update_control_display (ControlUI* cui);
301 void update_input_displays (); // workaround for preset load
302 void control_combo_changed (ControlUI* cui, float value);
304 bool astate_button_event (GdkEventButton* ev, ControlUI*);
305 void automation_state_changed (ControlUI*);
306 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
307 void set_all_automation (ARDOUR::AutoState state);
309 void knob_size_request(Gtk::Requisition* req, ControlUI* cui);
311 typedef std::map<uint32_t, Gtk::FileChooserButton*> FilePathControls;
312 FilePathControls _filepath_controls;
313 void set_path_property (const ARDOUR::ParameterDescriptor& desc,
314 Gtk::FileChooserButton* widget);
315 void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
317 void scroller_size_request (Gtk::Requisition*);
318 Gtk::ScrolledWindow scroller;
320 Gtk::Expander _plugin_pianokeyboard_expander;
321 APianoKeyboard* _piano;
323 Gtk::SpinButton _piano_velocity;
324 Gtk::SpinButton _piano_channel;
326 void note_on_event_handler (int, int);
327 void note_off_event_handler (int);
329 void toggle_pianokeyboard ();
330 void build_midi_table ();
331 void midi_refill_patches ();
332 void midi_bank_patch_change (uint8_t chn);
333 void midi_bank_patch_select (uint8_t chn, uint32_t bankpgm);
334 std::vector<ArdourWidgets::ArdourDropdown*> midi_pgmsel;
335 PBD::ScopedConnectionList midi_connections;
336 std::map<uint32_t, std::string> pgm_names;
339 class PluginUIWindow : public ArdourWindow
342 PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert,
343 bool scrollable=false,
347 PlugUIBase& pluginui() { return *_pluginui; }
349 void resize_preferred();
350 void set_parent (Gtk::Window*);
351 void set_title(const std::string& title);
354 bool on_key_press_event (GdkEventKey*);
355 bool on_key_release_event (GdkEventKey*);
361 PlugUIBase* _pluginui;
362 PBD::ScopedConnection death_connection;
366 bool _keyboard_focused;
367 #ifdef AUDIOUNIT_SUPPORT
368 int pre_deactivate_x;
369 int pre_deactivate_y;
372 void keyboard_focused (bool yn);
374 void app_activated (bool);
375 void plugin_going_away ();
377 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
378 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
379 bool create_mac_vst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
380 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
381 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
384 #ifdef MACVST_SUPPORT
385 /* this function has to be in a .mm file
386 * because MacVSTPluginUI has Cocoa members
388 extern VSTPluginUI* create_mac_vst_gui (boost::shared_ptr<ARDOUR::PluginInsert>);
391 #ifdef AUDIOUNIT_SUPPORT
392 /* this function has to be in a .mm file */
393 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
396 #endif /* __ardour_plugin_ui_h__ */