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/adjustment.h>
38 #include <gtkmm/togglebutton.h>
39 #include <gtkmm/socket.h>
40 #include <gtkmm/comboboxtext.h>
41 #include <gtkmm/socket.h>
43 #include <ardour_dialog.h>
44 #include <ardour/types.h>
59 class HSliderController;
66 class PlugUIBase : public virtual sigc::trackable
69 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
70 virtual ~PlugUIBase() {}
72 virtual gint get_preferred_height () = 0;
73 virtual gint get_preferred_width () = 0;
74 virtual bool start_updating(GdkEventAny*) = 0;
75 virtual bool stop_updating(GdkEventAny*) = 0;
77 virtual void activate () {}
78 virtual void deactivate () {}
80 virtual void update_presets ();
83 boost::shared_ptr<ARDOUR::PluginInsert> insert;
84 boost::shared_ptr<ARDOUR::Plugin> plugin;
85 Gtk::ComboBoxText preset_combo;
86 Gtk::Button save_button;
87 Gtk::ToggleButton bypass_button;
89 void setting_selected();
90 void save_plugin_setting (void);
91 void bypass_toggled();
92 void redirect_active_changed (ARDOUR::Redirect* r, void* src);
95 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
98 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
101 gint get_preferred_height () { return prefheight; }
102 gint get_preferred_width () { return -1; }
104 bool start_updating(GdkEventAny*);
105 bool stop_updating(GdkEventAny*);
108 Gtk::HBox settings_box;
111 Gtk::Table button_table;
112 Gtk::Table output_table;
114 Gtk::ScrolledWindow scroller;
115 Gtk::Adjustment hAdjustment;
116 Gtk::Adjustment vAdjustment;
117 Gtk::Viewport scroller_view;
118 Gtk::Menu* automation_menu;
124 Gtkmm2ext::FastMeter *meter;
142 static const int32_t initial_button_rows = 6;
143 static const int32_t initial_button_cols = 1;
144 static const int32_t initial_output_rows = 1;
145 static const int32_t initial_output_cols = 4;
147 struct ControlUI : public Gtk::HBox {
153 Gtk::Adjustment* adjustment;
154 Gtk::ComboBoxText* combo;
155 std::map<string, float>* combo_map;
156 Gtk::ToggleButton* button;
157 Gtkmm2ext::BarController* control;
158 Gtkmm2ext::ClickBox* clickbox;
163 Gtk::Button automate_button;
167 Gtk::EventBox *display;
168 Gtk::Label* display_label;
172 MeterInfo * meterinfo;
178 std::vector<ControlUI*> output_controls;
179 sigc::connection screen_update_connection;
180 void output_update();
183 ControlUI* build_control_ui (guint32 port_index, PBD::Controllable *);
184 std::vector<string> setup_scale_values(guint32 port_index, ControlUI* cui);
185 void control_adjustment_changed (ControlUI* cui);
186 void parameter_changed (uint32_t, float, ControlUI* cui);
187 void update_control_display (ControlUI* cui);
188 void control_port_toggled (ControlUI* cui);
189 void control_combo_changed (ControlUI* cui);
191 void redirect_active_changed (ARDOUR::Redirect*, void*);
193 void astate_clicked (ControlUI*, uint32_t parameter);
194 void automation_state_changed (ControlUI*);
195 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
196 void start_touch (ControlUI*);
197 void stop_touch (ControlUI*);
199 void print_parameter (char *buf, uint32_t len, uint32_t param);
202 class PluginUIWindow : public Gtk::Window
205 PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
208 PlugUIBase& pluginui() { return *_pluginui; }
210 void resize_preferred();
212 bool on_key_press_event (GdkEventKey*);
213 bool on_key_release_event (GdkEventKey*);
218 PlugUIBase* _pluginui;
221 void app_activated (bool);
222 void plugin_going_away ();
224 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
225 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
229 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
232 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
235 gint get_preferred_height ();
236 gint get_preferred_width ();
237 bool start_updating(GdkEventAny*) {return false;}
238 bool stop_updating(GdkEventAny*) {return false;}
240 int package (Gtk::Window&);
243 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
245 Gtk::HBox preset_box;
248 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
249 void save_plugin_setting ();
251 #endif // VST_SUPPORT
253 #ifdef HAVE_AUDIOUNITS
254 /* this function has to be in a .mm file */
255 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
258 #endif /* __ardour_plugin_ui_h__ */