I have a question about scaling. On my plugin there is an option to change windows size from a menu (like small size, normal, large). I use this like a parameter that I applied in resized methods of my components.
So for example if large is 1.5 to normal size I just multiply all sizes, coordinates to 1.5.
Is it good approach or any other best practices?
If so, when user change the size, what is the best way to redraw/resize the whole editor?
I haven’t implemented runtime UI rescaling myself yet, but check out Desktop::getInstance().setGlobalScaleFactor(float); - this doesn’t seem to require any changes to the resized() or paint() methods.
For example, in my Editor constructor: #if JUCE_MAC
Desktop::getInstance().setGlobalScaleFactor(1.2f); // makes Mac UI slightly larger if needed #else
Desktop::getInstance().setGlobalScaleFactor(1.0f); #endif
I tried this method, but as I see it doesn’t change the size of editor window (standalone version). It’s still the same size, but interface inside is scaling correctly. Am I doing something wrong
When the use makes the window bigger, do you want to see more or do you want everything to be bigger?
If you are building a sequencer plugin, maybe when the user makes the window bigger, the controls on the edge should stay the same size, but the component with the notes should get bigger to show more notes.
If you are building a synth with a fixed layout, when user resizes, then controls should all get smaller / bigger.
Or maybe you want a hybrid of both approaches.
If you want the 2nd method, I find it’s easiest to write your editor with one fixed size and then wrap in it another editor that provides the scaling.
I scale each group of components in the resized function with setTransform(juce::AffineTransform::scale(scale));
I get scale via getHeight() / originalHeight , so when I call setSize manually the window resizes, the resized function is called, scale is recalculated, and all components are scaled
For some reason I needed to override shouldPopupMenuScaleWithTargetComponent and return true (even though it looks like this should not be necessary since it’s set in L&Fv2). Now all my popups scale along with the main component!
So far I keep going with setScaleFactor. Looks like it works fine with all cases on MAC and standalone on Windows.
But I see it shows always default side on Windows when I close the project and open it again. It always default size. Any ideas how to fix it?
I see that parameter that I pass to setScaleFactor is correct, so the problem in something else.