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:
@@ -528,8 +528,12 @@ BView::ConvertFromParent(BRect rect) const
|
|||||||
void
|
void
|
||||||
BView::ConvertToScreen(BPoint *pt) const
|
BView::ConvertToScreen(BPoint *pt) const
|
||||||
{
|
{
|
||||||
if (!parent)
|
if (!parent) {
|
||||||
|
if (owner)
|
||||||
|
owner->ConvertToScreen(pt);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
do_owner_check_no_pick();
|
do_owner_check_no_pick();
|
||||||
|
|
||||||
@@ -3323,6 +3327,13 @@ BView::ResizeBy(float deltaWidth, float deltaHeight)
|
|||||||
void
|
void
|
||||||
BView::ResizeTo(float width, float height)
|
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())
|
if (width == fBounds.Width() && height == fBounds.Height())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1892,28 +1892,36 @@ BView* BWindow::LastMouseMovedView() const
|
|||||||
|
|
||||||
void BWindow::MoveBy(float dx, float dy)
|
void BWindow::MoveBy(float dx, float dy)
|
||||||
{
|
{
|
||||||
Lock();
|
if (dx != 0.0 || dy != 0.0) {
|
||||||
fLink->StartMessage( AS_WINDOW_MOVE );
|
|
||||||
fLink->Attach<float>( dx );
|
Lock();
|
||||||
fLink->Attach<float>( dy );
|
|
||||||
fLink->Flush();
|
fLink->StartMessage(AS_WINDOW_MOVE);
|
||||||
Unlock();
|
fLink->Attach<float>(dx);
|
||||||
|
fLink->Attach<float>(dy);
|
||||||
|
fLink->Flush();
|
||||||
|
|
||||||
|
fFrame.OffsetBy(dx, dy);
|
||||||
|
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void BWindow::MoveTo( BPoint point )
|
void BWindow::MoveTo( BPoint point )
|
||||||
{
|
{
|
||||||
|
printf("BWindow::MoveTo(%.1f, %.1f)\n", point.x, point.y);
|
||||||
if (fFrame.left == point.x && fFrame.top == point.y)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fFrame.OffsetTo(point);
|
|
||||||
Lock();
|
Lock();
|
||||||
fLink->StartMessage( AS_WINDOW_MOVE );
|
|
||||||
fLink->Attach<float>( fFrame.left );
|
if (fFrame.left != point.x || fFrame.top != point.y) {
|
||||||
fLink->Attach<float>( fFrame.top );
|
|
||||||
fLink->Flush();
|
float xOffset = point.x - fFrame.left;
|
||||||
|
float yOffset = point.y - fFrame.top;
|
||||||
|
|
||||||
|
MoveBy(xOffset, yOffset);
|
||||||
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1921,38 +1929,36 @@ void BWindow::MoveTo( BPoint point )
|
|||||||
|
|
||||||
void BWindow::MoveTo(float x, float y)
|
void BWindow::MoveTo(float x, float y)
|
||||||
{
|
{
|
||||||
MoveTo(BPoint(x,y));
|
MoveTo(BPoint(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void BWindow::ResizeBy(float dx, float dy)
|
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();
|
Lock();
|
||||||
fLink->StartMessage( AS_WINDOW_RESIZE );
|
// stay in minimum & maximum frame limits
|
||||||
fLink->Attach<float>( fFrame.Width() );
|
if (fFrame.Width() + dx < fMinWindWidth)
|
||||||
fLink->Attach<float>( fFrame.Height() );
|
dx = fMinWindWidth - fFrame.Width();
|
||||||
fLink->Flush();
|
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) {
|
||||||
|
|
||||||
top_view->ResizeBy(dxNew, dyNew);
|
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();
|
||||||
|
|
||||||
|
fFrame.SetRightBottom( fFrame.RightBottom() + BPoint(dx, dy));
|
||||||
|
top_view->ResizeBy(dx, dy);
|
||||||
|
}
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1960,7 +1966,9 @@ void BWindow::ResizeBy(float dx, float dy)
|
|||||||
|
|
||||||
void BWindow::ResizeTo(float width, float height)
|
void BWindow::ResizeTo(float width, float height)
|
||||||
{
|
{
|
||||||
|
Lock();
|
||||||
ResizeBy(width - fFrame.Width(), height - fFrame.Height());
|
ResizeBy(width - fFrame.Width(), height - fFrame.Height());
|
||||||
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
}
|
}
|
||||||
case AS_LAYER_SCROLL:
|
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 dh;
|
||||||
float dv;
|
float dv;
|
||||||
|
|
||||||
@@ -551,8 +551,6 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
_CopyBits(myRootLayer, cl, src, dst, xOffset, yOffset);
|
_CopyBits(myRootLayer, cl, src, dst, xOffset, yOffset);
|
||||||
|
|
||||||
cl->fLayerData->OffsetOrigin(BPoint(dh, dv));
|
cl->fLayerData->OffsetOrigin(BPoint(dh, dv));
|
||||||
//cl->fBoundsLeftTop += BPoint(dh, dv);
|
|
||||||
//cl->fFrame.OffsetBy(BPoint(-dh, -dv));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1420,12 +1418,13 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
}
|
}
|
||||||
case AS_WINDOW_RESIZE:
|
case AS_WINDOW_RESIZE:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE\n",fName));
|
|
||||||
float xResizeBy;
|
float xResizeBy;
|
||||||
float yResizeBy;
|
float yResizeBy;
|
||||||
|
|
||||||
link.Read<float>(&xResizeBy);
|
link.Read<float>(&xResizeBy);
|
||||||
link.Read<float>(&yResizeBy);
|
link.Read<float>(&yResizeBy);
|
||||||
|
|
||||||
|
STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n",fName, xResizeBy, yResizeBy));
|
||||||
|
|
||||||
fWinBorder->ResizeBy(xResizeBy, yResizeBy);
|
fWinBorder->ResizeBy(xResizeBy, yResizeBy);
|
||||||
|
|
||||||
@@ -1433,13 +1432,14 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
}
|
}
|
||||||
case AS_WINDOW_MOVE:
|
case AS_WINDOW_MOVE:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE\n",fName));
|
|
||||||
float xMoveBy;
|
float xMoveBy;
|
||||||
float yMoveBy;
|
float yMoveBy;
|
||||||
|
|
||||||
link.Read<float>(&xMoveBy);
|
link.Read<float>(&xMoveBy);
|
||||||
link.Read<float>(&yMoveBy);
|
link.Read<float>(&yMoveBy);
|
||||||
|
|
||||||
|
STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n",fName, xMoveBy, yMoveBy));
|
||||||
|
|
||||||
fWinBorder->MoveBy(xMoveBy, yMoveBy);
|
fWinBorder->MoveBy(xMoveBy, yMoveBy);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ void WinBorder::Draw(const BRect &r)
|
|||||||
//! Moves the winborder with redraw
|
//! Moves the winborder with redraw
|
||||||
void WinBorder::MoveBy(float x, float y)
|
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)
|
if(fDecorator)
|
||||||
fDecorator->MoveBy(x,y);
|
fDecorator->MoveBy(x,y);
|
||||||
|
|
||||||
@@ -320,6 +320,7 @@ void WinBorder::MoveBy(float x, float y)
|
|||||||
void WinBorder::ResizeBy(float x, float y)
|
void WinBorder::ResizeBy(float x, float y)
|
||||||
{
|
{
|
||||||
// TODO: account for size limits
|
// TODO: account for size limits
|
||||||
|
// NOTE: size limits are also regarded in BWindow::ResizeXX()
|
||||||
|
|
||||||
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
||||||
if(fDecorator)
|
if(fDecorator)
|
||||||
|
|||||||
Reference in New Issue
Block a user