Resize plugin with setGlobalScaleFactor



i'm looking for an easy way to scale a vector UI without calling SetBounds() for every component. It would be very easy if it's possible to use the global scale factor for this. It works perfect if i call it in the constructor. Resizing seems to work too without scaling.

I tried following code to resize the component and scale it, but it throws an exception. Think it creates something like an endless loop because scalling also affects the size. 

void AudioEditor::resized()
    this->resizer->setBounds(this->getWidth() - 16, this->getHeight() - 16, 16, 16);
    Desktop::getInstance().setGlobalScaleFactor((float)this->getWidth() / MyPluginWidth);

Is this possible and is there a "right" solution or should i avoid this kind of scaling at all?


Another question: It seems that sung setGlobalScaleFactor does not change the plugin window size. Is it possible to change the window size to fit the scaled plugin without using the components setSize() method? setSize() directly also changes the scaled plugin size.

Any help is welcome.


Just found following thread:

Think theres still no clean solution for this...


Of couse resizing inside the resized callback will cause an endless loop.

Try to resize the parent-window after you set the global Scale Factor (not inside resized())



But would be interesting, if jules could modify the plugin-wrappers, that setting that setGlobalScaleFactor() also work for plugins, i think it does not need so much work, only resizing the host-controlled plugin window




I'm pretty sure there was a good reason why I didn't allow the plugin window to be rescaled globally.. Personally, I'd probably suggest that putting a subcomponent inside your editor and setting its scale while leaving the editor component itself unscaled would be the safest plan.



and what about just let the plugin-window size stay the same, and trigger a resize callback so that the plugin-Gui know about its changed new virtual bounds. The reason i write, its because i'm to lazy to  implement  your suggestion on every on my Plugins, i just want to  use setGlobalScaleFactor()...

This is something which belongs to AudioProcessEditor i think ;)



You mean overwrite getGlobalScaleFactor() in the subcomponent?! Is it really that simple. Have to try that...


Well no, you obviously can't override a Desktop method. I actually meant calling Component::setTransform on the subcomponent, but leaving its parent un-transformed.


Scaling with setTransform in a sub component seems to work well as far as i was able to test. Only pop up menus don't scale. Maybe it's possible to scale them with the font size in the look and feel class without writing a lot of code. The quality depends on the scale factor. Think it's better to let the user choose from predefined screen resolutions. Will make some more tests. Thanks!


I was able to scale popup menus and the combo box font. Just one problem left... Is it possible to reduce the cap between the scaled ComboBox entries somewhere? See attachment.

Edit: Overwriting getIdealPopupMenuItemSize() did the job.


another why setGlobalFactor needs full support for plugins, popup-windows need also scaling (currently the plugin-content will be also transformed, this is ok, the plugin just needs to get informed (just call resized on the plugins-content window)