1
Fork 0

Alternative way to deal with resizes in jucewrapper

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-03-19 20:48:19 +00:00
parent f59ff8f266
commit e4c04c5074
No known key found for this signature in database
GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 19 additions and 11 deletions

View File

@ -525,6 +525,7 @@ static constexpr const fileRequestFunc nullFileRequestFunc = nullptr;
// UI/editor implementation
class CardinalWrapperEditor : public juce::AudioProcessorEditor,
private juce::AsyncUpdater,
private juce::Timer
{
CardinalWrapperProcessor& cardinalProcessor;
@ -554,6 +555,22 @@ public:
}
protected:
void handleAsyncUpdate() override
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
int width = static_cast<int>(ui->getWidth());
int height = static_cast<int>(ui->getHeight());
#ifdef DISTRHO_OS_MAC
const double scaleFactor = ui->getScaleFactor();
width /= scaleFactor;
height /= scaleFactor;
#endif
setSize(width, height);
}
void timerCallback() override
{
if (ui == nullptr)
@ -639,21 +656,12 @@ private:
cardinalProcessor.plugin.setState(key, value);
}
static void setSizeFunc(void* const ptr, uint width, uint height)
static void setSizeFunc(void* const ptr, uint, uint)
{
CardinalWrapperEditor* const editor = static_cast<CardinalWrapperEditor*>(ptr);
DISTRHO_SAFE_ASSERT_RETURN(editor != nullptr,);
#ifdef DISTRHO_OS_MAC
UIExporter* const ui = editor->ui;
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
const double scaleFactor = ui->getScaleFactor();
width /= scaleFactor;
height /= scaleFactor;
#endif
editor->setSize(static_cast<int>(width), static_cast<int>(height));
editor->triggerAsyncUpdate();
}
};