fix OSX compilation
[ardour.git] / gtk2_ardour / lv2_plugin_ui.h
1 /*
2     Copyright (C) 2008-2012 Paul Davis
3     Author: David Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_lv2_plugin_ui_h__
21 #define __ardour_lv2_plugin_ui_h__
22
23 #ifdef WAF_BUILD
24 #include "gtk2ardour-config.h"
25 #endif
26
27 #include <list>
28 #include <map>
29 #include <set>
30 #include <vector>
31
32 #include <gtkmm/widget.h>
33 #include <sigc++/signal.h>
34
35 #include "ardour_dialog.h"
36 #include "ardour/types.h"
37 #include "plugin_ui.h"
38
39 #ifdef LV2_SUPPORT
40 #include "ardour/plugin_insert.h"
41
42 #include "lv2_external_ui.h"
43
44 namespace ARDOUR {
45         class PluginInsert;
46         class LV2Plugin;
47 }
48
49 class LV2PluginUI : public PlugUIBase, public Gtk::VBox
50 {
51   public:
52         LV2PluginUI (boost::shared_ptr<ARDOUR::PluginInsert>,
53                      boost::shared_ptr<ARDOUR::LV2Plugin>);
54         ~LV2PluginUI ();
55
56         gint get_preferred_height ();
57         gint get_preferred_width ();
58         bool resizable ();
59
60         bool start_updating(GdkEventAny*);
61         bool stop_updating(GdkEventAny*);
62
63         int package (Gtk::Window&);
64         void grab_focus ();
65
66   private:
67
68         void control_changed (uint32_t);
69
70         typedef boost::shared_ptr<ARDOUR::AutomationControl> ControllableRef;
71
72         boost::shared_ptr<ARDOUR::PluginInsert> _pi;
73         boost::shared_ptr<ARDOUR::LV2Plugin> _lv2;
74         std::vector<int>                     _output_ports;
75         sigc::connection                     _screen_update_connection;
76         sigc::connection                     _message_update_connection;
77         Gtk::Widget*                         _gui_widget;
78         /** a box containing the focus, bypass, delete, save / add preset buttons etc. */
79         Gtk::HBox                            _ardour_buttons_box;
80         float*                               _values_last_sent_to_ui;
81         std::vector<ControllableRef>         _controllables;
82         struct lv2_external_ui_host          _external_ui_host;
83         LV2_Feature                          _external_ui_feature;
84         LV2_Feature                          _external_kxui_feature;
85         struct lv2_external_ui*              _external_ui_ptr;
86         LV2_Feature                          _parent_feature;
87         Gtk::Window*                         _win_ptr;
88         void*                                _inst;
89         typedef std::set<uint32_t> Updates;
90         Updates                              _updates;
91
92         static void on_external_ui_closed(void* controller);
93
94         static void write_from_ui(void*       controller,
95                                   uint32_t    port_index,
96                                   uint32_t    buffer_size,
97                                   uint32_t    format,
98                                   const void* buffer);
99
100         static void write_to_ui(void*       controller,
101                                 uint32_t    port_index,
102                                 uint32_t    buffer_size,
103                                 uint32_t    format,
104                                 const void* buffer);
105
106         static uint32_t port_index(void* controller, const char* symbol);
107
108         static void touch(void*    controller,
109                           uint32_t port_index,
110                           bool     grabbed);
111
112         void update_timeout();
113
114         void lv2ui_instantiate(const std::string& title);
115         void lv2ui_free();
116
117         void parameter_update(uint32_t, float);
118         bool configure_handler (GdkEventConfigure*);
119         void save_plugin_setting ();
120         void output_update();
121         void queue_port_update();
122         bool is_update_wanted(uint32_t index);
123
124         virtual bool on_window_show(const std::string& title);
125         virtual void on_window_hide();
126 };
127
128 #endif // LV2_SUPPORT
129
130 #endif /* __ardour_lv2_plugin_ui_h__ */
131