mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Fully implement the host side GUI extension
This commit is contained in:
@@ -152,6 +152,11 @@ using ClapMainThreadCallbackRequest =
|
||||
clap::ext::latency::host::Changed,
|
||||
clap::ext::audio_ports::host::IsRescanFlagSupported,
|
||||
clap::ext::audio_ports::host::Rescan,
|
||||
clap::ext::gui::host::ResizeHintsChanged,
|
||||
clap::ext::gui::host::RequestResize,
|
||||
clap::ext::gui::host::RequestShow,
|
||||
clap::ext::gui::host::RequestHide,
|
||||
clap::ext::gui::host::Closed,
|
||||
clap::ext::note_ports::host::SupportedDialects,
|
||||
clap::ext::note_ports::host::Rescan,
|
||||
clap::ext::params::host::Rescan,
|
||||
|
||||
@@ -48,6 +48,13 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
|
||||
.is_rescan_flag_supported = ext_audio_ports_is_rescan_flag_supported,
|
||||
.rescan = ext_audio_ports_rescan,
|
||||
}),
|
||||
ext_gui_vtable(clap_host_gui_t{
|
||||
.resize_hints_changed = ext_gui_resize_hints_changed,
|
||||
.request_resize = ext_gui_request_resize,
|
||||
.request_show = ext_gui_request_show,
|
||||
.request_hide = ext_gui_request_hide,
|
||||
.closed = ext_gui_closed,
|
||||
}),
|
||||
ext_latency_vtable(clap_host_latency_t{
|
||||
.changed = ext_latency_changed,
|
||||
}),
|
||||
@@ -77,6 +84,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
|
||||
if (self->supported_extensions_.supports_audio_ports &&
|
||||
strcmp(extension_id, CLAP_EXT_AUDIO_PORTS) == 0) {
|
||||
extension_ptr = &self->ext_audio_ports_vtable;
|
||||
} else if (self->supported_extensions_.supports_gui &&
|
||||
strcmp(extension_id, CLAP_EXT_GUI) == 0) {
|
||||
extension_ptr = &self->ext_gui_vtable;
|
||||
} else if (self->supported_extensions_.supports_latency &&
|
||||
strcmp(extension_id, CLAP_EXT_LATENCY) == 0) {
|
||||
extension_ptr = &self->ext_latency_vtable;
|
||||
@@ -169,6 +179,57 @@ void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
|
||||
.owner_instance_id = self->owner_instance_id(), .flags = flags});
|
||||
}
|
||||
|
||||
void CLAP_ABI
|
||||
clap_host_proxy::ext_gui_resize_hints_changed(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
self->bridge_.send_main_thread_message(
|
||||
clap::ext::gui::host::ResizeHintsChanged{
|
||||
.owner_instance_id = self->owner_instance_id()});
|
||||
}
|
||||
|
||||
bool CLAP_ABI clap_host_proxy::ext_gui_request_resize(const clap_host_t* host,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
return self->bridge_.send_main_thread_message(
|
||||
clap::ext::gui::host::RequestResize{
|
||||
.owner_instance_id = self->owner_instance_id(),
|
||||
.width = width,
|
||||
.height = height});
|
||||
}
|
||||
|
||||
bool CLAP_ABI clap_host_proxy::ext_gui_request_show(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
return self->bridge_.send_main_thread_message(
|
||||
clap::ext::gui::host::RequestShow{.owner_instance_id =
|
||||
self->owner_instance_id()});
|
||||
}
|
||||
|
||||
bool CLAP_ABI clap_host_proxy::ext_gui_request_hide(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
return self->bridge_.send_main_thread_message(
|
||||
clap::ext::gui::host::RequestHide{.owner_instance_id =
|
||||
self->owner_instance_id()});
|
||||
}
|
||||
|
||||
void CLAP_ABI clap_host_proxy::ext_gui_closed(const clap_host_t* host,
|
||||
bool was_destroyed) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
self->bridge_.send_main_thread_message(clap::ext::gui::host::Closed{
|
||||
.owner_instance_id = self->owner_instance_id(),
|
||||
.was_destroyed = was_destroyed});
|
||||
}
|
||||
|
||||
void CLAP_ABI clap_host_proxy::ext_latency_changed(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <atomic>
|
||||
|
||||
#include <clap/ext/audio-ports.h>
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
@@ -82,6 +83,15 @@ class clap_host_proxy {
|
||||
static void CLAP_ABI ext_audio_ports_rescan(const clap_host_t* host,
|
||||
uint32_t flags);
|
||||
|
||||
static void CLAP_ABI ext_gui_resize_hints_changed(const clap_host_t* host);
|
||||
static bool CLAP_ABI ext_gui_request_resize(const clap_host_t* host,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
static bool CLAP_ABI ext_gui_request_show(const clap_host_t* host);
|
||||
static bool CLAP_ABI ext_gui_request_hide(const clap_host_t* host);
|
||||
static void CLAP_ABI ext_gui_closed(const clap_host_t* host,
|
||||
bool was_destroyed);
|
||||
|
||||
static void CLAP_ABI ext_latency_changed(const clap_host_t* host);
|
||||
|
||||
static uint32_t CLAP_ABI
|
||||
@@ -116,6 +126,7 @@ class clap_host_proxy {
|
||||
// depends on whether the plugin supported this extension when the host
|
||||
// called `clap_plugin::init()`.
|
||||
const clap_host_audio_ports_t ext_audio_ports_vtable;
|
||||
const clap_host_gui_t ext_gui_vtable;
|
||||
const clap_host_latency_t ext_latency_vtable;
|
||||
const clap_host_note_ports_t ext_note_ports_vtable;
|
||||
const clap_host_params_t ext_params_vtable;
|
||||
|
||||
Reference in New Issue
Block a user