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_analysis_expander;
106 Gtk::Image* focus_out_image;
107 Gtk::Image* focus_in_image;
109 void setting_selected();
110 void save_plugin_setting (void);
111 bool focus_toggled(GdkEventButton*);
112 void bypass_toggled();
113 void toggle_plugin_analysis ();
114 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
117 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
120 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
123 gint get_preferred_height () { return prefheight; }
124 gint get_preferred_width () { return -1; }
126 bool start_updating(GdkEventAny*);
127 bool stop_updating(GdkEventAny*);
130 Gtk::VBox main_contents;
132 Gtk::HBox settings_box;
135 Gtk::Table button_table;
136 Gtk::Table output_table;
138 Gtk::ScrolledWindow scroller;
139 Gtk::Adjustment hAdjustment;
140 Gtk::Adjustment vAdjustment;
141 Gtk::Viewport scroller_view;
142 Gtk::Menu* automation_menu;
148 Gtkmm2ext::FastMeter *meter;
166 static const int32_t initial_button_rows = 6;
167 static const int32_t initial_button_cols = 1;
168 static const int32_t initial_output_rows = 1;
169 static const int32_t initial_output_cols = 4;
171 /* FIXME: Unify with AutomationController */
172 struct ControlUI : public Gtk::HBox {
174 boost::shared_ptr<ARDOUR::AutomationControl> control;
176 Evoral::Parameter parameter() { return control->parameter(); }
180 Gtk::ComboBoxText* combo;
181 std::map<std::string, float>* combo_map;
182 Gtk::ToggleButton* button;
183 boost::shared_ptr<AutomationController> controller;
184 Gtkmm2ext::ClickBox* clickbox;
189 Gtk::Button automate_button;
193 Gtk::EventBox *display;
194 Gtk::Label* display_label;
198 MeterInfo * meterinfo;
204 std::vector<ControlUI*> output_controls;
205 sigc::connection screen_update_connection;
206 void output_update();
209 ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
210 std::vector<std::string> setup_scale_values(guint32 port_index, ControlUI* cui);
211 void parameter_changed (ControlUI* cui);
212 void toggle_parameter_changed (ControlUI* cui);
213 void update_control_display (ControlUI* cui);
214 void control_port_toggled (ControlUI* cui);
215 void control_combo_changed (ControlUI* cui);
217 void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
219 void astate_clicked (ControlUI*, uint32_t parameter);
220 void automation_state_changed (ControlUI*);
221 void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
222 void start_touch (ControlUI*);
223 void stop_touch (ControlUI*);
225 void print_parameter (char *buf, uint32_t len, uint32_t param);
228 class PluginUIWindow : public Gtk::Window
231 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
234 PlugUIBase& pluginui() { return *_pluginui; }
236 void resize_preferred();
237 void set_parent (Gtk::Window*);
239 bool on_enter_notify_event (GdkEventCrossing*);
240 bool on_leave_notify_event (GdkEventCrossing*);
241 bool on_focus_in_event (GdkEventFocus*);
242 bool on_focus_out_event (GdkEventFocus*);
243 bool on_key_press_event (GdkEventKey*);
244 bool on_key_release_event (GdkEventKey*);
250 PlugUIBase* _pluginui;
251 sigc::connection death_connection;
257 void app_activated (bool);
258 void plugin_going_away ();
260 bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
261 bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
262 bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
266 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
269 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
272 gint get_preferred_height ();
273 gint get_preferred_width ();
274 bool start_updating(GdkEventAny*) {return false;}
275 bool stop_updating(GdkEventAny*) {return false;}
277 int package (Gtk::Window&);
280 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
282 Gtk::HBox preset_box;
285 bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
286 void save_plugin_setting ();
288 #endif // VST_SUPPORT
290 #ifdef HAVE_AUDIOUNITS
291 /* this function has to be in a .mm file */
292 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
295 #endif /* __ardour_plugin_ui_h__ */