LV2: Send messages from one UI to all replicated instances.
[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 <vector>
30
31 #include <gtkmm/widget.h>
32 #include <sigc++/signal.h>
33
34 #include "ardour_dialog.h"
35 #include "ardour/types.h"
36 #include "plugin_ui.h"
37
38 #ifdef LV2_SUPPORT
39 #include "ardour/plugin_insert.h"
40
41 #include "lv2_external_ui.h"
42
43 namespace ARDOUR {
44         class PluginInsert;
45         class LV2Plugin;
46 }
47
48 class LV2PluginUI : public PlugUIBase, public Gtk::VBox
49 {
50   public:
51         LV2PluginUI (boost::shared_ptr<ARDOUR::PluginInsert>,
52                      boost::shared_ptr<ARDOUR::LV2Plugin>);
53         ~LV2PluginUI ();
54
55         gint get_preferred_height ();
56         gint get_preferred_width ();
57         bool resizable ();
58
59         bool start_updating(GdkEventAny*);
60         bool stop_updating(GdkEventAny*);
61
62         int package (Gtk::Window&);
63
64   private:
65
66         void parameter_changed (uint32_t, float);
67
68         typedef boost::shared_ptr<ARDOUR::AutomationControl> ControllableRef;
69
70         boost::shared_ptr<ARDOUR::PluginInsert> _pi;
71         boost::shared_ptr<ARDOUR::LV2Plugin> _lv2;
72         std::vector<int>                     _output_ports;
73         sigc::connection                     _screen_update_connection;
74         Gtk::Widget*                         _gui_widget;
75         /** a box containing the focus, bypass, delete, save / add preset buttons etc. */
76         Gtk::HBox*                           _ardour_buttons_box;
77         float*                               _values;
78         std::vector<ControllableRef>         _controllables;
79         struct lv2_external_ui_host          _external_ui_host;
80         LV2_Feature                          _external_ui_feature;
81         struct lv2_external_ui*              _external_ui_ptr;
82         LV2_Feature                          _parent_feature;
83         Gtk::Window*                         _win_ptr;
84         void*                                _inst;
85
86         static void on_external_ui_closed(void* controller);
87
88         static void write_from_ui(void*       controller,
89                                   uint32_t    port_index,
90                                   uint32_t    buffer_size,
91                                   uint32_t    format,
92                                   const void* buffer);
93
94         static void write_to_ui(void*       controller,
95                                 uint32_t    port_index,
96                                 uint32_t    buffer_size,
97                                 uint32_t    format,
98                                 const void* buffer);
99
100         static uint32_t port_index(void* controller, const char* symbol);
101
102         static void touch(void*    controller,
103                           uint32_t port_index,
104                           bool     grabbed);
105
106         void update_timeout();
107
108         void lv2ui_instantiate(const std::string& title);
109         void lv2ui_free();
110
111         void parameter_update(uint32_t, float);
112         bool configure_handler (GdkEventConfigure*);
113         void save_plugin_setting ();
114         void output_update();
115         bool is_update_wanted(uint32_t index);
116
117         virtual bool on_window_show(const std::string& title);
118         virtual void on_window_hide();
119 };
120
121 #endif // LV2_SUPPORT
122
123 #endif /* __ardour_lv2_plugin_ui_h__ */
124