fixed BWindow::MoveXX(), BWindow::ResizeXX() and BView::ConvertToScreen()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12491 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8f6b562ad5
commit
9715a3e1bf
@ -528,8 +528,12 @@ BView::ConvertFromParent(BRect rect) const
|
||||
void
|
||||
BView::ConvertToScreen(BPoint *pt) const
|
||||
{
|
||||
if (!parent)
|
||||
if (!parent) {
|
||||
if (owner)
|
||||
owner->ConvertToScreen(pt);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
do_owner_check_no_pick();
|
||||
|
||||
@ -3323,6 +3327,13 @@ BView::ResizeBy(float deltaWidth, float deltaHeight)
|
||||
void
|
||||
BView::ResizeTo(float width, float height)
|
||||
{
|
||||
// NOTE: I think this check makes sense, but I didn't
|
||||
// test what R5 does.
|
||||
if (width < 0.0)
|
||||
width = 0.0;
|
||||
if (height < 0.0)
|
||||
height = 0.0;
|
||||
|
||||
if (width == fBounds.Width() && height == fBounds.Height())
|
||||
return;
|
||||
|
||||
|
@ -1892,28 +1892,36 @@ BView* BWindow::LastMouseMovedView() const
|
||||
|
||||
void BWindow::MoveBy(float dx, float dy)
|
||||
{
|
||||
if (dx != 0.0 || dy != 0.0) {
|
||||
|
||||
Lock();
|
||||
fLink->StartMessage( AS_WINDOW_MOVE );
|
||||
fLink->Attach<float>( dx );
|
||||
fLink->Attach<float>( dy );
|
||||
|
||||
fLink->StartMessage(AS_WINDOW_MOVE);
|
||||
fLink->Attach<float>(dx);
|
||||
fLink->Attach<float>(dy);
|
||||
fLink->Flush();
|
||||
|
||||
fFrame.OffsetBy(dx, dy);
|
||||
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BWindow::MoveTo( BPoint point )
|
||||
{
|
||||
|
||||
if (fFrame.left == point.x && fFrame.top == point.y)
|
||||
return;
|
||||
|
||||
fFrame.OffsetTo(point);
|
||||
printf("BWindow::MoveTo(%.1f, %.1f)\n", point.x, point.y);
|
||||
Lock();
|
||||
fLink->StartMessage( AS_WINDOW_MOVE );
|
||||
fLink->Attach<float>( fFrame.left );
|
||||
fLink->Attach<float>( fFrame.top );
|
||||
fLink->Flush();
|
||||
|
||||
if (fFrame.left != point.x || fFrame.top != point.y) {
|
||||
|
||||
float xOffset = point.x - fFrame.left;
|
||||
float yOffset = point.y - fFrame.top;
|
||||
|
||||
MoveBy(xOffset, yOffset);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
@ -1921,38 +1929,36 @@ void BWindow::MoveTo( BPoint point )
|
||||
|
||||
void BWindow::MoveTo(float x, float y)
|
||||
{
|
||||
MoveTo(BPoint(x,y));
|
||||
MoveTo(BPoint(x, y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BWindow::ResizeBy(float dx, float dy)
|
||||
{
|
||||
|
||||
float dxNew;
|
||||
float dyNew;
|
||||
|
||||
// stay in minimum & maximum frame limits
|
||||
dxNew = (fFrame.Width() + dx) < fMinWindWidth ? fFrame.Width() - fMinWindWidth : dx;
|
||||
if (dxNew == dx)
|
||||
dxNew = (fFrame.Width() + dx) > fMaxWindWidth ? fMaxWindWidth - fFrame.Width() : dx;
|
||||
|
||||
dyNew = (fFrame.Height() + dy) < fMinWindHeight ? fFrame.Height() - fMinWindHeight : dy;
|
||||
if (dyNew == dy)
|
||||
dyNew = (fFrame.Height() + dy) > fMaxWindHeight ? fMaxWindHeight - fFrame.Height() : dy;
|
||||
|
||||
if (dxNew == 0.0 && dyNew == 0.0)
|
||||
return;
|
||||
|
||||
fFrame.SetRightBottom( fFrame.RightBottom() + BPoint(dxNew, dyNew));
|
||||
|
||||
Lock();
|
||||
fLink->StartMessage( AS_WINDOW_RESIZE );
|
||||
fLink->Attach<float>( fFrame.Width() );
|
||||
fLink->Attach<float>( fFrame.Height() );
|
||||
// stay in minimum & maximum frame limits
|
||||
if (fFrame.Width() + dx < fMinWindWidth)
|
||||
dx = fMinWindWidth - fFrame.Width();
|
||||
if (fFrame.Width() + dx > fMaxWindWidth)
|
||||
dx = fMaxWindWidth - fFrame.Width();
|
||||
if (fFrame.Height() + dy < fMinWindHeight)
|
||||
dy = fMinWindHeight - fFrame.Height();
|
||||
if (fFrame.Height() + dy > fMaxWindHeight)
|
||||
dy = fMaxWindHeight - fFrame.Height();
|
||||
|
||||
if (dx != 0.0 || dy != 0.0) {
|
||||
|
||||
fLink->StartMessage(AS_WINDOW_RESIZE);
|
||||
// fLink->Attach<float>( fFrame.Width() );
|
||||
// fLink->Attach<float>( fFrame.Height() );
|
||||
fLink->Attach<float>(dx);
|
||||
fLink->Attach<float>(dy);
|
||||
fLink->Flush();
|
||||
|
||||
top_view->ResizeBy(dxNew, dyNew);
|
||||
fFrame.SetRightBottom( fFrame.RightBottom() + BPoint(dx, dy));
|
||||
top_view->ResizeBy(dx, dy);
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
@ -1960,7 +1966,9 @@ void BWindow::ResizeBy(float dx, float dy)
|
||||
|
||||
void BWindow::ResizeTo(float width, float height)
|
||||
{
|
||||
Lock();
|
||||
ResizeBy(width - fFrame.Width(), height - fFrame.Height());
|
||||
Unlock();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -522,7 +522,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
}
|
||||
case AS_LAYER_SCROLL:
|
||||
{
|
||||
printf("AS_LAYER_SCROLL\n");
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_SCROLL: Layer name: %s\n", fName, cl->fName->String()));
|
||||
float dh;
|
||||
float dv;
|
||||
|
||||
@ -551,8 +551,6 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
_CopyBits(myRootLayer, cl, src, dst, xOffset, yOffset);
|
||||
|
||||
cl->fLayerData->OffsetOrigin(BPoint(dh, dv));
|
||||
//cl->fBoundsLeftTop += BPoint(dh, dv);
|
||||
//cl->fFrame.OffsetBy(BPoint(-dh, -dv));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1420,26 +1418,28 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
}
|
||||
case AS_WINDOW_RESIZE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE\n",fName));
|
||||
float xResizeBy;
|
||||
float yResizeBy;
|
||||
|
||||
link.Read<float>(&xResizeBy);
|
||||
link.Read<float>(&yResizeBy);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n",fName, xResizeBy, yResizeBy));
|
||||
|
||||
fWinBorder->ResizeBy(xResizeBy, yResizeBy);
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_WINDOW_MOVE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE\n",fName));
|
||||
float xMoveBy;
|
||||
float yMoveBy;
|
||||
|
||||
link.Read<float>(&xMoveBy);
|
||||
link.Read<float>(&yMoveBy);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n",fName, xMoveBy, yMoveBy));
|
||||
|
||||
fWinBorder->MoveBy(xMoveBy, yMoveBy);
|
||||
|
||||
break;
|
||||
|
@ -309,7 +309,7 @@ void WinBorder::Draw(const BRect &r)
|
||||
//! Moves the winborder with redraw
|
||||
void WinBorder::MoveBy(float x, float y)
|
||||
{
|
||||
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
||||
STRACE(("WinBorder(%s)::MoveBy(%.1f, %.1f) fDecorator: %p\n", GetName(), x, y, fDecorator));
|
||||
if(fDecorator)
|
||||
fDecorator->MoveBy(x,y);
|
||||
|
||||
@ -320,6 +320,7 @@ void WinBorder::MoveBy(float x, float y)
|
||||
void WinBorder::ResizeBy(float x, float y)
|
||||
{
|
||||
// TODO: account for size limits
|
||||
// NOTE: size limits are also regarded in BWindow::ResizeXX()
|
||||
|
||||
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
||||
if(fDecorator)
|
||||
|
Loading…
x
Reference in New Issue
Block a user