I need to use a ComponentBoundsConstrainer to enforce a fixed aspect ratio on my ResizableWindow. While this works fine when using the juce title bar, I’m having trouble when switching to the native title bar.
On Windows 7, if I drag the corners of the window and release the mouse, the new window bounds are slightly off, and while dragging the constrainer sometimes changes the position and size of the window. If I resize at a window edge, the window resizes fine will dragging, but after releasing the mouse button the component switches back to its original position.
On Mac the problem is less obvious (because you can’t resize on the edge) but looks similar: while resizing with the (native) corner-resizer the window bounds sometimes switch to a wrong size.
This is not specific to my app, but also reproducable in the juce demo (today’s git) if I change the MainDemoWindow to use a constrainer:
setResizable (true, false); // resizability is a property of ResizableWindow setUsingNativeTitleBar(true); ComponentBoundsConstrainer* constrainer = new ComponentBoundsConstrainer(); constrainer->setFixedAspectRatio(1.5); setConstrainer(constrainer);
If I add a juce corner-resizer with “setResizable (true, true)”, resizing works fine as long as I only use the corner-resizer, but the same issues apply if I resize the window by its native border.
Is the ComponentBoundsConstrainer not meant to be used in combination with “native” resizing, or am I just doing something wrong?