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"
65 class HSliderController;
75 class PlugUIBase : public virtual sigc::trackable
78 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
79 virtual ~PlugUIBase();
81 virtual gint get_preferred_height () = 0;
82 virtual gint get_preferred_width () = 0;
83 virtual bool start_updating(GdkEventAny*) = 0;
84 virtual bool stop_updating(GdkEventAny*) = 0;
86 virtual void activate () {}
87 virtual void deactivate () {}
89 virtual void update_presets ();
91 void latency_button_clicked ();
93 virtual bool on_window_show(const std::string& /*title*/) { return true; }
94 virtual void on_window_hide() {}
96 virtual void forward_key_event (GdkEventKey*) {}
97 virtual bool non_gtk_gui() const { return false; }
99 sigc::signal<void,bool> KeyboardFocused;
102 boost::shared_ptr<ARDOUR::PluginInsert> insert;
103 boost::shared_ptr<ARDOUR::Plugin> plugin;
104 Gtk::ComboBoxText preset_combo;
105 Gtk::Button add_button;
106 Gtk::Button save_button;
107 Gtk::Button delete_button;
108 Gtk::ToggleButton bypass_button;
109 Gtk::EventBox focus_button;
111 Gtk::Label latency_label;
112 Gtk::Button latency_button;
113 void set_latency_label ();
115 LatencyGUI* latency_gui;
116 ArdourDialog* latency_dialog;
118 Gtk::Expander plugin_analysis_expander;
120 Gtk::Image* focus_out_image;
121 Gtk::Image* focus_in_image;
124 void setting_selected();
125 void add_plugin_setting ();
126 void save_plugin_setting ();
127 void delete_plugin_setting ();
128 bool focus_toggled(GdkEventButton*);
129 void bypass_toggled();
130 void toggle_plugin_analysis ();
131 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
132 void plugin_going_away ();
133 void update_sensitivity ();
135 PBD::ScopedConnection death_connection;
136 PBD::ScopedConnection active_connection;
137 PBD::ScopedConnection preset_added_connection;
138 PBD::ScopedConnection preset_removed_connection;
139 PBD::ScopedConnectionList control_connections;
142 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
145 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
148 gint get_preferred_height () { return prefheight; }
149 gint get_preferred_width () { return -1; }
151 bool start_updating(GdkEventAny*);
152 bool stop_updating(GdkEventAny*);
155 Gtk::VBox main_contents;
157 Gtk::HBox settings_box;
160 Gtk::Table button_table;
161 Gtk::Table output_table;
163 Gtk::ScrolledWindow scroller;
164 Gtk::Adjustment hAdjustment;
165 Gtk::Adjustment vAdjustment;
166 Gtk::Viewport scroller_view;
167 Gtk::Menu* automation_menu;
173 Gtkmm2ext::FastMeter *meter;
181 MeterInfo (int /*i*/) {
191 static const int32_t initial_button_rows = 12;
192 static const int32_t initial_button_cols = 1;
193 static const int32_t initial_output_rows = 1;
194 static const int32_t initial_output_cols = 4;
196 /* FIXME: Unify with AutomationController */
197 struct ControlUI : public Gtk::HBox {
199 boost::shared_ptr<ARDOUR::AutomationControl> control;
201 Evoral::Parameter parameter() { return control->parameter(); }
205 Gtk::ComboBoxText* combo;
206 std::map<std::string, float>* combo_map;
207 Gtk::ToggleButton* button;
208 boost::shared_ptr<AutomationController> controller;
209 Gtkmm2ext::ClickBox* clickbox;
214 Gtk::Button automate_button;
218 Gtk::EventBox *display;
219 Gtk::Label* display_label;
223 MeterInfo * meterinfo;
229 std::vector<ControlUI*> input_controls;
230 std::vector<ControlUI*> output_controls;
231 sigc::connection screen_update_connection;
232 void output_update();
235 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
236 std::vector<std::string> setup_scale_values(guint32 port_index, ControlUI* cui);
237 void parameter_changed (ControlUI* cui);
238 void toggle_parameter_changed (ControlUI* cui);
239 void update_control_display (ControlUI* cui);
240 void control_port_toggled (ControlUI* cui);
241 void control_combo_changed (ControlUI* cui);
243 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
245 void astate_clicked (ControlUI*, uint32_t parameter);
246 void automation_state_changed (ControlUI*);
247 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
248 void start_touch (ControlUI*);
249 void stop_touch (ControlUI*);
251 void print_parameter (char *buf, uint32_t len, uint32_t param);
254 class PluginUIWindow : public Gtk::Window
257 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
260 PlugUIBase& pluginui() { return *_pluginui; }
262 void resize_preferred();
263 void set_parent (Gtk::Window*);
264 void set_title(const std::string& title);
267 bool on_enter_notify_event (GdkEventCrossing*);
268 bool on_leave_notify_event (GdkEventCrossing*);
269 bool on_focus_in_event (GdkEventFocus*);
270 bool on_focus_out_event (GdkEventFocus*);
271 bool on_key_press_event (GdkEventKey*);
272 bool on_key_release_event (GdkEventKey*);
279 PlugUIBase* _pluginui;
280 PBD::ScopedConnection death_connection;
284 bool _keyboard_focused;
285 void keyboard_focused (bool yn);
287 void app_activated (bool);
288 void plugin_going_away ();
290 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
291 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
292 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
296 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
299 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
302 gint get_preferred_height ();
303 gint get_preferred_width ();
304 bool start_updating(GdkEventAny*) {return false;}
305 bool stop_updating(GdkEventAny*) {return false;}
307 int package (Gtk::Window&);
310 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
312 Gtk::HBox preset_box;
314 Gtk::ComboBox vst_preset_combo;
315 Glib::RefPtr<Gtk::ListStore> preset_model;
317 struct PresetModelColumns : public Gtk::TreeModel::ColumnRecord {
318 PresetModelColumns() {
322 Gtk::TreeModelColumn<std::string> name;
323 Gtk::TreeModelColumn<int> number;
326 PresetModelColumns preset_columns;
328 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
329 void save_plugin_setting ();
330 void preset_chosen ();
331 void update_presets ();
333 #endif // VST_SUPPORT
336 /* this function has to be in a .mm file */
337 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
340 #endif /* __ardour_plugin_ui_h__ */