High-DPI support how to

JUCE 5.1 Release notes state the following

Scaling support for plugins
Added support for VST 2 and 3 extensions that allow a host to give a plugin the scale-factor that it should use for its UI. This will solve the problem of Windows high-DPI support for plugins in hosts which support this.

How should the host tell the plugin to use a certain scale factor? Is that the
AudioProcessorEditor::setScaleFactor() function?

If so - it does not seem to work on Windows as soon as the scale in windows is set to anything other than 100% the result of a plugin window is not scaled properly.

The audio plugin host example does not really offer any insight as its PluginWindow class overrides the getDesktopScaleFactor function and ALWAYS returns 1.0f scale resulting in obviously tiny windows when scale is set to above 100%.

Is there a way to take advantage of this functionality and properly handle the High-DPI mess?
Talking from the plugin host perspective, not plugin developer.

I see that some hosts do seem to properly scale the plugin’s UI (Cubase on windows for example), but it seems that all they do is resample the window so it’s blury.

VST’s “CFrame” class has a method called “setZoom()” - is that something that could be utilized?

Any advice is appreciated - thanks.

Old post but replying to it for the sake of new forum searchers.

It looks like setScaleFactor() is called by DAWs like Ableton, with different values for Retina Displays and normal ones.

You can solve the issue by placing all of your editor elements into a component, applying an affine transform to it, and then adding that component to the editor.

#define SCALE_FACTOR 0.5f

//==============================================================================
ScaledAudioProcessorEditor::ScaledAudioProcessorEditor(ScaledMonsterAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p),  editorScaledComponent (p)
{
    setSize (2112 * SCALE_FACTOR, 1387 * SCALE_FACTOR);
    addAndMakeVisible (editorScaledComponent); 
}

ScaledAudioProcessorEditor::~ScaledAudioProcessorEditor()
{
}

//==============================================================================
void ScaledAudioProcessorEditor::paint (juce::Graphics& g)
{
}

void ScaledAudioProcessorEditor::resized()
{
    editorScaledComponent.setBounds (getBounds().getX() * (1 / SCALE_FACTOR),
                                     getBounds().getY() * (1 / SCALE_FACTOR),
                                     getBounds().getWidth() * (1 / SCALE_FACTOR),
                                     getBounds().getHeight() * (1 / SCALE_FACTOR));

    editorScaledComponent.setTransform (juce::AffineTransform().scaled (SCALE_FACTOR));
}

1 Like