fix names of new no-selected-tracks actions in menus
[ardour2.git] / gtk2_ardour / plugin_ui.h
blob95110a9d619d9a74f62e9adc6e0eddaffc2decb8
1 /*
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__
23 #include <vector>
24 #include <map>
25 #include <list>
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>
47 namespace ARDOUR {
48 class PluginInsert;
49 class Plugin;
50 class VSTPlugin;
51 class Redirect;
52 class AUPlugin;
55 namespace PBD {
56 class Controllable;
59 namespace Gtkmm2ext {
60 class HSliderController;
61 class BarController;
62 class ClickBox;
63 class FastMeter;
64 class PixmapButton;
67 class PlugUIBase : public virtual sigc::trackable
69 public:
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 ();
83 protected:
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;
93 bool no_load_preset;
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
104 public:
105 GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
106 ~GenericPluginUI ();
108 gint get_preferred_height () { return prefheight; }
109 gint get_preferred_width () { return -1; }
111 bool start_updating(GdkEventAny*);
112 bool stop_updating(GdkEventAny*);
114 private:
115 Gtk::HBox settings_box;
116 Gtk::HBox hpacker;
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;
127 gint prefheight;
128 bool is_scrollable;
130 struct MeterInfo {
131 Gtkmm2ext::FastMeter *meter;
133 float min;
134 float max;
135 bool min_unbound;
136 bool max_unbound;
137 bool packed;
139 MeterInfo(int i) {
140 meter = 0;
141 packed = false;
142 min = 1.0e10;
143 max = -1.0e10;
144 min_unbound = false;
145 max_unbound = false;
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 {
156 uint32_t port_index;
158 /* input */
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;
166 Gtk::Label label;
167 bool logarithmic;
168 bool update_pending;
169 char ignore_change;
170 Gtk::Button automate_button;
172 /* output */
174 Gtk::EventBox *display;
175 Gtk::Label* display_label;
177 Gtk::HBox * hbox;
178 Gtk::VBox * vbox;
179 MeterInfo * meterinfo;
181 ControlUI ();
182 ~ControlUI();
185 std::vector<ControlUI*> output_controls;
186 sigc::connection screen_update_connection;
187 void output_update();
189 void build ();
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
209 public:
210 PluginUIWindow (Gtk::Window*, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
211 ~PluginUIWindow ();
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*);
224 void on_show ();
225 void on_hide ();
226 void on_map ();
229 private:
230 PlugUIBase* _pluginui;
231 Gtk::Window* parent;
232 Gtk::VBox vbox;
233 bool non_gtk_gui;
234 bool was_visible;
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>);
244 #ifdef VST_SUPPORT
245 class VSTPluginUI : public PlugUIBase, public Gtk::VBox
247 public:
248 VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>);
249 ~VSTPluginUI ();
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&);
258 private:
259 boost::shared_ptr<ARDOUR::VSTPlugin> vst;
260 Gtk::Socket socket;
261 Gtk::HBox preset_box;
262 Gtk::VBox vpacker;
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**);
272 #endif
274 #endif /* __ardour_plugin_ui_h__ */