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__
27 #include <sigc++/signal.h>
29 #include <gtkmm/button.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/table.h>
32 #include <gtkmm/eventbox.h>
33 #include <gtkmm/viewport.h>
34 #include <gtkmm/scrolledwindow.h>
35 #include <gtkmm/label.h>
36 #include <gtkmm/menu.h>
37 #include <gtkmm/image.h>
38 #include <gtkmm/adjustment.h>
39 #include <gtkmm/togglebutton.h>
40 #include <gtkmm/socket.h>
41 #include <gtkmm/comboboxtext.h>
42 #include <gtkmm/socket.h>
44 #include "ardour/types.h"
46 #include "automation_controller.h"
61 class HSliderController;
71 class PlugUIBase : public virtual sigc::trackable
74 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
75 virtual ~PlugUIBase();
77 virtual gint get_preferred_height () = 0;
78 virtual gint get_preferred_width () = 0;
79 virtual bool start_updating(GdkEventAny*) = 0;
80 virtual bool stop_updating(GdkEventAny*) = 0;
82 virtual void activate () {}
83 virtual void deactivate () {}
85 virtual void update_presets ();
87 void latency_button_clicked ();
90 boost::shared_ptr<ARDOUR::PluginInsert> insert;
91 boost::shared_ptr<ARDOUR::Plugin> plugin;
92 Gtk::ComboBoxText preset_combo;
93 Gtk::Button save_button;
94 Gtk::ToggleButton bypass_button;
95 Gtk::EventBox focus_button;
97 Gtk::Label latency_label;
98 Gtk::Button latency_button;
99 void set_latency_label ();
101 LatencyGUI* latency_gui;
102 ArdourDialog* latency_dialog;
104 Gtk::Expander plugin_eq_bin;
105 Gtk::ToggleButton eqgui_toggle;
107 Gtk::Image* focus_out_image;
108 Gtk::Image* focus_in_image;
110 void setting_selected();
111 void save_plugin_setting (void);
112 bool focus_toggled(GdkEventButton*);
113 void bypass_toggled();
114 void toggle_plugin_analysis ();
115 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
118 class GenericPluginUI : public PlugUIBase, public Gtk::HPaned
121 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
124 gint get_preferred_height () { return prefheight; }
125 gint get_preferred_width () { return -1; }
127 bool start_updating(GdkEventAny*);
128 bool stop_updating(GdkEventAny*);
131 Gtk::VBox main_contents;
133 Gtk::HBox settings_box;
136 Gtk::Table button_table;
137 Gtk::Table output_table;
139 Gtk::ScrolledWindow scroller;
140 Gtk::Adjustment hAdjustment;
141 Gtk::Adjustment vAdjustment;
142 Gtk::Viewport scroller_view;
143 Gtk::Menu* automation_menu;
149 Gtkmm2ext::FastMeter *meter;
167 static const int32_t initial_button_rows = 6;
168 static const int32_t initial_button_cols = 1;
169 static const int32_t initial_output_rows = 1;
170 static const int32_t initial_output_cols = 4;
172 /* FIXME: Unify with AutomationController */
173 struct ControlUI : public Gtk::HBox {
175 boost::shared_ptr<ARDOUR::AutomationControl> control;
177 Evoral::Parameter parameter() { return control->parameter(); }
181 Gtk::ComboBoxText* combo;
182 std::map<string, float>* combo_map;
183 Gtk::ToggleButton* button;
184 boost::shared_ptr<AutomationController> controller;
185 Gtkmm2ext::ClickBox* clickbox;
190 Gtk::Button automate_button;
194 Gtk::EventBox *display;
195 Gtk::Label* display_label;
199 MeterInfo * meterinfo;
205 std::vector<ControlUI*> output_controls;
206 sigc::connection screen_update_connection;
207 void output_update();
210 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
211 std::vector<string> setup_scale_values(guint32 port_index, ControlUI* cui);
212 void parameter_changed (ControlUI* cui);
213 void toggle_parameter_changed (ControlUI* cui);
214 void update_control_display (ControlUI* cui);
215 void control_port_toggled (ControlUI* cui);
216 void control_combo_changed (ControlUI* cui);
218 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
220 void astate_clicked (ControlUI*, uint32_t parameter);
221 void automation_state_changed (ControlUI*);
222 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
223 void start_touch (ControlUI*);
224 void stop_touch (ControlUI*);
226 void print_parameter (char *buf, uint32_t len, uint32_t param);
229 class PluginUIWindow : public Gtk::Window
232 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
235 PlugUIBase& pluginui() { return *_pluginui; }
237 void resize_preferred();
238 void set_parent (Gtk::Window*);
240 bool on_enter_notify_event (GdkEventCrossing*);
241 bool on_leave_notify_event (GdkEventCrossing*);
242 bool on_focus_in_event (GdkEventFocus*);
243 bool on_focus_out_event (GdkEventFocus*);
244 bool on_key_press_event (GdkEventKey*);
245 bool on_key_release_event (GdkEventKey*);
251 PlugUIBase* _pluginui;
252 sigc::connection death_connection;
258 void app_activated (bool);
259 void plugin_going_away ();
261 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
262 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
263 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
267 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
270 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
273 gint get_preferred_height ();
274 gint get_preferred_width ();
275 bool start_updating(GdkEventAny*) {return false;}
276 bool stop_updating(GdkEventAny*) {return false;}
278 int package (Gtk::Window&);
281 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
283 Gtk::HBox preset_box;
286 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
287 void save_plugin_setting ();
289 #endif // VST_SUPPORT
291 #ifdef HAVE_AUDIOUNITS
292 /* this function has to be in a .mm file */
293 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
296 #endif /* __ardour_plugin_ui_h__ */