Ardour  9.0-pre0-582-g084a23a80d
plugin_ui.h
Go to the documentation of this file.
1 /*
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>
9  *
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.
14  *
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.
19  *
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.
23  */
24 
25 #pragma once
26 
27 #ifdef WAF_BUILD
28 #include "gtk2ardour-config.h"
29 #endif
30 
31 #include <vector>
32 #include <map>
33 #include <list>
34 
35 #include <sigc++/signal.h>
36 
37 #include <gtkmm/adjustment.h>
38 #include <gtkmm/box.h>
39 #include <gtkmm/button.h>
40 #include <gtkmm/eventbox.h>
41 #include <gtkmm/expander.h>
43 #include <gtkmm/image.h>
44 #include <gtkmm/label.h>
45 #include <gtkmm/menu.h>
46 #include <gtkmm/scrolledwindow.h>
47 #include <gtkmm/socket.h>
48 #include <gtkmm/togglebutton.h>
49 #include <gtkmm/viewport.h>
50 
51 #include "ardour/types.h"
52 #include "ardour/plugin.h"
53 #include "ardour/variant.h"
54 
55 #include "widgets/ardour_button.h"
57 #include "widgets/ardour_spinner.h"
58 
59 #include "ardour_window.h"
60 #include "automation_controller.h"
61 #include "pianokeyboard.h"
62 
63 namespace ARDOUR {
64  class PluginInsert;
65  class PlugInsertBase;
66  class Plugin;
67  class WindowsVSTPlugin;
68  class LXVSTPlugin;
69  class IOProcessor;
70  class AUPlugin;
71  class Processor;
72 }
73 
74 namespace PBD {
75  class Controllable;
76 }
77 
78 namespace ArdourWidgets {
79  class FastMeter;
80 }
81 
82 class TimeCtlGUI;
83 class ArdourWindow;
84 class PluginEqGui;
85 class PluginLoadStatsGui;
86 class PluginPresetsUI;
87 class VSTPluginUI;
88 
89 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
90 {
91 public:
92  PlugUIBase (std::shared_ptr<ARDOUR::PlugInsertBase>);
93  virtual ~PlugUIBase();
94 
95  virtual gint get_preferred_height () = 0;
96  virtual gint get_preferred_width () = 0;
97  virtual bool resizable () { return true; }
98  virtual bool start_updating(GdkEventAny*) = 0;
99  virtual bool stop_updating(GdkEventAny*) = 0;
100 
101  virtual bool is_external () const { return false; }
102  virtual bool is_external_visible () const { return false; }
103 
104  virtual void activate () {}
105  virtual void deactivate () {}
106 
108  void update_preset ();
109 
112 
113  virtual bool on_window_show(const std::string& /*title*/) { return true; }
114  virtual void on_window_hide() {}
115 
116  virtual void forward_key_event (GdkEventKey*) {}
117  virtual void grab_focus () {}
118  virtual bool non_gtk_gui() const { return false; }
119 
120  sigc::signal<void,bool> KeyboardFocused;
121 
122 protected:
123  std::shared_ptr<ARDOUR::PlugInsertBase> _pib;
124  std::shared_ptr<ARDOUR::PluginInsert> _pi;
125  std::shared_ptr<ARDOUR::Plugin> plugin;
126 
127  void add_common_widgets (Gtk::HBox*, bool with_focus = true);
128 
129  /* UI elements that subclasses can add to their widgets */
130 
171 
175 
179 
184 
186 
192  void browse_presets ();
193  void manage_pins ();
199  void processor_active_changed (std::weak_ptr<ARDOUR::Processor> p);
204 
205  bool has_descriptive_presets () const;
206 
212 
213 private:
216 };
217 
218 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
219 {
220 public:
221  GenericPluginUI (std::shared_ptr<ARDOUR::PlugInsertBase> plug, bool scrollable = false, bool ctrls_only = false);
223 
224  gint get_preferred_height () { return prefheight; }
225  gint get_preferred_width () { return -1; }
226  bool empty () const { return _empty; }
227 
230 
231 private:
236 
240  bool _empty;
241 
242  struct MeterInfo {
244  bool packed;
245 
247  meter = 0;
248  packed = false;
249  }
250  };
251 
252  /* FIXME: Unify with AutomationController */
253  struct ControlUI : public Gtk::HBox {
254 
255  const Evoral::Parameter parameter() const { return param; }
256 
258  std::shared_ptr<ARDOUR::AutomationControl> control;
259 
260  /* input */
261 
262  std::shared_ptr<ARDOUR::ScalePoints> scale_points;
263  std::shared_ptr<AutomationController> controller;
264 
270 
271  bool button;
274 
275 
276  /* output */
277 
280 
284 
287 
288  bool short_autostate; // modify with set_short_autostate below
289  };
290 
291  void set_short_autostate(ControlUI* cui, bool value);
292 
293  std::vector<ControlUI*> input_controls; // workaround for preset load
294  std::vector<ControlUI*> input_controls_with_automation;
295  std::vector<ControlUI*> output_controls;
296 
297  sigc::connection screen_update_connection;
298 
300 
301  void build ();
302  void automatic_layout (const std::vector<ControlUI *>& control_uis);
303 
305  const ARDOUR::ParameterDescriptor& desc,
306  std::shared_ptr<ARDOUR::AutomationControl> mcontrol,
307  float value,
308  bool is_input);
309 
312  void update_input_displays (); // workaround for preset load
313  void control_combo_changed (ControlUI* cui, float value);
314 
319 
321 
322  typedef std::map<uint32_t, Gtk::FileChooserButton*> FilePathControls;
325  Gtk::FileChooserButton* widget);
326  void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
327 
330 
336 
337  void note_on_event_handler (int, int);
339 
343  void midi_bank_patch_change (uint8_t chn);
344  void midi_bank_patch_select (uint8_t chn, uint32_t bankpgm);
345  std::vector<ArdourWidgets::ArdourDropdown*> midi_pgmsel;
347  std::map<uint32_t, std::string> pgm_names;
348 };
349 
351 {
352 public:
353  PluginUIWindow (std::shared_ptr<ARDOUR::PlugInsertBase>,
354  bool scrollable = false,
355  bool editor = true);
357 
358  PlugUIBase& pluginui() { return *_pluginui; }
359 
362  void set_title(const std::string& title);
363 
364 
367  void on_show ();
368  void on_hide ();
369 
370 private:
371  std::string _title;
378 #ifdef AUDIOUNIT_SUPPORT
379  int pre_deactivate_x;
380  int pre_deactivate_y;
381 #endif
382 
383  void keyboard_focused (bool yn);
384 
385  void app_activated (bool);
387 
388  bool create_windows_vst_editor (std::shared_ptr<ARDOUR::PlugInsertBase>);
389  bool create_lxvst_editor(std::shared_ptr<ARDOUR::PlugInsertBase>);
390  bool create_mac_vst_editor(std::shared_ptr<ARDOUR::PlugInsertBase>);
391  bool create_audiounit_editor (std::shared_ptr<ARDOUR::PlugInsertBase>);
392  bool create_lv2_editor (std::shared_ptr<ARDOUR::PlugInsertBase>);
393  bool create_vst3_editor (std::shared_ptr<ARDOUR::PlugInsertBase>);
394 
396 };
397 
398 #ifdef MACVST_SUPPORT
399 /* this function has to be in a .mm file
400  * because MacVSTPluginUI has Cocoa members
401  */
402 extern VSTPluginUI* create_mac_vst_gui (std::shared_ptr<ARDOUR::PlugInsertBase>);
403 #endif
404 
405 #ifdef AUDIOUNIT_SUPPORT
406 /* this function has to be in a .mm file */
407 extern PlugUIBase* create_au_gui (std::shared_ptr<ARDOUR::PlugInsertBase>, Gtk::VBox**);
408 #endif
409 
void output_update()
gint get_preferred_height()
Definition: plugin_ui.h:224
Gtk::Expander _plugin_pianokeyboard_expander
Definition: plugin_ui.h:331
ControlUI * build_control_ui(const Evoral::Parameter &param, const ARDOUR::ParameterDescriptor &desc, std::shared_ptr< ARDOUR::AutomationControl > mcontrol, float value, bool is_input)
void midi_bank_patch_change(uint8_t chn)
void midi_bank_patch_select(uint8_t chn, uint32_t bankpgm)
bool start_updating(GdkEventAny *)
void automatic_layout(const std::vector< ControlUI * > &control_uis)
FilePathControls _filepath_controls
Definition: plugin_ui.h:323
Gtk::SpinButton _piano_velocity
Definition: plugin_ui.h:334
Gtk::Menu * automation_menu
Definition: plugin_ui.h:235
void midi_refill_patches()
Gtk::VBox main_contents
Definition: plugin_ui.h:232
std::vector< ControlUI * > output_controls
Definition: plugin_ui.h:295
std::vector< ArdourWidgets::ArdourDropdown * > midi_pgmsel
Definition: plugin_ui.h:345
void ui_parameter_changed(ControlUI *cui)
void update_control_display(ControlUI *cui)
void build_midi_table()
void set_automation_state(ARDOUR::AutoState state, ControlUI *cui)
void set_path_property(const ARDOUR::ParameterDescriptor &desc, Gtk::FileChooserButton *widget)
void automation_state_changed(ControlUI *)
void control_combo_changed(ControlUI *cui, float value)
Gtk::HBox hpacker
Definition: plugin_ui.h:234
bool is_scrollable
Definition: plugin_ui.h:238
Gtk::VBox settings_box
Definition: plugin_ui.h:233
void set_all_automation(ARDOUR::AutoState state)
std::map< uint32_t, std::string > pgm_names
Definition: plugin_ui.h:347
bool empty() const
Definition: plugin_ui.h:226
sigc::connection screen_update_connection
Definition: plugin_ui.h:297
void path_property_changed(uint32_t key, const ARDOUR::Variant &value)
GenericPluginUI(std::shared_ptr< ARDOUR::PlugInsertBase > plug, bool scrollable=false, bool ctrls_only=false)
bool stop_updating(GdkEventAny *)
void toggle_pianokeyboard()
gint get_preferred_width()
Definition: plugin_ui.h:225
std::vector< ControlUI * > input_controls_with_automation
Definition: plugin_ui.h:294
void note_on_event_handler(int, int)
void scroller_size_request(Gtk::Requisition *)
bool astate_button_event(GdkEventButton *ev, ControlUI *)
void set_short_autostate(ControlUI *cui, bool value)
APianoKeyboard * _piano
Definition: plugin_ui.h:332
void update_input_displays()
void note_off_event_handler(int)
Gtk::SpinButton _piano_channel
Definition: plugin_ui.h:335
Gtk::ScrolledWindow scroller
Definition: plugin_ui.h:329
std::vector< ControlUI * > input_controls
Definition: plugin_ui.h:293
bool want_ctrl_only
Definition: plugin_ui.h:239
std::map< uint32_t, Gtk::FileChooserButton * > FilePathControls
Definition: plugin_ui.h:322
PBD::ScopedConnectionList midi_connections
Definition: plugin_ui.h:346
Gtk::VBox _pianobox
Definition: plugin_ui.h:333
void knob_size_request(Gtk::Requisition *req, ControlUI *cui)
virtual void on_window_hide()
Definition: plugin_ui.h:114
void update_preset_list()
Gtk::Image * _focus_in_image
Definition: plugin_ui.h:215
bool focus_toggled(GdkEventButton *)
virtual void preset_selected(ARDOUR::Plugin::PresetRecord preset)
virtual bool stop_updating(GdkEventAny *)=0
PBD::ScopedConnection preset_removed_connection
Definition: plugin_ui.h:210
ArdourWidgets::ArdourButton _add_button
Definition: plugin_ui.h:136
Gtk::EventBox _focus_button
Definition: plugin_ui.h:150
ArdourWidgets::ArdourButton automation_latch_all_button
Definition: plugin_ui.h:170
void set_tailtime_label()
virtual void forward_key_event(GdkEventKey *)
Definition: plugin_ui.h:116
ArdourWindow * tailtime_dialog
Definition: plugin_ui.h:178
virtual gint get_preferred_width()=0
void add_plugin_setting()
ArdourWidgets::ArdourButton _pin_management_button
Definition: plugin_ui.h:148
virtual bool non_gtk_gui() const
Definition: plugin_ui.h:118
Gtk::Label _preset_modified
Definition: plugin_ui.h:134
void update_preset_modified()
PBD::ScopedConnection active_connection
Definition: plugin_ui.h:208
ArdourWidgets::ArdourButton automation_play_all_button
Definition: plugin_ui.h:164
std::shared_ptr< ARDOUR::PlugInsertBase > _pib
Definition: plugin_ui.h:123
Gtk::Image * _focus_out_image
Definition: plugin_ui.h:214
PluginPresetsUI * preset_gui
Definition: plugin_ui.h:182
void delete_plugin_setting()
virtual gint get_preferred_height()=0
void latency_button_clicked()
std::shared_ptr< ARDOUR::PluginInsert > _pi
Definition: plugin_ui.h:124
ArdourWidgets::ArdourButton _save_button
Definition: plugin_ui.h:138
virtual bool is_external_visible() const
Definition: plugin_ui.h:102
ArdourWidgets::ArdourButton _reset_button
Definition: plugin_ui.h:144
Gtk::Expander plugin_analysis_expander
Definition: plugin_ui.h:154
Gtk::Expander description_expander
Definition: plugin_ui.h:152
void toggle_cpuload_display()
void toggle_plugin_analysis()
virtual bool on_window_show(const std::string &)
Definition: plugin_ui.h:113
void reset_plugin_parameters()
void plugin_going_away()
virtual void deactivate()
Definition: plugin_ui.h:105
void automation_state_changed()
PluginLoadStatsGui * stats_gui
Definition: plugin_ui.h:181
ArdourWidgets::ArdourButton automation_touch_all_button
Definition: plugin_ui.h:168
void processor_active_changed(std::weak_ptr< ARDOUR::Processor > p)
sigc::signal< void, bool > KeyboardFocused
Definition: plugin_ui.h:120
virtual ~PlugUIBase()
void toggle_description()
ArdourWidgets::ArdourButton automation_manual_all_button
Definition: plugin_ui.h:162
virtual bool is_external() const
Definition: plugin_ui.h:101
void save_plugin_setting()
ArdourWindow * latency_dialog
Definition: plugin_ui.h:174
void tailtime_button_clicked()
TimeCtlGUI * tailtime_gui
Definition: plugin_ui.h:177
TimeCtlGUI * latency_gui
Definition: plugin_ui.h:173
ArdourWidgets::ArdourButton _preset_browser_button
Definition: plugin_ui.h:142
int _no_load_preset
Definition: plugin_ui.h:185
ArdourWidgets::ArdourButton _tailtime_button
Definition: plugin_ui.h:160
void add_common_widgets(Gtk::HBox *, bool with_focus=true)
Gtk::Expander cpuload_expander
Definition: plugin_ui.h:156
PBD::ScopedConnectionList control_connections
Definition: plugin_ui.h:211
PlugUIBase(std::shared_ptr< ARDOUR::PlugInsertBase >)
PBD::ScopedConnection death_connection
Definition: plugin_ui.h:207
void set_latency_label()
ArdourWidgets::ArdourButton _bypass_button
Definition: plugin_ui.h:146
virtual void activate()
Definition: plugin_ui.h:104
PBD::ScopedConnection preset_added_connection
Definition: plugin_ui.h:209
ArdourWindow * preset_dialog
Definition: plugin_ui.h:183
void preset_added_or_removed()
virtual bool start_updating(GdkEventAny *)=0
void manage_pins()
void browse_presets()
ArdourWidgets::ArdourButton _delete_button
Definition: plugin_ui.h:140
bool bypass_button_release(GdkEventButton *)
void update_preset()
std::shared_ptr< ARDOUR::Plugin > plugin
Definition: plugin_ui.h:125
ArdourWidgets::ArdourButton automation_write_all_button
Definition: plugin_ui.h:166
virtual bool resizable()
Definition: plugin_ui.h:97
bool has_descriptive_presets() const
virtual void grab_focus()
Definition: plugin_ui.h:117
ArdourWidgets::ArdourButton _latency_button
Definition: plugin_ui.h:158
ArdourWidgets::ArdourDropdown _preset_combo
Definition: plugin_ui.h:132
PluginEqGui * eqgui
Definition: plugin_ui.h:180
bool was_visible
Definition: plugin_ui.h:376
void keyboard_focused(bool yn)
Gtk::VBox vbox
Definition: plugin_ui.h:375
bool create_windows_vst_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
void on_hide()
This is a default handler for the signal signal_hide().
bool create_lv2_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
std::string _title
Definition: plugin_ui.h:371
bool create_vst3_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
void set_title(const std::string &title)
void app_activated(bool)
void plugin_going_away()
Gtk::Window * parent
Definition: plugin_ui.h:374
bool _keyboard_focused
Definition: plugin_ui.h:377
PlugUIBase & pluginui()
Definition: plugin_ui.h:358
void resize_preferred()
void set_parent(Gtk::Window *)
bool create_lxvst_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
bool create_audiounit_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
PlugUIBase * _pluginui
Definition: plugin_ui.h:372
bool on_key_press_event(GdkEventKey *)
This is a default handler for the signal signal_key_press_event().
static PluginUIWindow * the_plugin_window
Definition: plugin_ui.h:395
bool on_key_release_event(GdkEventKey *)
This is a default handler for the signal signal_key_release_event().
PluginUIWindow(std::shared_ptr< ARDOUR::PlugInsertBase >, bool scrollable=false, bool editor=true)
void on_show()
This is a default handler for the signal signal_show().
PBD::ScopedConnection death_connection
Definition: plugin_ui.h:373
bool create_mac_vst_editor(std::shared_ptr< ARDOUR::PlugInsertBase >)
std::shared_ptr< PBD::Controllable > Controllable
Definition: console1.h:80
Definition: axis_view.h:42
Gtk::EventBox * display
Definition: plugin_ui.h:278
Gtk::FileChooserButton * file_button
Definition: plugin_ui.h:268
ArdourWidgets::ArdourButton automate_button
Definition: plugin_ui.h:265
std::shared_ptr< AutomationController > controller
Definition: plugin_ui.h:263
std::shared_ptr< ARDOUR::ScalePoints > scale_points
Definition: plugin_ui.h:262
Gtk::Label * display_label
Definition: plugin_ui.h:279
ControlUI(const Evoral::Parameter &param)
ArdourWidgets::ArdourSpinner * spin_box
Definition: plugin_ui.h:269
Evoral::Parameter param
Definition: plugin_ui.h:257
const Evoral::Parameter parameter() const
Definition: plugin_ui.h:255
ArdourWidgets::ArdourDropdown * combo
Definition: plugin_ui.h:267
std::shared_ptr< ARDOUR::AutomationControl > control
Definition: plugin_ui.h:258
ArdourWidgets::FastMeter * meter
Definition: plugin_ui.h:243