mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Properly resize the CLAP editor window
This commit is contained in:
@@ -195,11 +195,20 @@ bool CLAP_ABI clap_host_proxy::ext_gui_request_resize(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(
|
||||
const bool result = self->bridge_.send_main_thread_message(
|
||||
clap::ext::gui::host::RequestResize{
|
||||
.owner_instance_id = self->owner_instance_id(),
|
||||
.width = width,
|
||||
.height = height});
|
||||
|
||||
// If the resize request was accepted by the host, then we'll also resize
|
||||
// our editor window
|
||||
if (result) {
|
||||
self->bridge_.maybe_resize_editor(self->owner_instance_id_, width,
|
||||
height);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CLAP_ABI clap_host_proxy::ext_gui_request_show(const clap_host_t* host) {
|
||||
|
||||
@@ -499,9 +499,19 @@ void ClapBridge::run() {
|
||||
|
||||
return main_context_
|
||||
.run_in_context([&, plugin = instance.plugin.get(),
|
||||
gui = instance.extensions.gui]() {
|
||||
return gui->set_size(plugin, request.width,
|
||||
request.height);
|
||||
gui = instance.extensions.gui,
|
||||
&editor = instance.editor]() {
|
||||
if (gui->set_size(plugin, request.width,
|
||||
request.height)) {
|
||||
// Also resize the editor window. We do the same
|
||||
// thing when the plugin requests a resize.
|
||||
assert(editor);
|
||||
editor->resize(request.width, request.height);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.get();
|
||||
},
|
||||
@@ -714,18 +724,19 @@ void ClapBridge::run() {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Implement this
|
||||
// bool ClapBridge::maybe_resize_editor(size_t instance_id,
|
||||
// const Steinberg::ViewRect& new_size) {
|
||||
// const auto& [instance, _] = get_instance(instance_id);
|
||||
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
|
||||
bool ClapBridge::maybe_resize_editor(size_t instance_id,
|
||||
uint16_t width,
|
||||
uint16_t height) {
|
||||
const auto& [instance, _] = get_instance(instance_id);
|
||||
|
||||
// if (instance.editor) {
|
||||
// instance.editor->resize(new_size.getWidth(), new_size.getHeight());
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if (instance.editor) {
|
||||
instance.editor->resize(width, height);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ClapBridge::close_sockets() {
|
||||
sockets_.close();
|
||||
|
||||
@@ -224,16 +224,14 @@ class ClapBridge : public HostBridge {
|
||||
*/
|
||||
void run() override;
|
||||
|
||||
// TODO: Editor resizing
|
||||
// /**
|
||||
// * If the plugin instance has an editor, resize the wrapper window to
|
||||
// match
|
||||
// * the new size. This is called from `IPlugFrame::resizeView()` to make
|
||||
// sure
|
||||
// * we do the resize before the request gets sent to the host.
|
||||
// */
|
||||
// bool maybe_resize_editor(size_t instance_id,
|
||||
// const Steinberg::ViewRect& new_size);
|
||||
/**
|
||||
* If the plugin instance has an editor, resize the wrapper window to match
|
||||
* the new size. This is called from `clap_host_gui::request_resize()` after
|
||||
* the host returns `true`.
|
||||
*/
|
||||
bool maybe_resize_editor(size_t instance_id,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
|
||||
protected:
|
||||
void close_sockets() override;
|
||||
|
||||
Reference in New Issue
Block a user