add lv2ui support
[goodguy/history.git] / cinelerra-5.1 / cinelerra / pluginlv2gui.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef __PLUGINLV2UI_H__
23 #define __PLUGINLV2UI_H__
24
25 #include "forkbase.h"
26 #include "pluginlv2gui.inc"
27 #include "pluginlv2client.h"
28
29 class PluginLV2GUI
30 {
31 public:
32         PluginLV2GUI();
33         ~PluginLV2GUI();
34
35         void reset_gui(void);
36         int init_gui(const char *path);
37         void update_value(int idx, uint32_t bfrsz, uint32_t typ, const void *bfr);
38         static void write_from_ui(void *the, uint32_t idx, uint32_t bfrsz,uint32_t typ,const void *bfr);
39         void update_control(int idx, uint32_t bfrsz, uint32_t typ, const void *bfr);
40         static uint32_t port_index(void *obj,const char *sym);
41         static void touch(void *obj,uint32_t pidx,bool grabbed);
42         static uint32_t uri_to_id(LV2_URID_Map_Handle handle, const char *map, const char *uri);
43         static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
44         static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
45         void lv2ui_instantiate(void *parent);
46         bool lv2ui_resizable();
47         void host_update(PluginLV2ChildGUI *child);
48         int run(int ac, char **av);
49
50         PluginLV2ClientConfig config;
51         PluginLV2UriTable  uri_table;
52         LV2_URI_Map_Feature *uri_map;
53         LV2_Extension_Data_Feature *ext_data;
54         LV2_URID_Map       map;
55         LV2_URID_Unmap     unmap;
56         Lv2Features        ui_features;
57         LilvNode *lv2_InputPort;
58         LilvNode *lv2_ControlPort;
59
60         LilvWorld *world;
61         const LilvPlugin *lilv;
62         LilvInstance *inst;
63         LilvUIs* uis;
64         const LilvUI *ui;
65         const LilvNode *ui_type;
66
67 #ifdef HAVE_LV2UI
68         SuilInstance *sinst;
69         SuilHost *ui_host;
70 #endif
71
72         char title[BCSTRLEN];
73         const char *gtk_type;
74         uint32_t last, updates;
75         int done, running;
76
77         void start();
78         void stop();
79         int update_lv2(float *vals, int force);
80         int redraw;
81
82         void run_gui(PluginLV2ChildGUI *child=0);
83 };
84
85 enum { NO_COMMAND,
86         LV2_OPEN,
87         LV2_LOAD,
88         LV2_UPDATE,
89         LV2_START,
90         LV2_SET,
91         NB_COMMANDS };
92
93 typedef struct { int idx;  float value; } control_t;
94
95 class PluginLV2ParentGUI : public ForkParent
96 {
97 public:
98         PluginLV2ParentGUI(PluginLV2ClientWindow *gui);
99         ~PluginLV2ParentGUI();
100         ForkChild* new_fork();
101         void start_parent();
102
103         int handle_parent();
104         PluginLV2ClientWindow *gui;
105 };
106
107 class PluginLV2ChildGUI : public ForkChild
108 {
109 public:
110         PluginLV2ChildGUI();
111         ~PluginLV2ChildGUI();
112
113         int handle_child();
114         void run();
115         int run(int ac, char **av);
116
117         PluginLV2GUI *lv2_gui;
118 // Command tokens
119 };
120
121 #endif