Fix some unused parameter warnings.
[ardour.git] / gtk2_ardour / plugin_ui.h
1 /*
2     Copyright (C) 2000-2006 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_plugin_ui_h__
21 #define __ardour_plugin_ui_h__
22
23 #ifdef WAF_BUILD
24 #include "gtk2ardour-config.h"
25 #endif
26
27 #include <vector>
28 #include <map>
29 #include <list>
30
31 #include <sigc++/signal.h>
32
33 #include <gtkmm/button.h>
34 #include <gtkmm/box.h>
35 #include <gtkmm/table.h>
36 #include <gtkmm/eventbox.h>
37 #include <gtkmm/viewport.h>
38 #include <gtkmm/scrolledwindow.h>
39 #include <gtkmm/label.h>
40 #include <gtkmm/menu.h>
41 #include <gtkmm/image.h>
42 #include <gtkmm/adjustment.h>
43 #include <gtkmm/togglebutton.h>
44 #include <gtkmm/socket.h>
45 #include <gtkmm/comboboxtext.h>
46 #include <gtkmm/socket.h>
47
48 #include "ardour/types.h"
49
50 #include "automation_controller.h"
51
52 namespace ARDOUR {
53         class PluginInsert;
54         class Plugin;
55         class VSTPlugin;
56         class IOProcessor;
57         class AUPlugin;
58 }
59
60 namespace PBD {
61         class Controllable;
62 }
63
64 namespace Gtkmm2ext {
65         class HSliderController;
66         class BarController;
67         class ClickBox;
68         class FastMeter;
69         class PixmapButton;
70 }
71
72 class LatencyGUI;
73 class ArdourDialog;
74
75 class PlugUIBase : public virtual sigc::trackable
76 {
77   public:
78         PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>);
79         virtual ~PlugUIBase();
80
81         virtual gint get_preferred_height () = 0;
82         virtual gint get_preferred_width () = 0;
83         virtual bool start_updating(GdkEventAny*) = 0;
84         virtual bool stop_updating(GdkEventAny*) = 0;
85         
86         virtual void activate () {}
87         virtual void deactivate () {}
88
89         virtual void update_presets ();
90
91         void latency_button_clicked ();
92
93   protected:
94         boost::shared_ptr<ARDOUR::PluginInsert> insert;
95         boost::shared_ptr<ARDOUR::Plugin> plugin;
96         Gtk::ComboBoxText preset_combo;
97         Gtk::Button save_button;
98         Gtk::ToggleButton bypass_button;
99         Gtk::EventBox focus_button;
100
101         Gtk::Label latency_label;
102         Gtk::Button latency_button;
103         void set_latency_label ();
104
105         LatencyGUI* latency_gui;
106         ArdourDialog* latency_dialog;
107
108         Gtk::Expander plugin_analysis_expander;
109
110         Gtk::Image* focus_out_image;
111         Gtk::Image* focus_in_image;
112
113         void setting_selected();
114         void save_plugin_setting (void);
115         bool focus_toggled(GdkEventButton*);
116         void bypass_toggled();
117         void toggle_plugin_analysis ();
118         void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
119         void plugin_going_away ();
120 };
121
122 class GenericPluginUI : public PlugUIBase, public Gtk::VBox
123 {
124   public:
125         GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
126         ~GenericPluginUI ();
127         
128         gint get_preferred_height () { return prefheight; }
129         gint get_preferred_width () { return -1; }
130         
131         bool start_updating(GdkEventAny*);
132         bool stop_updating(GdkEventAny*);
133
134   private:
135         Gtk::VBox main_contents;
136
137         Gtk::HBox settings_box;
138         Gtk::HBox hpacker;
139         
140         Gtk::Table button_table;
141         Gtk::Table output_table;
142
143         Gtk::ScrolledWindow scroller;
144         Gtk::Adjustment hAdjustment;
145         Gtk::Adjustment vAdjustment;
146         Gtk::Viewport scroller_view;
147         Gtk::Menu* automation_menu;
148
149         gint prefheight;
150         bool is_scrollable;
151
152         struct MeterInfo {
153                 Gtkmm2ext::FastMeter *meter;
154
155                 float           min;
156                 float           max;
157                 bool            min_unbound;
158                 bool            max_unbound;
159                 bool packed;
160                 
161                 MeterInfo (int /*i*/) { 
162                         meter = 0;
163                         packed = false;
164                         min = 1.0e10;
165                         max = -1.0e10;
166                         min_unbound = false;
167                         max_unbound = false;
168                 }
169         };
170         
171         static const int32_t initial_button_rows = 6;
172         static const int32_t initial_button_cols = 1;
173         static const int32_t initial_output_rows = 1;
174         static const int32_t initial_output_cols = 4;
175
176         /* FIXME: Unify with AutomationController */
177         struct ControlUI : public Gtk::HBox {
178
179                 boost::shared_ptr<ARDOUR::AutomationControl> control;
180
181                 Evoral::Parameter parameter() { return control->parameter(); }
182             
183             /* input */
184             
185             Gtk::ComboBoxText*        combo;
186             std::map<std::string, float>*  combo_map;
187             Gtk::ToggleButton*        button;
188             boost::shared_ptr<AutomationController>  controller;
189             Gtkmm2ext::ClickBox*       clickbox;
190             Gtk::Label         label;
191             bool               logarithmic;
192             bool               update_pending;
193             char               ignore_change;
194             Gtk::Button        automate_button;
195             
196             /* output */
197
198             Gtk::EventBox *display;
199             Gtk::Label*    display_label;
200
201                 Gtk::HBox  *    hbox;
202                 Gtk::VBox  *    vbox;
203             MeterInfo  *    meterinfo;
204
205             ControlUI ();
206             ~ControlUI(); 
207         };
208         
209         std::vector<ControlUI*>   output_controls;
210         sigc::connection screen_update_connection;
211         void output_update();
212         
213         void build ();
214         ControlUI* build_control_ui (guint32 port_index, boost::shared_ptr<ARDOUR::AutomationControl>);
215         std::vector<std::string> setup_scale_values(guint32 port_index, ControlUI* cui);
216         void parameter_changed (ControlUI* cui);
217         void toggle_parameter_changed (ControlUI* cui);
218         void update_control_display (ControlUI* cui);
219         void control_port_toggled (ControlUI* cui);
220         void control_combo_changed (ControlUI* cui);
221
222         void processor_active_changed (boost::weak_ptr<ARDOUR::Processor>);
223
224         void astate_clicked (ControlUI*, uint32_t parameter);
225         void automation_state_changed (ControlUI*);
226         void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
227         void start_touch (ControlUI*);
228         void stop_touch (ControlUI*);
229
230         void print_parameter (char *buf, uint32_t len, uint32_t param);
231 };
232
233 class PluginUIWindow : public Gtk::Window
234 {
235   public:
236         PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
237         ~PluginUIWindow ();
238
239         PlugUIBase& pluginui() { return *_pluginui; }
240
241         void resize_preferred();
242         void set_parent (Gtk::Window*);
243
244         bool on_enter_notify_event (GdkEventCrossing*);
245         bool on_leave_notify_event (GdkEventCrossing*);
246         bool on_focus_in_event (GdkEventFocus*);
247         bool on_focus_out_event (GdkEventFocus*);
248         bool on_key_press_event (GdkEventKey*);
249         bool on_key_release_event (GdkEventKey*);
250         void on_show ();
251         void on_hide ();
252         void on_map ();
253
254   private:
255         PlugUIBase* _pluginui;
256         sigc::connection death_connection;
257         Gtk::Window* parent;
258         Gtk::VBox vbox;
259         bool non_gtk_gui;
260         bool was_visible;
261
262         void app_activated (bool);
263         void plugin_going_away ();
264
265         bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
266         bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
267         bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>);
268 };
269
270 #ifdef VST_SUPPORT
271 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
272 {
273   public:
274         VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
275         ~VSTPluginUI ();
276
277         gint get_preferred_height ();
278         gint get_preferred_width ();
279         bool start_updating(GdkEventAny*) {return false;}
280         bool stop_updating(GdkEventAny*) {return false;}
281
282         int package (Gtk::Window&);
283
284   private:
285         boost::shared_ptr<ARDOUR::VSTPlugin>  vst;
286         Gtk::Socket socket;
287         Gtk::HBox   preset_box;
288         Gtk::VBox   vpacker;
289         
290         bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
291         void save_plugin_setting ();
292 };
293 #endif // VST_SUPPORT
294
295 #ifdef HAVE_AUDIOUNITS
296 /* this function has to be in a .mm file */
297 extern PlugUIBase* create_au_gui (boost::shared_ptr<ARDOUR::PluginInsert>, Gtk::VBox**);
298 #endif
299
300 #endif /* __ardour_plugin_ui_h__ */