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_dialog.h>
45 #include <ardour/types.h>
60 class HSliderController;
67 class PlugUIBase : public virtual sigc::trackable
70 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
71 virtual ~PlugUIBase() {}
73 virtual gint get_preferred_height () = 0;
74 virtual gint get_preferred_width () = 0;
75 virtual bool start_updating(GdkEventAny*) = 0;
76 virtual bool stop_updating(GdkEventAny*) = 0;
78 virtual void activate () {}
79 virtual void deactivate () {}
81 virtual void update_presets ();
84 boost::shared_ptr<ARDOUR::PluginInsert> insert;
85 boost::shared_ptr<ARDOUR::Plugin> plugin;
86 Gtk::ComboBoxText preset_combo;
87 Gtk::Button save_button;
88 Gtk::ToggleButton bypass_button;
89 Gtk::EventBox focus_button;
91 Gtk::Image* focus_out_image;
92 Gtk::Image* focus_in_image;
95 void setting_selected();
96 void save_plugin_setting (void);
97 bool focus_toggled(GdkEventButton*);
98 void bypass_toggled();
99 void redirect_active_changed (ARDOUR::Redirect* r, void* src);
102 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
105 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
108 gint get_preferred_height () { return prefheight; }
109 gint get_preferred_width () { return -1; }
111 bool start_updating(GdkEventAny*);
112 bool stop_updating(GdkEventAny*);
115 Gtk::HBox settings_box;
118 Gtk::Table button_table;
119 Gtk::Table output_table;
121 Gtk::ScrolledWindow scroller;
122 Gtk::Adjustment hAdjustment;
123 Gtk::Adjustment vAdjustment;
124 Gtk::Viewport scroller_view;
125 Gtk::Menu* automation_menu;
131 Gtkmm2ext::FastMeter *meter;
149 static const int32_t initial_button_rows = 6;
150 static const int32_t initial_button_cols = 1;
151 static const int32_t initial_output_rows = 1;
152 static const int32_t initial_output_cols = 4;
154 struct ControlUI : public Gtk::HBox {
160 Gtk::Adjustment* adjustment;
161 Gtk::ComboBoxText* combo;
162 std::map<string, float>* combo_map;
163 Gtk::ToggleButton* button;
164 Gtkmm2ext::BarController* control;
165 Gtkmm2ext::ClickBox* clickbox;
170 Gtk::Button automate_button;
174 Gtk::EventBox *display;
175 Gtk::Label* display_label;
179 MeterInfo * meterinfo;
185 std::vector<ControlUI*> output_controls;
186 sigc::connection screen_update_connection;
187 void output_update();
190 ControlUI* build_control_ui (guint32 port_index, PBD::Controllable *);
191 std::vector<string> setup_scale_values(guint32 port_index, ControlUI* cui);
192 void control_adjustment_changed (ControlUI* cui);
193 void parameter_changed (uint32_t, float, ControlUI* cui);
194 void toggle_parameter_changed (uint32_t, float, ControlUI* cui);
195 void update_control_display (ControlUI* cui);
196 void control_port_toggled (ControlUI* cui);
197 void control_combo_changed (ControlUI* cui);
199 void astate_clicked (ControlUI*, uint32_t parameter);
200 void automation_state_changed (ControlUI*);
201 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
202 void start_touch (ControlUI*);
203 void stop_touch (ControlUI*);
205 void print_parameter (char *buf, uint32_t len, uint32_t param);
208 class PluginUIWindow : public Gtk::Window
211 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
214 PlugUIBase& pluginui() { return *_pluginui; }
216 void resize_preferred();
217 void set_parent (Gtk::Window*);
219 bool on_enter_notify_event (GdkEventCrossing*);
220 bool on_leave_notify_event (GdkEventCrossing*);
221 bool on_focus_in_event (GdkEventFocus*);
222 bool on_focus_out_event (GdkEventFocus*);
223 bool on_key_press_event (GdkEventKey*);
224 bool on_key_release_event (GdkEventKey*);
231 PlugUIBase* _pluginui;
237 void app_activated (bool);
238 void plugin_going_away ();
240 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
241 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
242 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
246 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
249 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
252 gint get_preferred_height ();
253 gint get_preferred_width ();
254 bool start_updating(GdkEventAny*) {return false;}
255 bool stop_updating(GdkEventAny*) {return false;}
257 int package (Gtk::Window&);
260 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
262 Gtk::HBox preset_box;
265 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
266 void save_plugin_setting ();
268 #endif // VST_SUPPORT
270 #ifdef HAVE_AUDIOUNITS
271 /* this function has to be in a .mm file */
272 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
275 #endif /* __ardour_plugin_ui_h__ */