* fixed window zooming/unzooming behaviour

* fixed FrameResized() and FrameMoved() not
  being called anymore in response to ResizeTo()
  and MoveTo() since I introduced a check in
  DispatchMessage() (fixes bug #123)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-02-09 16:39:46 +00:00
parent ebae3c7d61
commit c81d2e7a59
2 changed files with 57 additions and 29 deletions
+1 -1
View File
@@ -338,7 +338,7 @@ private:
int32 fLastViewToken; int32 fLastViewToken;
BPrivate::PortLink *fLink; BPrivate::PortLink *fLink;
BMessageRunner *fPulseRunner; BMessageRunner *fPulseRunner;
BRect fCurrentFrame; // not yet used BRect fPreviousFrame;
uint32 _reserved[9]; uint32 _reserved[9];
}; };
+56 -28
View File
@@ -783,8 +783,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fFrame.bottom = fFrame.top + height; fFrame.bottom = fFrame.top + height;
_AdoptResize(); _AdoptResize();
FrameResized(width, height); // FrameResized(width, height);
} }
// call hook function anyways
// TODO: When a window is resized programmatically,
// it receives this message, and maybe it is wise to
// keep the asynchronous nature of this process to
// not risk breaking any apps.
FrameResized(width, height);
} }
break; break;
} }
@@ -798,8 +804,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
// in an _UPDATE_ message // in an _UPDATE_ message
fFrame.OffsetTo(origin); fFrame.OffsetTo(origin);
FrameMoved(origin); // FrameMoved(origin);
} }
// call hook function anyways
// TODO: When a window is moved programmatically,
// it receives this message, and maybe it is wise to
// keep the asynchronous nature of this process to
// not risk breaking any apps.
FrameMoved(origin);
} }
break; break;
} }
@@ -1232,23 +1244,19 @@ BWindow::SetZoomLimits(float maxWidth, float maxHeight)
void void
BWindow::Zoom(BPoint rec_position, float rec_width, float rec_height) BWindow::Zoom(BPoint leftTop, float width, float height)
{ {
// this is also a Hook function! // the default implementation of this hook function
// just does the obvious:
MoveTo(rec_position); MoveTo(leftTop);
ResizeTo(rec_width, rec_height); ResizeTo(width, height);
} }
void void
BWindow::Zoom() BWindow::Zoom()
{ {
// TODO: broken.
// TODO: What about locking?!? // TODO: What about locking?!?
float minWidth, minHeight;
BScreen screen;
/* /*
from BeBook: from BeBook:
However, if the window's rectangle already matches these "zoom" dimensions However, if the window's rectangle already matches these "zoom" dimensions
@@ -1256,34 +1264,54 @@ BWindow::Zoom()
("non-zoomed") size and location. (??????) ("non-zoomed") size and location. (??????)
*/ */
if (Frame().Width() == fMaxZoomWidth && Frame().Height() == fMaxZoomHeight) {
BPoint position(Frame().left, Frame().top);
Zoom(position, fMaxZoomWidth, fMaxZoomHeight);
return;
}
/* From BeBook: /* From BeBook:
The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from
the smallest of three rectangles: the smallest of three rectangles:
*/ */
// TODO: make more elaborate (figure out this window's
// tab height and border width... maybe ask app_server)
float borderWidth = 5.0;
float tabHeight = 26.0;
// 1) the rectangle defined by SetZoomLimits(), // 1) the rectangle defined by SetZoomLimits(),
minHeight = fMaxZoomHeight; float zoomedWidth = fMaxZoomWidth;
minWidth = fMaxZoomWidth; float zoomedHeight = fMaxZoomHeight;
// 2) the rectangle defined by SetSizeLimits() // 2) the rectangle defined by SetSizeLimits()
if (fMaxHeight < minHeight) if (fMaxWidth < zoomedWidth)
minHeight = fMaxHeight; zoomedWidth = fMaxWidth;
if (fMaxWidth < minWidth) if (fMaxHeight < zoomedHeight)
minWidth = fMaxWidth; zoomedHeight = fMaxHeight;
// 3) the screen rectangle // 3) the screen rectangle
if (screen.Frame().Width() < minWidth) BScreen screen(this);
minWidth = screen.Frame().Width(); float screenWidth = screen.Frame().Width() - 2 * borderWidth;
if (screen.Frame().Height() < minHeight) float screenHeight = screen.Frame().Height() - (borderWidth + tabHeight);
minHeight = screen.Frame().Height(); if (screenWidth < zoomedWidth)
zoomedWidth = screenWidth;
if (screenHeight < zoomedHeight)
zoomedHeight = screenHeight;
Zoom(Frame().LeftTop(), minWidth, minHeight); BPoint zoomedLeftTop = screen.Frame().LeftTop() + BPoint(borderWidth, tabHeight);
// UN-ZOOM:
if (fPreviousFrame.IsValid()
// NOTE: don't check for fFrame.LeftTop() == zoomedLeftTop
// -> makes it easier on the user to get a window back into place
&& fFrame.Width() == zoomedWidth
&& fFrame.Height() == zoomedHeight) {
// already zoomed!
Zoom(fPreviousFrame.LeftTop(), fPreviousFrame.Width(), fPreviousFrame.Height());
return;
}
// ZOOM:
// remember fFrame for later "unzooming"
fPreviousFrame = fFrame;
Zoom(zoomedLeftTop, zoomedWidth, zoomedHeight);
} }