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"
66 class HSliderController;
77 class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
80 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
81 virtual ~PlugUIBase();
83 virtual gint get_preferred_height () = 0;
84 virtual gint get_preferred_width () = 0;
85 virtual bool start_updating(GdkEventAny*) = 0;
86 virtual bool stop_updating(GdkEventAny*) = 0;
88 virtual void activate () {}
89 virtual void deactivate () {}
91 void update_preset_list ();
92 void update_preset ();
94 void latency_button_clicked ();
96 virtual bool on_window_show(const std::string& /*title*/) { return true; }
97 virtual void on_window_hide() {}
99 virtual void forward_key_event (GdkEventKey*) {}
100 virtual bool non_gtk_gui() const { return false; }
102 sigc::signal<void,bool> KeyboardFocused;
105 boost::shared_ptr<ARDOUR::PluginInsert> insert;
106 boost::shared_ptr<ARDOUR::Plugin> plugin;
107 Gtk::HBox _preset_box;
108 Gtk::ComboBoxText _preset_combo;
109 Gtk::Label _preset_modified;
110 Gtk::Button add_button;
111 Gtk::Button save_button;
112 Gtk::Button delete_button;
113 Gtk::ToggleButton bypass_button;
114 Gtk::EventBox focus_button;
116 Gtk::Label latency_label;
117 Gtk::Button latency_button;
118 void set_latency_label ();
120 LatencyGUI* latency_gui;
121 ArdourDialog* latency_dialog;
123 Gtk::Expander plugin_analysis_expander;
125 Gtk::Requisition pre_eq_size;
127 Gtk::Image* focus_out_image;
128 Gtk::Image* focus_in_image;
131 virtual void preset_selected ();
132 void add_plugin_setting ();
133 void save_plugin_setting ();
134 void delete_plugin_setting ();
135 bool focus_toggled(GdkEventButton*);
136 void bypass_toggled();
137 void toggle_plugin_analysis ();
138 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
139 void plugin_going_away ();
140 virtual void parameter_changed (uint32_t, float);
141 void preset_added_or_removed ();
142 void update_preset_modified ();
144 PBD::ScopedConnection death_connection;
145 PBD::ScopedConnection active_connection;
146 PBD::ScopedConnection preset_added_connection;
147 PBD::ScopedConnection preset_removed_connection;
148 PBD::ScopedConnectionList control_connections;
151 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
154 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
157 gint get_preferred_height () { return prefheight; }
158 gint get_preferred_width () { return -1; }
160 bool start_updating(GdkEventAny*);
161 bool stop_updating(GdkEventAny*);
164 Gtk::VBox main_contents;
166 Gtk::HBox settings_box;
169 Gtk::Table button_table;
170 Gtk::Table output_table;
172 Gtk::ScrolledWindow scroller;
173 Gtk::Adjustment hAdjustment;
174 Gtk::Adjustment vAdjustment;
175 Gtk::Viewport scroller_view;
176 Gtk::Menu* automation_menu;
182 Gtkmm2ext::FastMeter *meter;
190 MeterInfo (int /*i*/) {
200 static const int32_t initial_button_rows = 12;
201 static const int32_t initial_button_cols = 1;
202 static const int32_t initial_output_rows = 1;
203 static const int32_t initial_output_cols = 4;
205 /* FIXME: Unify with AutomationController */
206 struct ControlUI : public Gtk::HBox {
209 boost::shared_ptr<ARDOUR::AutomationControl> control;
211 Evoral::Parameter parameter() { return control->parameter(); }
215 Gtk::ComboBoxText* combo;
216 boost::shared_ptr<ARDOUR::Plugin::ScalePoints> combo_map;
217 Gtk::ToggleButton* button;
218 boost::shared_ptr<AutomationController> controller;
219 Gtkmm2ext::ClickBox* clickbox;
223 Gtk::Button automate_button;
227 Gtk::EventBox* display;
228 Gtk::Label* display_label;
232 MeterInfo* meterinfo;
238 std::vector<ControlUI*> input_controls;
239 std::vector<ControlUI*> output_controls;
240 sigc::connection screen_update_connection;
241 void output_update();
244 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
245 void ui_parameter_changed (ControlUI* cui);
246 void toggle_parameter_changed (ControlUI* cui);
247 void update_control_display (ControlUI* cui);
248 void control_port_toggled (ControlUI* cui);
249 void control_combo_changed (ControlUI* cui);
251 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
253 void astate_clicked (ControlUI*, uint32_t parameter);
254 void automation_state_changed (ControlUI*);
255 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
256 void start_touch (ControlUI*);
257 void stop_touch (ControlUI*);
259 void print_parameter (char *buf, uint32_t len, uint32_t param);
262 class PluginUIWindow : public Gtk::Window
265 PluginUIWindow (Gtk::Window*,
266 boost::shared_ptr<ARDOUR::PluginInsert> insert,
267 bool scrollable=false,
271 PlugUIBase& pluginui() { return *_pluginui; }
273 void resize_preferred();
274 void set_parent (Gtk::Window*);
275 void set_title(const std::string& title);
278 bool on_enter_notify_event (GdkEventCrossing*);
279 bool on_leave_notify_event (GdkEventCrossing*);
280 bool on_focus_in_event (GdkEventFocus*);
281 bool on_focus_out_event (GdkEventFocus*);
282 bool on_key_press_event (GdkEventKey*);
283 bool on_key_release_event (GdkEventKey*);
290 PlugUIBase* _pluginui;
291 PBD::ScopedConnection death_connection;
295 bool _keyboard_focused;
296 void keyboard_focused (bool yn);
298 void app_activated (bool);
299 void plugin_going_away ();
301 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
302 bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>);
303 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
304 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
307 #ifdef AUDIOUNIT_SUPPORT
308 /* this function has to be in a .mm file */
309 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
312 #endif /* __ardour_plugin_ui_h__ */