edit group selection and cut/copy/paste/del shortcuts, interview mode tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginlv2ui.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 "pluginlv2.h"
27 #include "pluginlv2client.h"
28 #include "pluginlv2gui.inc"
29 #include "pluginlv2ui.inc"
30
31 //=== lv2_external_ui.h
32 #define LV2_EXTERNAL_UI_URI "http://lv2plug.in/ns/extensions/ui#external"
33 #define LV2_EXTERNAL_UI_URI__KX__Host "http://kxstudio.sf.net/ns/lv2ext/external-ui#Host"
34
35 typedef struct _lv2_external_ui lv2_external_ui;
36 struct _lv2_external_ui {
37         void (*run)(lv2_external_ui *ui);
38         void (*show)(lv2_external_ui *ui);
39         void (*hide)(lv2_external_ui *ui);
40         void *self;
41 };
42
43 typedef struct _lv2_external_ui_host lv2_external_ui_host;
44 struct _lv2_external_ui_host {
45         void (*ui_closed)(void* controller);
46         const char *plugin_human_id;
47 };
48
49 #define LV2_EXTERNAL_UI_RUN(ptr) (ptr)->run(ptr)
50 #define LV2_EXTERNAL_UI_SHOW(ptr) (ptr)->show(ptr)
51 #define LV2_EXTERNAL_UI_HIDE(ptr) (ptr)->hide(ptr)
52 //===
53
54 typedef struct _GtkWidget GtkWidget;
55
56 #define UPDATE_HOST 1
57 #define UPDATE_PORTS 2
58
59 class PluginLV2UI : public PluginLV2
60 {
61 public:
62         PluginLV2UI();
63         ~PluginLV2UI();
64
65         const LilvUI *lilv_ui;
66         const LilvNode *lilv_type;
67
68         LV2_Extension_Data_Feature *ext_data;
69         lv2_external_ui_host extui_host;
70         const char *wgt_type;
71         const char *gtk_type;
72         const char *ui_type;
73
74         char title[BCSTRLEN];
75         PluginLV2ClientConfig config;
76         int done, running;
77         int hidden, updates;
78
79         void start();
80         void stop();
81         int update_lv2_input(float *vals, int force);
82         void update_lv2_output();
83         virtual int send_host(int64_t token, const void *data, int bytes) = 0;
84         virtual int child_iteration(int64_t usec) { return -1; }
85
86         void run_lilv(int samples);
87         void update_value(int idx, uint32_t bfrsz, uint32_t typ, const void *bfr);
88         void update_control(int idx, uint32_t bfrsz, uint32_t typ, const void *bfr);
89         static void write_from_ui(void *the, uint32_t idx,
90                 uint32_t bfrsz, uint32_t typ, const void *bfr);
91         static uint32_t port_index(void* obj, const char* sym);
92
93 //      static void touch(void *obj,uint32_t pidx,bool grabbed);
94         static uint32_t uri_to_id(LV2_URID_Map_Handle handle, const char *map, const char *uri);
95         static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
96         static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
97         void lv2ui_instantiate(void *parent);
98         bool lv2ui_resizable();
99         void update_host();
100 };
101
102 class PluginLV2GUI
103 {
104 public:
105         PluginLV2GUI(PluginLV2ChildUI *child_ui);
106         virtual ~PluginLV2GUI();
107         virtual void reset_gui() = 0;
108         virtual void start_gui() = 0;
109         virtual int handle_child() = 0;
110
111         PluginLV2ChildUI *child_ui;
112         void *top_level;
113 };
114
115 class PluginLV2ChildGtkUI : public PluginLV2GUI
116 {
117 public:
118         PluginLV2ChildGtkUI(PluginLV2ChildUI *child_ui);
119         ~PluginLV2ChildGtkUI();
120
121         void reset_gui();
122         void start_gui();
123         int handle_child();
124 };
125
126 class PluginLV2ChildWgtUI : public PluginLV2GUI
127 {
128 public:
129         PluginLV2ChildWgtUI(PluginLV2ChildUI *child_ui);
130         ~PluginLV2ChildWgtUI();
131
132         void reset_gui();
133         void start_gui();
134         int handle_child();
135 };
136
137 class PluginLV2ChildUI : public ForkChild, public PluginLV2UI
138 {
139 public:
140         PluginLV2ChildUI();
141         ~PluginLV2ChildUI();
142
143         int init_ui(const char *path, int sample_rate, int bfrsz);
144         void reset_gui();
145         void start_gui();
146         int handle_child();
147
148         int is_forked() { return ppid; }
149         int send_host(int64_t token, const void *data, int bytes);
150         int child_iteration(int64_t usec);
151         void run();
152         int run(int ac, char **av);
153         int run_ui();
154         void run_buffer(int shmid);
155
156         int ac;
157         char **av;
158         PluginLV2GUI *gui;
159 };
160
161 #endif