In our plug-ins, we are scaling our main interface component using AffineTransform::scale. We are experiencing major issues with certain child components.
First, we are having issues with PopupMenu components losing track of proper boundaries. We have an Options Menu that appears as a popup whenever a user clicks on our Options “Gear” button. Here is the Option Menu at 100% interface scaling:
At 150%, if the popup is not assigned a ParentComponent, it appears as a window with 100% scaling that goes off the side of the plugin interface.
We want the popup to scale properly with the rest of our plugin. We also want it to stay inside of the plugin window instead of spawning its own window. So, we are setting ParentComponent to our PluginEditor. Here’s what happens:
Side note, if I try to call AffineTransform on the Popup before it’s made visible, I get this:
optionMenu->setTransform(AffineTransform::scale(ourEditor->getInterfaceScale()));
optionsPopup.showMenuAsync(PopupMenu::Options().withTargetComponent(optionsButton), nullptr);
Essentially, the spawned child comp thinks that the parent’s screen size is nearly twice as wide and tall as it actually is. I noticed this exact same behavior when trying to spawn a DialogWindow and saying “centreWithSize”. When the interface scale is anything larger than 1.0x, the DialogWindow trends toward finding the bottom right corner of the editor as the center point. We had to write a hacky block of code to get the DialogWindow to center correctly at all interface scales.
const int editorWidth = getParentComponent()->getWidth();
const int editorHeight = getParentComponent()->getHeight();
const int creditWidth = creditsWindow->getWidth();
const int creditHeight = creditsWindow->getHeight();
float scaleFactor = 1.0f;
auto editor = dynamic_cast<UAPluginEditor*>(getParentComponent());
if (editor) scaleFactor = editor->getInterfaceScale();
scaleFactor *= scaleFactor;
const float widthDiff = (editorWidth - creditWidth) / 2.0f;
const float heightDiff = (editorHeight - creditHeight) / 2.0f;
creditsWindow->setTopLeftPosition(widthDiff / scaleFactor, heightDiff / scaleFactor);
My thought is that when AffineTransform is called on a component, the component should keep track of its current scale. Then, that scale is used when calculating center positions on DialogWindows, PopupMenus, etc.