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/togglebutton.h>
38 #include <gtkmm/socket.h>
39 #include <gtkmm/comboboxtext.h>
40 #include <gtkmm/socket.h>
42 #include <ardour/types.h>
44 #include "ardour_dialog.h"
45 #include "latency_gui.h"
46 #include "automation_controller.h"
61 class HSliderController;
68 class PlugUIBase : public virtual sigc::trackable
71 PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
72 virtual ~PlugUIBase() {}
74 virtual gint get_preferred_height () = 0;
75 virtual gint get_preferred_width () = 0;
76 virtual bool start_updating(GdkEventAny*) = 0;
77 virtual bool stop_updating(GdkEventAny*) = 0;
79 virtual void activate () {}
80 virtual void deactivate () {}
82 virtual void update_presets ();
85 boost::shared_ptr<ARDOUR::PluginInsert> insert;
86 boost::shared_ptr<ARDOUR::Plugin> plugin;
87 Gtk::ComboBoxText preset_combo;
88 Gtk::Button save_button;
89 Gtk::ToggleButton bypass_button;
90 LatencyGUI latency_gui;
92 void setting_selected();
93 void save_plugin_setting (void);
94 void bypass_toggled();
95 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
98 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
101 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
104 gint get_preferred_height () { return prefheight; }
105 gint get_preferred_width () { return -1; }
107 bool start_updating(GdkEventAny*);
108 bool stop_updating(GdkEventAny*);
111 Gtk::HBox settings_box;
114 Gtk::Table button_table;
115 Gtk::Table output_table;
117 Gtk::ScrolledWindow scroller;
118 Gtk::Adjustment hAdjustment;
119 Gtk::Adjustment vAdjustment;
120 Gtk::Viewport scroller_view;
121 Gtk::Menu* automation_menu;
127 Gtkmm2ext::FastMeter *meter;
145 static const int32_t initial_button_rows = 6;
146 static const int32_t initial_button_cols = 1;
147 static const int32_t initial_output_rows = 1;
148 static const int32_t initial_output_cols = 4;
150 /* FIXME: Unify with AutomationController */
151 struct ControlUI : public Gtk::HBox {
153 boost::shared_ptr<ARDOUR::AutomationControl> control;
155 ARDOUR::Parameter parameter() { return control->parameter(); }
159 Gtk::ComboBoxText* combo;
160 std::map<string, float>* combo_map;
161 Gtk::ToggleButton* button;
162 boost::shared_ptr<AutomationController> controller;
163 Gtkmm2ext::ClickBox* clickbox;
168 Gtk::Button automate_button;
172 Gtk::EventBox *display;
173 Gtk::Label* display_label;
177 MeterInfo * meterinfo;
183 std::vector<ControlUI*> output_controls;
184 sigc::connection screen_update_connection;
185 void output_update();
188 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
189 std::vector<string> setup_scale_values(guint32 port_index, ControlUI* cui);
190 void parameter_changed (ControlUI* cui);
191 void update_control_display (ControlUI* cui);
192 void control_port_toggled (ControlUI* cui);
193 void control_combo_changed (ControlUI* cui);
195 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
197 void astate_clicked (ControlUI*, uint32_t parameter);
198 void automation_state_changed (ControlUI*);
199 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
200 void start_touch (ControlUI*);
201 void stop_touch (ControlUI*);
203 void print_parameter (char *buf, uint32_t len, uint32_t param);
206 class PluginUIWindow : public Gtk::Window
209 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
212 PlugUIBase& pluginui() { return *_pluginui; }
214 void resize_preferred();
215 void set_parent (Gtk::Window*);
217 bool on_enter_notify_event (GdkEventCrossing*);
218 bool on_leave_notify_event (GdkEventCrossing*);
219 bool on_key_press_event (GdkEventKey*);
220 bool on_key_release_event (GdkEventKey*);
226 PlugUIBase* _pluginui;
232 void app_activated (bool);
233 void plugin_going_away ();
235 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
236 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
237 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
241 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
244 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
247 gint get_preferred_height ();
248 gint get_preferred_width ();
249 bool start_updating(GdkEventAny*) {return false;}
250 bool stop_updating(GdkEventAny*) {return false;}
252 int package (Gtk::Window&);
255 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
257 Gtk::HBox preset_box;
260 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
261 void save_plugin_setting ();
263 #endif // VST_SUPPORT
265 #ifdef HAVE_AUDIOUNITS
266 /* this function has to be in a .mm file */
267 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
270 #endif /* __ardour_plugin_ui_h__ */