How to use AffineTransform() to scale a GUI?

I’m a bit confused on how to apply an AffineTransform().scaled() to my MainComponent, to scale the GUI. This is a GUI Application using a ResizableWindow with a MainComponent (holding all other components).

I have experimented with Desktop::setGlobalScaleFactor(), which works, but I would like to maintain a separate scaling for my main window, and some other windows I have at the moment.

So I tried applying setTransform(AffineTransform().scaled(1.5f)) to my Main Component (as an experiment), but I hit an assert in ResizableWindow:

        // The window expects to be able to be able to manage the size and position
        // of its content component, so you can't arbitrarily add a transform to it!
        jassert (! contentComponent->isTransformed());

I read elsewhere to put your MainComponent inside another one…? Do I simply put my MainComponent inside a basically default empty Component class “wrapper”, and then use it to apply and change the transform? And then separately set the size on the owning window or the wrapping component at the same time?

Is there any problem that can’t be solved by yet another layer of indirection? :slight_smile:

Yes, if it’s asserting at this level, I’d add another wrapper component.

1 Like

OK, I did it and it works great! :grin: