comparison DPF-Prymula-audioplugins/dpf/distrho/src/travesty/view.h @ 3:84e66ea83026

DPF-Prymula-audioplugins-0.231015-2
author prymula <prymula76@outlook.com>
date Mon, 16 Oct 2023 21:53:34 +0200
parents
children
comparison
equal deleted inserted replaced
2:cf2cb71d31dd 3:84e66ea83026
1 /*
2 * travesty, pure C VST3-compatible interface
3 * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #pragma once
18
19 #include "base.h"
20
21 /**
22 * base view stuff
23 */
24
25 struct v3_view_rect {
26 int32_t left;
27 int32_t top;
28 int32_t right;
29 int32_t bottom;
30 };
31
32 #define V3_VIEW_PLATFORM_TYPE_HWND "HWND"
33 #define V3_VIEW_PLATFORM_TYPE_NSVIEW "NSView"
34 #define V3_VIEW_PLATFORM_TYPE_X11 "X11EmbedWindowID"
35
36 #if defined(__APPLE__)
37 # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_NSVIEW
38 #elif defined(_WIN32)
39 # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_HWND
40 #else
41 # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_X11
42 #endif
43
44 /**
45 * plugin view
46 */
47
48 struct v3_plugin_frame;
49
50 struct v3_plugin_view {
51 #ifndef __cplusplus
52 struct v3_funknown;
53 #endif
54 v3_result (V3_API* is_platform_type_supported)(void* self, const char* platform_type);
55 v3_result (V3_API* attached)(void* self, void* parent, const char* platform_type);
56 v3_result (V3_API* removed)(void* self);
57 v3_result (V3_API* on_wheel)(void* self, float distance);
58 v3_result (V3_API* on_key_down)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
59 v3_result (V3_API* on_key_up)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
60 v3_result (V3_API* get_size)(void* self, struct v3_view_rect*);
61 v3_result (V3_API* on_size)(void* self, struct v3_view_rect*);
62 v3_result (V3_API* on_focus)(void* self, v3_bool state);
63 v3_result (V3_API* set_frame)(void* self, struct v3_plugin_frame**);
64 v3_result (V3_API* can_resize)(void* self);
65 v3_result (V3_API* check_size_constraint)(void* self, struct v3_view_rect*);
66 };
67
68 static constexpr const v3_tuid v3_plugin_view_iid =
69 V3_ID(0x5BC32507, 0xD06049EA, 0xA6151B52, 0x2B755B29);
70
71 /**
72 * plugin frame
73 */
74
75 struct v3_plugin_frame {
76 #ifndef __cplusplus
77 struct v3_funknown;
78 #endif
79 v3_result (V3_API* resize_view)(void* self, struct v3_plugin_view**, struct v3_view_rect*);
80 };
81
82 static constexpr const v3_tuid v3_plugin_frame_iid =
83 V3_ID(0x367FAF01, 0xAFA94693, 0x8D4DA2A0, 0xED0882A3);
84
85 /**
86 * steinberg content scaling support
87 * (same IID/iface as presonus view scaling)
88 */
89
90 struct v3_plugin_view_content_scale {
91 #ifndef __cplusplus
92 struct v3_funknown;
93 #endif
94 v3_result (V3_API* set_content_scale_factor)(void* self, float factor);
95 };
96
97 static constexpr const v3_tuid v3_plugin_view_content_scale_iid =
98 V3_ID(0x65ED9690, 0x8AC44525, 0x8AADEF7A, 0x72EA703F);
99
100 /**
101 * support for querying the view to find what control is underneath the mouse
102 */
103
104 struct v3_plugin_view_parameter_finder {
105 #ifndef __cplusplus
106 struct v3_funknown;
107 #endif
108 v3_result (V3_API* find_parameter)(void* self, int32_t x, int32_t y, v3_param_id *);
109 };
110
111 static constexpr const v3_tuid v3_plugin_view_parameter_finder_iid =
112 V3_ID(0x0F618302, 0x215D4587, 0xA512073C, 0x77B9D383);
113
114 /**
115 * linux event handler
116 */
117
118 struct v3_event_handler {
119 #ifndef __cplusplus
120 struct v3_funknown;
121 #endif
122 void (V3_API* on_fd_is_set)(void* self, int fd);
123 };
124
125 static constexpr const v3_tuid v3_event_handler_iid =
126 V3_ID(0x561E65C9, 0x13A0496F, 0x813A2C35, 0x654D7983);
127
128 /**
129 * linux timer handler
130 */
131
132 struct v3_timer_handler {
133 #ifndef __cplusplus
134 struct v3_funknown;
135 #endif
136 void (V3_API* on_timer)(void* self);
137 };
138
139 static constexpr const v3_tuid v3_timer_handler_iid =
140 V3_ID(0x10BDD94F, 0x41424774, 0x821FAD8F, 0xECA72CA9);
141
142 /**
143 * linux host run loop
144 */
145
146 struct v3_run_loop {
147 #ifndef __cplusplus
148 struct v3_funknown;
149 #endif
150 v3_result (V3_API* register_event_handler)(void* self, v3_event_handler** handler, int fd);
151 v3_result (V3_API* unregister_event_handler)(void* self, v3_event_handler** handler);
152 v3_result (V3_API* register_timer)(void* self, v3_timer_handler** handler, uint64_t ms);
153 v3_result (V3_API* unregister_timer)(void* self, v3_timer_handler** handler);
154 };
155
156 static constexpr const v3_tuid v3_run_loop_iid =
157 V3_ID(0x18C35366, 0x97764F1A, 0x9C5B8385, 0x7A871389);
158
159 #ifdef __cplusplus
160
161 /**
162 * C++ variants
163 */
164
165 struct v3_plugin_view_cpp : v3_funknown {
166 v3_plugin_view view;
167 };
168
169 struct v3_plugin_frame_cpp : v3_funknown {
170 v3_plugin_frame frame;
171 };
172
173 struct v3_plugin_view_content_scale_cpp : v3_funknown {
174 v3_plugin_view_content_scale scale;
175 };
176
177 struct v3_plugin_view_parameter_finder_cpp : v3_funknown {
178 v3_plugin_view_parameter_finder finder;
179 };
180
181 struct v3_event_handler_cpp : v3_funknown {
182 v3_event_handler handler;
183 };
184
185 struct v3_timer_handler_cpp : v3_funknown {
186 v3_timer_handler timer;
187 };
188
189 struct v3_run_loop_cpp : v3_funknown {
190 v3_run_loop loop;
191 };
192
193 #endif