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