mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +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);
|
assert(host && host->host_data);
|
||||||
auto self = static_cast<const clap_host_proxy*>(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{
|
clap::ext::gui::host::RequestResize{
|
||||||
.owner_instance_id = self->owner_instance_id(),
|
.owner_instance_id = self->owner_instance_id(),
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height});
|
.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) {
|
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_
|
return main_context_
|
||||||
.run_in_context([&, plugin = instance.plugin.get(),
|
.run_in_context([&, plugin = instance.plugin.get(),
|
||||||
gui = instance.extensions.gui]() {
|
gui = instance.extensions.gui,
|
||||||
return gui->set_size(plugin, request.width,
|
&editor = instance.editor]() {
|
||||||
request.height);
|
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();
|
.get();
|
||||||
},
|
},
|
||||||
@@ -714,18 +724,19 @@ void ClapBridge::run() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement this
|
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
|
||||||
// bool ClapBridge::maybe_resize_editor(size_t instance_id,
|
bool ClapBridge::maybe_resize_editor(size_t instance_id,
|
||||||
// const Steinberg::ViewRect& new_size) {
|
uint16_t width,
|
||||||
// const auto& [instance, _] = get_instance(instance_id);
|
uint16_t height) {
|
||||||
|
const auto& [instance, _] = get_instance(instance_id);
|
||||||
|
|
||||||
// if (instance.editor) {
|
if (instance.editor) {
|
||||||
// instance.editor->resize(new_size.getWidth(), new_size.getHeight());
|
instance.editor->resize(width, height);
|
||||||
// return true;
|
return true;
|
||||||
// } else {
|
} else {
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
void ClapBridge::close_sockets() {
|
void ClapBridge::close_sockets() {
|
||||||
sockets_.close();
|
sockets_.close();
|
||||||
|
|||||||
@@ -224,16 +224,14 @@ class ClapBridge : public HostBridge {
|
|||||||
*/
|
*/
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
// TODO: Editor resizing
|
/**
|
||||||
// /**
|
* If the plugin instance has an editor, resize the wrapper window to match
|
||||||
// * If the plugin instance has an editor, resize the wrapper window to
|
* the new size. This is called from `clap_host_gui::request_resize()` after
|
||||||
// match
|
* the host returns `true`.
|
||||||
// * the new size. This is called from `IPlugFrame::resizeView()` to make
|
*/
|
||||||
// sure
|
bool maybe_resize_editor(size_t instance_id,
|
||||||
// * we do the resize before the request gets sent to the host.
|
uint16_t width,
|
||||||
// */
|
uint16_t height);
|
||||||
// bool maybe_resize_editor(size_t instance_id,
|
|
||||||
// const Steinberg::ViewRect& new_size);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void close_sockets() override;
|
void close_sockets() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user