BView/BBox: Fixed FrameResized() handling.

* BView incorrectly passed the current width and height to
  FrameResized(), not the one from the message. Since there is such
  a call for each size change, a Draw() might have been called for
  each of those in return.
* This should also fix such problems in BMenuBar, as it used the size
  from FrameResized() as it should have.
* BBox now correctly takes the update events into account, and no
  longer ignores the size passed to FrameResized().
* This fixes bug #3037.
This commit is contained in:
Axel Dörfler 2017-03-24 16:27:15 +01:00
parent a652a5fed3
commit ff4dee1caf
2 changed files with 8 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2015 Haiku, Inc. All Rights Reserved. * Copyright 2001-2017 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@ -322,7 +322,7 @@ BBox::FrameResized(float width, float height)
// TODO: this must be made part of the be_control_look stuff! // TODO: this must be made part of the be_control_look stuff!
int32 borderSize = fStyle == B_PLAIN_BORDER ? 0 : 2; int32 borderSize = fStyle == B_PLAIN_BORDER ? 0 : 2;
BRect invalid(bounds); BRect invalid(fBounds);
if (fBounds.right < bounds.right) { if (fBounds.right < bounds.right) {
// enlarging // enlarging
invalid.left = fBounds.right - borderSize; invalid.left = fBounds.right - borderSize;
@ -351,8 +351,8 @@ BBox::FrameResized(float width, float height)
} }
} }
fBounds.right = bounds.right; fBounds.right = fBounds.left + width;
fBounds.bottom = bounds.bottom; fBounds.bottom = fBounds.top + height;
} }
@ -395,6 +395,7 @@ void
BBox::FrameMoved(BPoint newLocation) BBox::FrameMoved(BPoint newLocation)
{ {
BView::FrameMoved(newLocation); BView::FrameMoved(newLocation);
fBounds.OffsetTo(newLocation);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2015 Haiku, Inc. All rights reserved. * Copyright 2001-2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -4894,10 +4894,8 @@ BView::MessageReceived(BMessage* message)
if (!message->HasSpecifiers()) { if (!message->HasSpecifiers()) {
switch (message->what) { switch (message->what) {
case B_VIEW_RESIZED: case B_VIEW_RESIZED:
// By the time the message arrives, the bounds may have FrameResized(message->GetInt32("width", 0),
// changed already, that's why we don't use the values message->GetInt32("height", 0));
// in the message itself.
FrameResized(fBounds.Width(), fBounds.Height());
break; break;
case B_VIEW_MOVED: case B_VIEW_MOVED: