diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index c8395c2ac4..74809825c5 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -204,6 +204,7 @@ public: float minHeight, float maxHeight); void GetSizeLimits(float* minWidth, float* maxWidth, float* minHeight, float* maxHeight); + void UpdateSizeLimits(); status_t SetDecoratorSettings(const BMessage& settings); status_t GetDecoratorSettings(BMessage* settings) const; @@ -350,8 +351,6 @@ private: void _GetDecoratorSize(float* _borderWidth, float* _tabHeight) const; - void _CheckSizeLimits(); - private: char* fTitle; int32 _unused0; diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 0b4ad0e174..bf6272db7c 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1445,7 +1445,7 @@ FrameMoved(origin); case B_LAYOUT_WINDOW: { - _CheckSizeLimits(); + UpdateSizeLimits(); // do the actual layout fTopView->Layout(false); @@ -1560,6 +1560,30 @@ BWindow::GetSizeLimits(float* _minWidth, float* _maxWidth, float* _minHeight, } +/*! Updates the window's size limits from the minimum and maximum sizes of its + top view. + + Is a no-op, unless the \c B_AUTO_UPDATE_SIZE_LIMITS window flag is set. + + The method is called automatically after a layout invalidation. Since it is + invoked asynchronously, calling this method manually is necessary, if it is + desired to adjust the limits (and as a possible side effect the window size) + earlier (e.g. before the first Show()). +*/ +void +BWindow::UpdateSizeLimits() +{ + if ((fFlags & B_AUTO_UPDATE_SIZE_LIMITS) != 0) { + // Get min/max constraints of the top view and enforce window + // size limits respectively. + BSize minSize = fTopView->MinSize(); + BSize maxSize = fTopView->MaxSize(); + SetSizeLimits(minSize.width, maxSize.width, + minSize.height, maxSize.height); + } +} + + status_t BWindow::SetDecoratorSettings(const BMessage& settings) { @@ -2501,7 +2525,7 @@ void BWindow::CenterIn(const BRect& rect) { // Set size limits now if needed - _CheckSizeLimits(); + UpdateSizeLimits(); MoveTo(BLayoutUtils::AlignInFrame(rect, Size(), BAlignment(B_ALIGN_HORIZONTAL_CENTER, @@ -3963,20 +3987,6 @@ BWindow::_GetDecoratorSize(float* _borderWidth, float* _tabHeight) const } -void -BWindow::_CheckSizeLimits() -{ - if (fFlags & B_AUTO_UPDATE_SIZE_LIMITS) { - // Get min/max constraints of the top view and enforce window - // size limits respectively. - BSize minSize = fTopView->MinSize(); - BSize maxSize = fTopView->MaxSize(); - SetSizeLimits(minSize.width, maxSize.width, - minSize.height, maxSize.height); - } -} - - // #pragma mark - C++ binary compatibility kludge