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 update_control_display (ControlUI
* cui
);
195 void control_port_toggled (ControlUI
* cui
);
196 void control_combo_changed (ControlUI
* cui
);
198 void astate_clicked (ControlUI
*, uint32_t parameter
);
199 void automation_state_changed (ControlUI
*);
200 void set_automation_state (ARDOUR::AutoState state
, ControlUI
* cui
);
201 void start_touch (ControlUI
*);
202 void stop_touch (ControlUI
*);
204 void print_parameter (char *buf
, uint32_t len
, uint32_t param
);
207 class PluginUIWindow
: public Gtk::Window
210 PluginUIWindow (Gtk::Window
*, boost::shared_ptr
<ARDOUR::PluginInsert
> insert
, bool scrollable
=false);
213 PlugUIBase
& pluginui() { return *_pluginui
; }
215 void resize_preferred();
216 void set_parent (Gtk::Window
*);
218 bool on_enter_notify_event (GdkEventCrossing
*);
219 bool on_leave_notify_event (GdkEventCrossing
*);
220 bool on_focus_in_event (GdkEventFocus
*);
221 bool on_focus_out_event (GdkEventFocus
*);
222 bool on_key_press_event (GdkEventKey
*);
223 bool on_key_release_event (GdkEventKey
*);
230 PlugUIBase
* _pluginui
;
236 void app_activated (bool);
237 void plugin_going_away ();
239 bool create_vst_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
240 bool create_audiounit_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
241 bool create_lv2_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
245 class VSTPluginUI
: public PlugUIBase
, public Gtk::VBox
248 VSTPluginUI (boost::shared_ptr
<ARDOUR::PluginInsert
>, boost::shared_ptr
<ARDOUR::VSTPlugin
>);
251 gint
get_preferred_height ();
252 gint
get_preferred_width ();
253 bool start_updating(GdkEventAny
*) {return false;}
254 bool stop_updating(GdkEventAny
*) {return false;}
256 int package (Gtk::Window
&);
259 boost::shared_ptr
<ARDOUR::VSTPlugin
> vst
;
261 Gtk::HBox preset_box
;
264 bool configure_handler (GdkEventConfigure
*, Gtk::Socket
*);
265 void save_plugin_setting ();
267 #endif // VST_SUPPORT
269 #ifdef HAVE_AUDIOUNITS
270 /* this function has to be in a .mm file */
271 extern PlugUIBase
* create_au_gui (boost::shared_ptr
<ARDOUR::PluginInsert
>, Gtk::VBox
**);
274 #endif /* __ardour_plugin_ui_h__ */