ComponentBoundsConstrainer::setMinimumOnscreenAmounts: cannot increase the height of the window (develop branch/macOS)

On the develop branch (commit d7d3505), on macOS 11.3.1, I cannot increase the window height of the juce::DocumentWindow anymore (using the mouse) when using a juce::ComponentBoundsConstrainer with setMinimumOnscreenAmounts(0xffffff, 50, 50, 50). I think it’s related “NSViewComponentPeer: Use JUCE-style coordinates to position subviews”.

On the current develop branch, I tried modifying the GuiAppExample project so that the MainWindow constructor looks like this:

        explicit MainWindow (juce::String name)
            : DocumentWindow (name,
                                                          .findColour (ResizableWindow::backgroundColourId),
            setUsingNativeTitleBar (false); // also works with 'true'
            setContentOwned (new MainComponent(), true);

           #if JUCE_IOS || JUCE_ANDROID
            setFullScreen (true);
            setResizable (true, false); // no corner resizer
            centreWithSize (getWidth(), getHeight());

            setVisible (true);

            constrainer.setMinimumOnscreenAmounts (0xffffff, 50, 50, 50);
            setConstrainer (&constrainer);

Where ‘constrainer’ is declared as a data member of the class, like this:

        juce::ComponentBoundsConstrainer constrainer;

I’m able to resize with the mouse using all edges and corners, so the constrainer doesn’t seem to disable resizing with the mouse. If I call setResizable (true, true) instead, then the border resizers are disabled, and replaced with a single corner resizer. I think this is the expected behaviour.

The current behaviour appears to be correct. If I’ve misunderstood the problem, please provide a small code sample which demonstrates the issue.

I can reproduce the problem using the WindowsDemo, here is what I’ve done for the main window (I think it’s similar to your code):

class MainWindow    : public juce::DocumentWindow
        MainWindow (const juce::String& name, juce::Component* c, JUCEApplication& a)
            : DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
                                                                .findColour (ResizableWindow::backgroundColourId),
              app (a)
            constrainer.setSizeLimits(1024, 768, std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
            constrainer.setMinimumOnscreenAmounts (0xffffff, 50, 50, 50);
            setConstrainer (&constrainer);
            setContentOwned (c, false);
            setResizable(true, false);

        void closeButtonPressed() override

        JUCEApplication& app;
        juce::ComponentBoundsConstrainer constrainer;


If I put back frameRect.origin.y -= proposedFrameSize.height - frameRect.size.height; l. 2227 of modules/juce_gui_basics/native/, the problem is fixed.

I use XCode 12.5 by the way.

Thanks for the code example, I think I can reproduce the issue now and I have a potential fix. I’ll update this thread once it’s merged.

1 Like

I think it’s fixed now :slight_smile: thank you!

This was the fix, for future reference: