Scale plugin depending on screen size

I want to make the scale factor of a whole plugin dependent on the screen size, so that it stays at some reasonable ratio for high resolutions without changing all the layout code. We’re told not to use AudioProcessorEditor::setScaleFactor, but Desktop::setGlobalScaleFactor modifies the display area which I’m supposed to query, so… how do we go about this?

I’m always using setTransform on a container component that is a child of the audio processor editor and contains all the components that I want to scale.

1 Like

I ended up doing something like this, just to avoid the extra container which I took out recently.

class MyAudioProcessorEditor : public juce::AudioProcessorEditor
{
    float extraScale = 1.0f;

    MyAudioProcessorEditor (MyAudioProcessor& p) // etc
    {
        if (auto d = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay())
        {
            extraScale = /* some function of d->totalArea */;
            setScaleFactor (1.0f);
        }
    }

    void setScaleFactor (float scale) override
    {
        juce::AudioProcessorEditor::setScaleFactor (scale * extraScale);
    }
}