From ff4dee1cafee7a9bf111fc361e58e7829e4852cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 24 Mar 2017 16:27:15 +0100 Subject: [PATCH] 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. --- src/kits/interface/Box.cpp | 9 +++++---- src/kits/interface/View.cpp | 8 +++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/Box.cpp b/src/kits/interface/Box.cpp index 7efdbb45c9..955bd0fbe7 100644 --- a/src/kits/interface/Box.cpp +++ b/src/kits/interface/Box.cpp @@ -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. * * Authors: @@ -322,7 +322,7 @@ BBox::FrameResized(float width, float height) // TODO: this must be made part of the be_control_look stuff! int32 borderSize = fStyle == B_PLAIN_BORDER ? 0 : 2; - BRect invalid(bounds); + BRect invalid(fBounds); if (fBounds.right < bounds.right) { // enlarging invalid.left = fBounds.right - borderSize; @@ -351,8 +351,8 @@ BBox::FrameResized(float width, float height) } } - fBounds.right = bounds.right; - fBounds.bottom = bounds.bottom; + fBounds.right = fBounds.left + width; + fBounds.bottom = fBounds.top + height; } @@ -395,6 +395,7 @@ void BBox::FrameMoved(BPoint newLocation) { BView::FrameMoved(newLocation); + fBounds.OffsetTo(newLocation); } diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index fb7a55fc0c..8f164a6987 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -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. * * Authors: @@ -4894,10 +4894,8 @@ BView::MessageReceived(BMessage* message) if (!message->HasSpecifiers()) { switch (message->what) { case B_VIEW_RESIZED: - // By the time the message arrives, the bounds may have - // changed already, that's why we don't use the values - // in the message itself. - FrameResized(fBounds.Width(), fBounds.Height()); + FrameResized(message->GetInt32("width", 0), + message->GetInt32("height", 0)); break; case B_VIEW_MOVED: