Fix ExportFormatSpecification copy-c'tor
[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 #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
45 #ifndef LV2_1_14_0
46 typedef struct _LV2UI_Request_Parameter {
47         LV2UI_Feature_Handle handle;
48         uint32_t (*request)(LV2UI_Feature_Handle handle, LV2_URID key);
49 }LV2UI_Request_Parameter;
50 #endif
51
52 namespace ARDOUR {
53         class PluginInsert;
54         class LV2Plugin;
55 }
56
57 class LV2PluginUI : public PlugUIBase, public Gtk::VBox
58 {
59 public:
60         LV2PluginUI (boost::shared_ptr<ARDOUR::PluginInsert>,
61                         boost::shared_ptr<ARDOUR::LV2Plugin>);
62         ~LV2PluginUI ();
63
64         gint get_preferred_height ();
65         gint get_preferred_width ();
66         bool resizable ();
67
68         bool start_updating(GdkEventAny*);
69         bool stop_updating(GdkEventAny*);
70
71         int package (Gtk::Window&);
72         void grab_focus ();
73
74 private:
75
76         void control_changed (uint32_t);
77
78         typedef boost::shared_ptr<ARDOUR::AutomationControl> ControllableRef;
79
80         boost::shared_ptr<ARDOUR::PluginInsert> _pi;
81         boost::shared_ptr<ARDOUR::LV2Plugin> _lv2;
82         std::vector<int>                     _output_ports;
83         sigc::connection                     _screen_update_connection;
84         sigc::connection                     _message_update_connection;
85         Gtk::Widget*                         _gui_widget;
86         /** a box containing the focus, bypass, delete, save / add preset buttons etc. */
87         Gtk::HBox                            _ardour_buttons_box;
88         float*                               _values_last_sent_to_ui;
89         std::vector<ControllableRef>         _controllables;
90         struct lv2_external_ui_host          _external_ui_host;
91         LV2_Feature                          _external_ui_feature;
92         LV2_Feature                          _external_kxui_feature;
93         LV2UI_Request_Parameter              _lv2ui_request_paramater;
94         LV2_Feature                          _lv2ui_request_feature;
95         struct lv2_external_ui*              _external_ui_ptr;
96         LV2_Feature                          _parent_feature;
97         Gtk::Window*                         _win_ptr;
98         void*                                _inst;
99         typedef std::set<uint32_t> Updates;
100         Updates                              _updates;
101
102         static void on_external_ui_closed(void* controller);
103
104         static void write_from_ui(void*       controller,
105                                   uint32_t    port_index,
106                                   uint32_t    buffer_size,
107                                   uint32_t    format,
108                                   const void* buffer);
109
110         static void write_to_ui(void*       controller,
111                                 uint32_t    port_index,
112                                 uint32_t    buffer_size,
113                                 uint32_t    format,
114                                 const void* buffer);
115
116         static uint32_t port_index(void* controller, const char* symbol);
117
118         static void touch(void*    controller,
119                           uint32_t port_index,
120                           bool     grabbed);
121
122         static uint32_t request_parameter (void* handle, LV2_URID key);
123         void set_path_property (int,
124                                 const ARDOUR::ParameterDescriptor&,
125                                 Gtk::FileChooserDialog*);
126         std::set<uint32_t> active_parameter_requests;
127
128         void update_timeout();
129
130         void lv2ui_instantiate(const std::string& title);
131         void lv2ui_free();
132
133         void parameter_update(uint32_t, float);
134         bool configure_handler (GdkEventConfigure*);
135         void save_plugin_setting ();
136         void output_update();
137         void queue_port_update();
138         bool is_update_wanted(uint32_t index);
139
140         virtual bool on_window_show(const std::string& title);
141         virtual void on_window_hide();
142 };
143
144 #endif // LV2_SUPPORT
145
146 #endif /* __ardour_lv2_plugin_ui_h__ */
147