Remove the forced resizing to preferred size when CenterIn is called, and
instead just check if the size limits need to be set. The code that previously did this when processing the B_LAYOUT_WINDOW message was extracted into a private method, which is called from both places. This may be slightly wasteful in some cases (since the size limits may be set multiple times), but it is definitely needed because without it both of the current test apps (DiskProbe and Screenshot) did not have properly centered windows. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32622 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1406,14 +1406,7 @@ FrameMoved(origin);
|
||||
|
||||
case B_LAYOUT_WINDOW:
|
||||
{
|
||||
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);
|
||||
}
|
||||
_CheckSizeLimits();
|
||||
|
||||
// do the actual layout
|
||||
fTopView->Layout(false);
|
||||
@@ -2460,11 +2453,8 @@ BWindow::ResizeTo(float width, float height)
|
||||
void
|
||||
BWindow::CenterIn(const BRect& rect)
|
||||
{
|
||||
// Force layout resizing if needed
|
||||
if (GetLayout() != NULL) {
|
||||
BSize size = GetLayout()->PreferredSize();
|
||||
ResizeTo(size.Width(), size.Height());
|
||||
}
|
||||
// Set size limits now if needed
|
||||
_CheckSizeLimits();
|
||||
|
||||
MoveTo(BLayoutUtils::AlignInFrame(rect, Size(),
|
||||
BAlignment(B_ALIGN_HORIZONTAL_CENTER,
|
||||
@@ -3884,6 +3874,20 @@ 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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user