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"
49 #include "ardour/plugin.h"
51 #include "automation_controller.h"
52 #include "ardour_button.h"
57 class WindowsVSTPlugin;
69 class HSliderController;
80 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
83 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
84 virtual ~PlugUIBase();
86 virtual gint get_preferred_height () = 0;
87 virtual gint get_preferred_width () = 0;
88 virtual bool start_updating(GdkEventAny*) = 0;
89 virtual bool stop_updating(GdkEventAny*) = 0;
91 virtual void activate () {}
92 virtual void deactivate () {}
94 void update_preset_list ();
95 void update_preset ();
97 void latency_button_clicked ();
99 virtual bool on_window_show(const std::string& /*title*/) { return true; }
100 virtual void on_window_hide() {}
102 virtual void forward_key_event (GdkEventKey*) {}
103 virtual bool non_gtk_gui() const { return false; }
105 sigc::signal<void,bool> KeyboardFocused;
108 boost::shared_ptr<ARDOUR::PluginInsert> insert;
109 boost::shared_ptr<ARDOUR::Plugin> plugin;
110 Gtk::HBox _preset_box;
111 Gtk::ComboBoxText _preset_combo;
112 Gtk::Label _preset_modified;
113 Gtk::Button add_button;
114 Gtk::Button save_button;
115 Gtk::Button delete_button;
116 ArdourButton bypass_button;
117 Gtk::EventBox focus_button;
119 Gtk::Label latency_label;
120 Gtk::Button latency_button;
121 void set_latency_label ();
123 LatencyGUI* latency_gui;
124 ArdourWindow* latency_dialog;
126 Gtk::Expander plugin_analysis_expander;
128 Gtk::Requisition pre_eq_size;
130 Gtk::Image* focus_out_image;
131 Gtk::Image* focus_in_image;
134 virtual void preset_selected ();
135 void add_plugin_setting ();
136 void save_plugin_setting ();
137 void delete_plugin_setting ();
138 bool focus_toggled(GdkEventButton*);
139 bool bypass_button_release(GdkEventButton*);
140 void toggle_plugin_analysis ();
141 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
142 void plugin_going_away ();
143 virtual void parameter_changed (uint32_t, float);
144 void preset_added_or_removed ();
145 void update_preset_modified ();
147 PBD::ScopedConnection death_connection;
148 PBD::ScopedConnection active_connection;
149 PBD::ScopedConnection preset_added_connection;
150 PBD::ScopedConnection preset_removed_connection;
151 PBD::ScopedConnectionList control_connections;
154 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
157 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
160 gint get_preferred_height () { return prefheight; }
161 gint get_preferred_width () { return -1; }
163 bool start_updating(GdkEventAny*);
164 bool stop_updating(GdkEventAny*);
167 Gtk::VBox main_contents;
169 Gtk::HBox settings_box;
172 Gtk::Table button_table;
173 Gtk::Table output_table;
175 Gtk::ScrolledWindow scroller;
176 Gtk::Adjustment hAdjustment;
177 Gtk::Adjustment vAdjustment;
178 Gtk::Viewport scroller_view;
179 Gtk::Menu* automation_menu;
185 Gtkmm2ext::FastMeter *meter;
193 MeterInfo (int /*i*/) {
203 static const int32_t initial_button_rows = 12;
204 static const int32_t initial_button_cols = 1;
205 static const int32_t initial_output_rows = 1;
206 static const int32_t initial_output_cols = 4;
208 /* FIXME: Unify with AutomationController */
209 struct ControlUI : public Gtk::HBox {
212 boost::shared_ptr<ARDOUR::AutomationControl> control;
214 Evoral::Parameter parameter() { return control->parameter(); }
218 Gtk::ComboBoxText* combo;
219 boost::shared_ptr<ARDOUR::Plugin::ScalePoints> combo_map;
220 Gtk::ToggleButton* button;
221 boost::shared_ptr<AutomationController> controller;
222 Gtkmm2ext::ClickBox* clickbox;
226 Gtk::Button automate_button;
230 Gtk::EventBox* display;
231 Gtk::Label* display_label;
235 MeterInfo* meterinfo;
241 std::vector<ControlUI*> input_controls;
242 std::vector<ControlUI*> output_controls;
243 sigc::connection screen_update_connection;
244 void output_update();
247 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
248 void ui_parameter_changed (ControlUI* cui);
249 void toggle_parameter_changed (ControlUI* cui);
250 void update_control_display (ControlUI* cui);
251 void control_port_toggled (ControlUI* cui);
252 void control_combo_changed (ControlUI* cui);
254 void astate_clicked (ControlUI*, uint32_t parameter);
255 void automation_state_changed (ControlUI*);
256 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
257 void start_touch (ControlUI*);
258 void stop_touch (ControlUI*);
260 void print_parameter (char *buf, uint32_t len, uint32_t param);
263 class PluginUIWindow : public Gtk::Window
266 PluginUIWindow (Gtk::Window*,
267 boost::shared_ptr<ARDOUR::PluginInsert> insert,
268 bool scrollable=false,
272 PlugUIBase& pluginui() { return *_pluginui; }
274 void resize_preferred();
275 void set_parent (Gtk::Window*);
276 void set_title(const std::string& title);
279 bool on_enter_notify_event (GdkEventCrossing*);
280 bool on_leave_notify_event (GdkEventCrossing*);
281 bool on_focus_in_event (GdkEventFocus*);
282 bool on_focus_out_event (GdkEventFocus*);
283 bool on_key_press_event (GdkEventKey*);
284 bool on_key_release_event (GdkEventKey*);
291 PlugUIBase* _pluginui;
292 PBD::ScopedConnection death_connection;
296 bool _keyboard_focused;
297 void keyboard_focused (bool yn);
299 void app_activated (bool);
300 void plugin_going_away ();
302 bool create_windows_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
303 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
304 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
305 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
308 #ifdef AUDIOUNIT_SUPPORT
309 /* this function has to be in a .mm file */
310 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
313 #endif /* __ardour_plugin_ui_h__ */