setResizeLimits strange behavior


#1

Hello

I am running my app in windows 8. The app has a pop up window that is subclassed from DocumentWindow,

The content component is added with resizeToFitWhenContentChangesSize==true. The actual size of content component can be less than 128 depending of display size.

The window itself doesn't have neither resizable border nor resizing corner and can not be resized by user mouse interaction.

The strange behavior happens when moving the window by dragging with mouse - the size of window changes at first to 128x128 and after the component triggers repaint it is resized to fit the component of size 100x80

128x128 is the default limitation of DocumentWindow ctor:


DocumentWindow::DocumentWindow (const String& title,
                                Colour backgroundColour,
                                int requiredButtons_,
                                bool addToDesktop_)
    : ResizableWindow (title, backgroundColour, addToDesktop_),
      titleBarHeight (26),
      menuBarHeight (24),
      requiredButtons (requiredButtons_),
     #if JUCE_MAC
      positionTitleBarButtonsOnLeft (true),
     #else
      positionTitleBarButtonsOnLeft (false),
     #endif
      drawTitleTextCentred (true),
      menuBarModel (nullptr)
{
    setResizeLimits (128, 128, 32768, 32768);
    DocumentWindow::lookAndFeelChanged();
}
 

The issue is resolved when i set setResizeLimits(100,80,32768,32768) explicitly in my subclass.

It seems strange to me because the description says

it's only when  the window is being resized by the user that these values are enforced

 

 


#2

Maybe it shouldn't say that in the docs.. All it really meant is that a direct call to setBounds() will bypass the constrainer. In a complex object like a DocumentWindow, there will be all kinds of resize callbacks that get triggered when the content is resized, and it's not surprising that somewhere in that process the constrainer might kick in.