From 715476b7efd237a7d0ac3e92f7c2fdaabca3dd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 6 Dec 2005 23:15:48 +0000 Subject: [PATCH] The resize code now works correctly, finally - it temporarily did harm ;) The BViews must be resized directly after every change in the window size - we cannot wait until B_WINDOW_RESIZED, since subsequent calls have wrong view sizes, then. B_WINDOW_RESIZED is only really useful for app_server caused window resizing. Added TODO to SetLook(): it may change the window size as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15385 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Window.h | 1 + src/kits/interface/Window.cpp | 37 +++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index da29109add..a20f3e13a2 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -285,6 +285,7 @@ private: bool IsFilePanel() const; void _CreateTopView(); + void _AdoptResize(); void _SetFocus(BView *focusView, bool notifyIputServer = false); Shortcut* _FindShortcut(uint32 key, uint32 modifiers); diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 67597958d0..993bf19dcc 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -737,12 +737,7 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) fFrame.right = fFrame.left + width; fFrame.bottom = fFrame.top + height; - // Resize views according to their resize modes - this - // saves us some server communication, as the server - // does the same with our views on its side. - fTopView->_ResizeBy(width - fTopView->Bounds().Width(), - height - fTopView->Bounds().Height()); - + _AdoptResize(); FrameResized(width, height); } break; @@ -1062,6 +1057,10 @@ BWindow::SetSizeLimits(float minWidth, float maxWidth, fLink->Read(&fMaxWidth); fLink->Read(&fMinHeight); fLink->Read(&fMaxHeight); + + _AdoptResize(); + // TODO: the same has to be done for SetLook() (that can alter + // the size limits, and hence, the size of the window } Unlock(); } @@ -1622,6 +1621,9 @@ BWindow::SetLook(window_look look) if (fLink->FlushWithReply(status) == B_OK && status == B_OK) fLook = look; + // TODO: this could have changed the window size, and thus, we + // need to get it from the server (and call _AdoptResize()). + return status; } @@ -1849,6 +1851,7 @@ BWindow::ResizeBy(float dx, float dy) fLink->Flush(); fFrame.SetRightBottom(fFrame.RightBottom() + BPoint(dx, dy)); + _AdoptResize(); } Unlock(); } @@ -2371,6 +2374,28 @@ BWindow::_CreateTopView() } +/*! + Resizes the top view to match the window size. This will also + adapt the size of all its child views as needed. + This method has to be called whenever the frame of the window + changes. +*/ +void +BWindow::_AdoptResize() +{ + // Resize views according to their resize modes - this + // saves us some server communication, as the server + // does the same with our views on its side. + + int32 deltaWidth = fFrame.Width() - fTopView->Bounds().Width(); + int32 deltaHeight = fFrame.Height() - fTopView->Bounds().Height(); + if (deltaWidth == 0 && deltaHeight == 0) + return; + + fTopView->_ResizeBy(deltaWidth, deltaHeight); +} + + void BWindow::_SetFocus(BView *focusView, bool notifyInputServer) {