Alternative way to deal with resizes in jucewrapper
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
f59ff8f266
commit
e4c04c5074
1 changed files with 19 additions and 11 deletions
|
|
@ -525,6 +525,7 @@ static constexpr const fileRequestFunc nullFileRequestFunc = nullptr;
|
||||||
|
|
||||||
// UI/editor implementation
|
// UI/editor implementation
|
||||||
class CardinalWrapperEditor : public juce::AudioProcessorEditor,
|
class CardinalWrapperEditor : public juce::AudioProcessorEditor,
|
||||||
|
private juce::AsyncUpdater,
|
||||||
private juce::Timer
|
private juce::Timer
|
||||||
{
|
{
|
||||||
CardinalWrapperProcessor& cardinalProcessor;
|
CardinalWrapperProcessor& cardinalProcessor;
|
||||||
|
|
@ -554,6 +555,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
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
|
void timerCallback() override
|
||||||
{
|
{
|
||||||
if (ui == nullptr)
|
if (ui == nullptr)
|
||||||
|
|
@ -639,21 +656,12 @@ private:
|
||||||
cardinalProcessor.plugin.setState(key, value);
|
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);
|
CardinalWrapperEditor* const editor = static_cast<CardinalWrapperEditor*>(ptr);
|
||||||
DISTRHO_SAFE_ASSERT_RETURN(editor != nullptr,);
|
DISTRHO_SAFE_ASSERT_RETURN(editor != nullptr,);
|
||||||
|
|
||||||
#ifdef DISTRHO_OS_MAC
|
editor->triggerAsyncUpdate();
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue