mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Allow set_size() before set_parent()
REAPER does this.
This commit is contained in:
@@ -514,22 +514,28 @@ void ClapBridge::run() {
|
|||||||
[&, plugin = instance.plugin.get(),
|
[&, plugin = instance.plugin.get(),
|
||||||
gui = instance.extensions.gui,
|
gui = instance.extensions.gui,
|
||||||
&editor = instance.editor]() {
|
&editor = instance.editor]() {
|
||||||
assert(editor);
|
|
||||||
|
|
||||||
// HACK: We need to resize the editor window before
|
// HACK: We need to resize the editor window before
|
||||||
// setting the size on the plugin. Surge XT and
|
// setting the size on the plugin. Surge XT and
|
||||||
// presumably other CLAP JUCE Extensions plugins
|
// presumably other CLAP JUCE Extensions plugins
|
||||||
// will request a resize to the same size that was
|
// will request a resize to the same size that was
|
||||||
// just set. This causes a resize loop, so we'll
|
// just set. This causes a resize loop, so we'll
|
||||||
// try to prevent resizes to the same size.
|
// try to prevent resizes to the same size.
|
||||||
const Size old_size = editor->size();
|
// The host is allowed to call this before
|
||||||
|
// `set_parent()`, so the editor instance may not
|
||||||
|
// yet exist.
|
||||||
|
Size old_size{};
|
||||||
|
if (editor) {
|
||||||
|
old_size = editor->size();
|
||||||
editor->resize(request.width, request.height);
|
editor->resize(request.width, request.height);
|
||||||
|
}
|
||||||
|
|
||||||
if (gui->set_size(plugin, request.width,
|
if (gui->set_size(plugin, request.width,
|
||||||
request.height)) {
|
request.height)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
if (editor) {
|
||||||
editor->resize(old_size.width, old_size.height);
|
editor->resize(old_size.width, old_size.height);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user