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,
juce::Desktop::getInstance().getDefaultLookAndFeel()
.findColour (ResizableWindow::backgroundColourId),
DocumentWindow::allButtons)
{
setUsingNativeTitleBar (false); // also works with 'true'
setContentOwned (new MainComponent(), true);
#if JUCE_IOS || JUCE_ANDROID
setFullScreen (true);
#else
setResizable (true, false); // no corner resizer
centreWithSize (getWidth(), getHeight());
#endif
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
{
public:
MainWindow (const juce::String& name, juce::Component* c, JUCEApplication& a)
: DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
.findColour (ResizableWindow::backgroundColourId),
juce::DocumentWindow::allButtons),
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);
setVisible(true);
setResizable(true, false);
setUsingNativeTitleBar(true);
}
void closeButtonPressed() override
{
app.systemRequestedQuit();
}
private:
JUCEApplication& app;
juce::ComponentBoundsConstrainer constrainer;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
};
If I put back frameRect.origin.y -= proposedFrameSize.height - frameRect.size.height; l. 2227 of modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm, 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.
I think it’s fixed now
thank you!
This was the fix, for future reference:
