* 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;
BPrivate::PortLink *fLink;
BMessageRunner *fPulseRunner;
BRect fCurrentFrame; // not yet used
BRect fPreviousFrame;
uint32 _reserved[9];
};
+56 -28
View File
@@ -783,8 +783,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fFrame.bottom = fFrame.top + height;
_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;
}
@@ -798,8 +804,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
// in an _UPDATE_ message
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;
}
@@ -1232,23 +1244,19 @@ BWindow::SetZoomLimits(float maxWidth, float maxHeight)
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!
MoveTo(rec_position);
ResizeTo(rec_width, rec_height);
// the default implementation of this hook function
// just does the obvious:
MoveTo(leftTop);
ResizeTo(width, height);
}
void
BWindow::Zoom()
{
// TODO: broken.
// TODO: What about locking?!?
float minWidth, minHeight;
BScreen screen;
/*
from BeBook:
However, if the window's rectangle already matches these "zoom" dimensions
@@ -1256,34 +1264,54 @@ BWindow::Zoom()
("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:
The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from
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(),
minHeight = fMaxZoomHeight;
minWidth = fMaxZoomWidth;
float zoomedWidth = fMaxZoomWidth;
float zoomedHeight = fMaxZoomHeight;
// 2) the rectangle defined by SetSizeLimits()
if (fMaxHeight < minHeight)
minHeight = fMaxHeight;
if (fMaxWidth < minWidth)
minWidth = fMaxWidth;
if (fMaxWidth < zoomedWidth)
zoomedWidth = fMaxWidth;
if (fMaxHeight < zoomedHeight)
zoomedHeight = fMaxHeight;
// 3) the screen rectangle
if (screen.Frame().Width() < minWidth)
minWidth = screen.Frame().Width();
if (screen.Frame().Height() < minHeight)
minHeight = screen.Frame().Height();
BScreen screen(this);
float screenWidth = screen.Frame().Width() - 2 * borderWidth;
float screenHeight = screen.Frame().Height() - (borderWidth + tabHeight);
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);
}