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"
50 #include "automation_controller.h"
51 #include "ardour_button.h"
56 class WindowsVSTPlugin;
67 class HSliderController;
78 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
81 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
82 virtual ~PlugUIBase();
84 virtual gint get_preferred_height () = 0;
85 virtual gint get_preferred_width () = 0;
86 virtual bool start_updating(GdkEventAny*) = 0;
87 virtual bool stop_updating(GdkEventAny*) = 0;
89 virtual void activate () {}
90 virtual void deactivate () {}
92 void update_preset_list ();
93 void update_preset ();
95 void latency_button_clicked ();
97 virtual bool on_window_show(const std::string& /*title*/) { return true; }
98 virtual void on_window_hide() {}
100 virtual void forward_key_event (GdkEventKey*) {}
101 virtual bool non_gtk_gui() const { return false; }
103 sigc::signal<void,bool> KeyboardFocused;
106 boost::shared_ptr<ARDOUR::PluginInsert> insert;
107 boost::shared_ptr<ARDOUR::Plugin> plugin;
108 Gtk::HBox _preset_box;
109 Gtk::ComboBoxText _preset_combo;
110 Gtk::Label _preset_modified;
111 Gtk::Button add_button;
112 Gtk::Button save_button;
113 Gtk::Button delete_button;
114 ArdourButton bypass_button;
115 Gtk::EventBox focus_button;
117 Gtk::Label latency_label;
118 Gtk::Button latency_button;
119 void set_latency_label ();
121 LatencyGUI* latency_gui;
122 ArdourWindow* latency_dialog;
124 Gtk::Expander plugin_analysis_expander;
126 Gtk::Requisition pre_eq_size;
128 Gtk::Image* focus_out_image;
129 Gtk::Image* focus_in_image;
132 virtual void preset_selected ();
133 void add_plugin_setting ();
134 void save_plugin_setting ();
135 void delete_plugin_setting ();
136 bool focus_toggled(GdkEventButton*);
137 bool bypass_button_release(GdkEventButton*);
138 void toggle_plugin_analysis ();
139 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
140 void plugin_going_away ();
141 virtual void parameter_changed (uint32_t, float);
142 void preset_added_or_removed ();
143 void update_preset_modified ();
145 PBD::ScopedConnection death_connection;
146 PBD::ScopedConnection active_connection;
147 PBD::ScopedConnection preset_added_connection;
148 PBD::ScopedConnection preset_removed_connection;
149 PBD::ScopedConnectionList control_connections;
152 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
155 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
158 gint get_preferred_height () { return prefheight; }
159 gint get_preferred_width () { return -1; }
161 bool start_updating(GdkEventAny*);
162 bool stop_updating(GdkEventAny*);
165 Gtk::VBox main_contents;
167 Gtk::HBox settings_box;
170 Gtk::Table button_table;
171 Gtk::Table output_table;
173 Gtk::ScrolledWindow scroller;
174 Gtk::Adjustment hAdjustment;
175 Gtk::Adjustment vAdjustment;
176 Gtk::Viewport scroller_view;
177 Gtk::Menu* automation_menu;
183 Gtkmm2ext::FastMeter *meter;
191 MeterInfo (int /*i*/) {
201 static const int32_t initial_button_rows = 12;
202 static const int32_t initial_button_cols = 1;
203 static const int32_t initial_output_rows = 1;
204 static const int32_t initial_output_cols = 4;
206 /* FIXME: Unify with AutomationController */
207 struct ControlUI : public Gtk::HBox {
210 boost::shared_ptr<ARDOUR::AutomationControl> control;
212 Evoral::Parameter parameter() { return control->parameter(); }
216 Gtk::ComboBoxText* combo;
217 boost::shared_ptr<ARDOUR::Plugin::ScalePoints> combo_map;
218 Gtk::ToggleButton* button;
219 boost::shared_ptr<AutomationController> controller;
220 Gtkmm2ext::ClickBox* clickbox;
224 Gtk::Button automate_button;
228 Gtk::EventBox* display;
229 Gtk::Label* display_label;
233 MeterInfo* meterinfo;
239 std::vector<ControlUI*> input_controls;
240 std::vector<ControlUI*> output_controls;
241 sigc::connection screen_update_connection;
242 void output_update();
245 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
246 void ui_parameter_changed (ControlUI* cui);
247 void toggle_parameter_changed (ControlUI* cui);
248 void update_control_display (ControlUI* cui);
249 void control_port_toggled (ControlUI* cui);
250 void control_combo_changed (ControlUI* cui);
252 void astate_clicked (ControlUI*, uint32_t parameter);
253 void automation_state_changed (ControlUI*);
254 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
255 void start_touch (ControlUI*);
256 void stop_touch (ControlUI*);
258 void print_parameter (char *buf, uint32_t len, uint32_t param);
261 class PluginUIWindow : public Gtk::Window
264 PluginUIWindow (Gtk::Window*,
265 boost::shared_ptr<ARDOUR::PluginInsert> insert,
266 bool scrollable=false,
270 PlugUIBase& pluginui() { return *_pluginui; }
272 void resize_preferred();
273 void set_parent (Gtk::Window*);
274 void set_title(const std::string& title);
277 bool on_enter_notify_event (GdkEventCrossing*);
278 bool on_leave_notify_event (GdkEventCrossing*);
279 bool on_focus_in_event (GdkEventFocus*);
280 bool on_focus_out_event (GdkEventFocus*);
281 bool on_key_press_event (GdkEventKey*);
282 bool on_key_release_event (GdkEventKey*);
289 PlugUIBase* _pluginui;
290 PBD::ScopedConnection death_connection;
294 bool _keyboard_focused;
295 void keyboard_focused (bool yn);
297 void app_activated (bool);
298 void plugin_going_away ();
300 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
301 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
302 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
303 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
306 #ifdef AUDIOUNIT_SUPPORT
307 /* this function has to be in a .mm file */
308 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
311 #endif /* __ardour_plugin_ui_h__ */