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__
24 #include "gtk2ardour-config.h"
31 #include <sigc++/signal.h>
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>
48 #include "ardour/types.h"
50 #include "automation_controller.h"
65 class HSliderController
;
75 class PlugUIBase
: public virtual sigc::trackable
78 PlugUIBase (boost::shared_ptr
<ARDOUR::PluginInsert
>);
79 virtual ~PlugUIBase();
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;
86 virtual void activate () {}
87 virtual void deactivate () {}
89 virtual void update_presets ();
91 void latency_button_clicked ();
93 virtual bool on_window_show(const Glib::ustring
& /*title*/) { return true; }
94 virtual void on_window_hide() {}
97 boost::shared_ptr
<ARDOUR::PluginInsert
> insert
;
98 boost::shared_ptr
<ARDOUR::Plugin
> plugin
;
99 Gtk::ComboBoxText preset_combo
;
100 Gtk::Button save_button
;
101 Gtk::ToggleButton bypass_button
;
102 Gtk::EventBox focus_button
;
104 Gtk::Label latency_label
;
105 Gtk::Button latency_button
;
106 void set_latency_label ();
108 LatencyGUI
* latency_gui
;
109 ArdourDialog
* latency_dialog
;
111 Gtk::Expander plugin_analysis_expander
;
113 Gtk::Image
* focus_out_image
;
114 Gtk::Image
* focus_in_image
;
117 void setting_selected();
118 void save_plugin_setting (void);
119 bool focus_toggled(GdkEventButton
*);
120 void bypass_toggled();
121 void toggle_plugin_analysis ();
122 void processor_active_changed (boost::weak_ptr
<ARDOUR::Processor
> p
);
123 void plugin_going_away ();
125 PBD::ScopedConnection death_connection
;
126 PBD::ScopedConnection active_connection
;
127 PBD::ScopedConnectionList control_connections
;
130 class GenericPluginUI
: public PlugUIBase
, public Gtk::VBox
133 GenericPluginUI (boost::shared_ptr
<ARDOUR::PluginInsert
> plug
, bool scrollable
=false);
136 gint
get_preferred_height () { return prefheight
; }
137 gint
get_preferred_width () { return -1; }
139 bool start_updating(GdkEventAny
*);
140 bool stop_updating(GdkEventAny
*);
143 Gtk::VBox main_contents
;
145 Gtk::HBox settings_box
;
148 Gtk::Table button_table
;
149 Gtk::Table output_table
;
151 Gtk::ScrolledWindow scroller
;
152 Gtk::Adjustment hAdjustment
;
153 Gtk::Adjustment vAdjustment
;
154 Gtk::Viewport scroller_view
;
155 Gtk::Menu
* automation_menu
;
161 Gtkmm2ext::FastMeter
*meter
;
169 MeterInfo (int /*i*/) {
179 static const int32_t initial_button_rows
= 12;
180 static const int32_t initial_button_cols
= 1;
181 static const int32_t initial_output_rows
= 1;
182 static const int32_t initial_output_cols
= 4;
184 /* FIXME: Unify with AutomationController */
185 struct ControlUI
: public Gtk::HBox
{
187 boost::shared_ptr
<ARDOUR::AutomationControl
> control
;
189 Evoral::Parameter
parameter() { return control
->parameter(); }
193 Gtk::ComboBoxText
* combo
;
194 std::map
<std::string
, float>* combo_map
;
195 Gtk::ToggleButton
* button
;
196 boost::shared_ptr
<AutomationController
> controller
;
197 Gtkmm2ext::ClickBox
* clickbox
;
202 Gtk::Button automate_button
;
206 Gtk::EventBox
*display
;
207 Gtk::Label
* display_label
;
211 MeterInfo
* meterinfo
;
217 std::vector
<ControlUI
*> input_controls
;
218 std::vector
<ControlUI
*> output_controls
;
219 sigc::connection screen_update_connection
;
220 void output_update();
223 ControlUI
* build_control_ui (guint32 port_index
, boost::shared_ptr
<ARDOUR::AutomationControl
>);
224 std::vector
<std::string
> setup_scale_values(guint32 port_index
, ControlUI
* cui
);
225 void parameter_changed (ControlUI
* cui
);
226 void toggle_parameter_changed (ControlUI
* cui
);
227 void update_control_display (ControlUI
* cui
);
228 void control_port_toggled (ControlUI
* cui
);
229 void control_combo_changed (ControlUI
* cui
);
231 void processor_active_changed (boost::weak_ptr
<ARDOUR::Processor
>);
233 void astate_clicked (ControlUI
*, uint32_t parameter
);
234 void automation_state_changed (ControlUI
*);
235 void set_automation_state (ARDOUR::AutoState state
, ControlUI
* cui
);
236 void start_touch (ControlUI
*);
237 void stop_touch (ControlUI
*);
239 void print_parameter (char *buf
, uint32_t len
, uint32_t param
);
242 class PluginUIWindow
: public Gtk::Window
245 PluginUIWindow (Gtk::Window
*, boost::shared_ptr
<ARDOUR::PluginInsert
> insert
, bool scrollable
=false);
248 PlugUIBase
& pluginui() { return *_pluginui
; }
250 void resize_preferred();
251 void set_parent (Gtk::Window
*);
252 void set_title(const Glib::ustring
& title
);
255 bool on_enter_notify_event (GdkEventCrossing
*);
256 bool on_leave_notify_event (GdkEventCrossing
*);
257 bool on_focus_in_event (GdkEventFocus
*);
258 bool on_focus_out_event (GdkEventFocus
*);
259 bool on_key_press_event (GdkEventKey
*);
260 bool on_key_release_event (GdkEventKey
*);
266 Glib::ustring _title
;
267 PlugUIBase
* _pluginui
;
268 PBD::ScopedConnection death_connection
;
274 void app_activated (bool);
275 void plugin_going_away ();
277 bool create_vst_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
278 bool create_audiounit_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
279 bool create_lv2_editor (boost::shared_ptr
<ARDOUR::PluginInsert
>);
283 class VSTPluginUI
: public PlugUIBase
, public Gtk::VBox
286 VSTPluginUI (boost::shared_ptr
<ARDOUR::PluginInsert
>, boost::shared_ptr
<ARDOUR::VSTPlugin
>);
289 gint
get_preferred_height ();
290 gint
get_preferred_width ();
291 bool start_updating(GdkEventAny
*) {return false;}
292 bool stop_updating(GdkEventAny
*) {return false;}
294 int package (Gtk::Window
&);
297 boost::shared_ptr
<ARDOUR::VSTPlugin
> vst
;
299 Gtk::HBox preset_box
;
302 bool configure_handler (GdkEventConfigure
*, Gtk::Socket
*);
303 void save_plugin_setting ();
305 #endif // VST_SUPPORT
307 #ifdef HAVE_AUDIOUNITS
308 /* this function has to be in a .mm file */
309 extern PlugUIBase
* create_au_gui (boost::shared_ptr
<ARDOUR::PluginInsert
>, Gtk::VBox
**);
312 #endif /* __ardour_plugin_ui_h__ */