After going to test an open source application on windows for the first time, I came a cross a strange error with my program. When a window is drawn, it initially starts off tiny! I’ve tested this with windows scaling turned off and on and I still have the problem.
After moving the edge of the window to resize it, the component returns to the normal size and becomes constrained by the constrainer. The code below is the code I am using to draw the window. The problem does not seem to occur If I use my setFixedAspectRatio
variable. Any ideas on what could be causing the problem? This problem doesn’t occur on mac perculiarly
auto mousePosition = Desktop::getInstance().getMousePosition();
auto windowHeight = Desktop::getInstance().getDisplays().getDisplayContaining (mousePosition).userArea.getHeight();
auto windowWidth = Desktop::getInstance().getDisplays().getDisplayContaining (mousePosition).userArea.getWidth();
if (setFixedAspectRatio == true)
{
DBG ("Resizeable: " + (String)minWidth + " x " + (String)minHeight);
boundsConstrainer = new (ComponentBoundsConstrainer);
auto aspectRatio = (double)minWidth / (double)minHeight;
boundsConstrainer->setFixedAspectRatio (aspectRatio);
boundsConstrainer->setMinimumSize (minWidth, minHeight);
boundsConstrainer->setMaximumSize (maxWidth, maxHeight);
boundsConstrainer->setMinimumOnscreenAmounts (maxHeight, maxWidth, maxHeight, maxWidth);
setConstrainer (boundsConstrainer);
}
else
{
DBG ("Fixed: " + (String)minWidth + " x " + (String)minHeight);
setResizeLimits (minWidth, minHeight, maxWidth, maxHeight);
}
Initial size:
After clicking the border to resize: