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
This commit is contained in:
Axel Dörfler 2005-12-06 23:15:48 +00:00
parent 817656943f
commit 715476b7ef
2 changed files with 32 additions and 6 deletions

View File

@ -285,6 +285,7 @@ private:
bool IsFilePanel() const; bool IsFilePanel() const;
void _CreateTopView(); void _CreateTopView();
void _AdoptResize();
void _SetFocus(BView *focusView, bool notifyIputServer = false); void _SetFocus(BView *focusView, bool notifyIputServer = false);
Shortcut* _FindShortcut(uint32 key, uint32 modifiers); Shortcut* _FindShortcut(uint32 key, uint32 modifiers);

View File

@ -737,12 +737,7 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fFrame.right = fFrame.left + width; fFrame.right = fFrame.left + width;
fFrame.bottom = fFrame.top + height; fFrame.bottom = fFrame.top + height;
// Resize views according to their resize modes - this _AdoptResize();
// 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());
FrameResized(width, height); FrameResized(width, height);
} }
break; break;
@ -1062,6 +1057,10 @@ BWindow::SetSizeLimits(float minWidth, float maxWidth,
fLink->Read<float>(&fMaxWidth); fLink->Read<float>(&fMaxWidth);
fLink->Read<float>(&fMinHeight); fLink->Read<float>(&fMinHeight);
fLink->Read<float>(&fMaxHeight); fLink->Read<float>(&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(); Unlock();
} }
@ -1622,6 +1621,9 @@ BWindow::SetLook(window_look look)
if (fLink->FlushWithReply(status) == B_OK && status == B_OK) if (fLink->FlushWithReply(status) == B_OK && status == B_OK)
fLook = look; 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; return status;
} }
@ -1849,6 +1851,7 @@ BWindow::ResizeBy(float dx, float dy)
fLink->Flush(); fLink->Flush();
fFrame.SetRightBottom(fFrame.RightBottom() + BPoint(dx, dy)); fFrame.SetRightBottom(fFrame.RightBottom() + BPoint(dx, dy));
_AdoptResize();
} }
Unlock(); 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 void
BWindow::_SetFocus(BView *focusView, bool notifyInputServer) BWindow::_SetFocus(BView *focusView, bool notifyInputServer)
{ {