Added some TODO comments in Window.cpp, improved coordinate conversion in View.cpp. I'm not sure if this really works correctly, I need to write more tests. The scrolling test actually does more of what it is supposed to. At least the scrolling properly follows the mouse now. Missing are the movement of child views, the rebuilding of clipping, and I think that the scrolling needs to be synced to update requests having been fullfilled, or else some parts of the View will be CopyBits()ed which have not been drawn after having been scrolled into view by previous calls to ScrollBy(). Any insights appreciated.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12485 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4828a7251f
commit
3505574164
|
@ -414,6 +414,15 @@ BView::ConvertToParent(BPoint *pt) const
|
|||
|
||||
check_lock_no_pick();
|
||||
|
||||
// TODO: handle scale
|
||||
|
||||
BPoint origin = Origin();
|
||||
|
||||
// our local coordinate transformation
|
||||
pt->x -= origin.x;
|
||||
pt->y -= origin.y;
|
||||
|
||||
// our bounds location within the parent
|
||||
pt->x += originX;
|
||||
pt->y += originY;
|
||||
}
|
||||
|
@ -422,16 +431,9 @@ BView::ConvertToParent(BPoint *pt) const
|
|||
BPoint
|
||||
BView::ConvertToParent(BPoint pt) const
|
||||
{
|
||||
if (!parent)
|
||||
ConvertToParent(&pt);
|
||||
|
||||
return pt;
|
||||
|
||||
check_lock_no_pick();
|
||||
|
||||
BPoint p;
|
||||
p.x = pt.x + originX;
|
||||
p.y = pt.y + originY;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -443,24 +445,25 @@ BView::ConvertFromParent(BPoint *pt) const
|
|||
|
||||
check_lock_no_pick();
|
||||
|
||||
// TODO: handle scale
|
||||
|
||||
BPoint origin = Origin();
|
||||
// our bounds location within the parent
|
||||
pt->x -= originX;
|
||||
pt->y -= originY;
|
||||
|
||||
// our local coordinate transformation
|
||||
pt->x += origin.x;
|
||||
pt->y += origin.y;
|
||||
}
|
||||
|
||||
|
||||
BPoint
|
||||
BView::ConvertFromParent(BPoint pt) const
|
||||
{
|
||||
if (!parent)
|
||||
ConvertFromParent(&pt);
|
||||
|
||||
return pt;
|
||||
|
||||
check_lock_no_pick();
|
||||
|
||||
BPoint p;
|
||||
p.x = pt.x - originX;
|
||||
p.y = pt.y - originY;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -472,6 +475,14 @@ BView::ConvertToParent(BRect *rect) const
|
|||
|
||||
check_lock_no_pick();
|
||||
|
||||
// TODO: handle scale
|
||||
|
||||
BPoint origin = Origin();
|
||||
|
||||
// our local coordinate transformation
|
||||
rect->OffsetBy(-origin.x, -origin.y);
|
||||
|
||||
// our bounds location within the parent
|
||||
rect->OffsetBy(originX, originY);
|
||||
}
|
||||
|
||||
|
@ -479,12 +490,9 @@ BView::ConvertToParent(BRect *rect) const
|
|||
BRect
|
||||
BView::ConvertToParent(BRect rect) const
|
||||
{
|
||||
if (!parent)
|
||||
ConvertToParent(&rect);
|
||||
|
||||
return rect;
|
||||
|
||||
check_lock_no_pick();
|
||||
|
||||
return rect.OffsetByCopy(originX, originY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -496,19 +504,24 @@ BView::ConvertFromParent(BRect *rect) const
|
|||
|
||||
check_lock_no_pick();
|
||||
|
||||
// TODO: handle scale
|
||||
|
||||
BPoint origin = Origin();
|
||||
|
||||
// our bounds location within the parent
|
||||
rect->OffsetBy(-originX, -originY);
|
||||
|
||||
// our local coordinate transformation
|
||||
rect->OffsetBy(origin.x, origin.y);
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
BView::ConvertFromParent(BRect rect) const
|
||||
{
|
||||
if (!parent)
|
||||
ConvertFromParent(&rect);
|
||||
|
||||
return rect;
|
||||
|
||||
check_lock_no_pick();
|
||||
|
||||
return rect.OffsetByCopy(-originX, -originY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -528,16 +541,9 @@ BView::ConvertToScreen(BPoint *pt) const
|
|||
BPoint
|
||||
BView::ConvertToScreen(BPoint pt) const
|
||||
{
|
||||
if (!parent)
|
||||
ConvertToScreen(&pt);
|
||||
|
||||
return pt;
|
||||
|
||||
do_owner_check_no_pick();
|
||||
|
||||
BPoint p;
|
||||
p = ConvertToParent(pt);
|
||||
p = parent->ConvertToScreen(p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -561,20 +567,9 @@ BView::ConvertFromScreen(BPoint *pt) const
|
|||
BPoint
|
||||
BView::ConvertFromScreen(BPoint pt) const
|
||||
{
|
||||
if (!parent) {
|
||||
if (owner)
|
||||
return owner->ConvertFromScreen(pt);
|
||||
ConvertFromScreen(&pt);
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
do_owner_check_no_pick();
|
||||
|
||||
BPoint p;
|
||||
p = ConvertFromParent(pt);
|
||||
p = parent->ConvertFromScreen(p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -594,13 +589,8 @@ BView::ConvertToScreen(BRect *rect) const
|
|||
BRect
|
||||
BView::ConvertToScreen(BRect rect) const
|
||||
{
|
||||
if (!parent)
|
||||
return rect;
|
||||
ConvertToScreen(&rect);
|
||||
|
||||
do_owner_check_no_pick();
|
||||
|
||||
rect = ConvertToParent(rect);
|
||||
rect = parent->ConvertToScreen(rect);
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
@ -621,13 +611,8 @@ BView::ConvertFromScreen(BRect *rect) const
|
|||
BRect
|
||||
BView::ConvertFromScreen(BRect rect) const
|
||||
{
|
||||
if (!parent)
|
||||
return rect;
|
||||
ConvertFromScreen(&rect);
|
||||
|
||||
do_owner_check_no_pick();
|
||||
|
||||
rect = ConvertFromParent(rect);
|
||||
rect = parent->ConvertFromScreen(rect);
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
@ -773,9 +758,8 @@ BView::SetOrigin(BPoint pt)
|
|||
void
|
||||
BView::SetOrigin(float x, float y)
|
||||
{
|
||||
// TODO: maybe app_server should do a redraw? - WRITE down into specs
|
||||
|
||||
if (x == originX && y == originY)
|
||||
if (!(fState->flags & B_VIEW_ORIGIN_BIT) &&
|
||||
x == fState->coordSysOrigin.x && y == fState->coordSysOrigin.y)
|
||||
return;
|
||||
|
||||
if (do_owner_check()) {
|
||||
|
@ -786,6 +770,8 @@ BView::SetOrigin(float x, float y)
|
|||
|
||||
// invalidate this flag, to stay in sync with app_server
|
||||
fState->flags |= B_VIEW_ORIGIN_BIT;
|
||||
// TODO: Bounds() is effected by SetOrigin() (?),
|
||||
// so should we set the COORD_BIT too?
|
||||
|
||||
// our local coord system origin has changed, so when archiving we'll add this too
|
||||
fState->archivingFlags |= B_VIEW_ORIGIN_BIT;
|
||||
|
@ -793,7 +779,7 @@ BView::SetOrigin(float x, float y)
|
|||
|
||||
|
||||
BPoint
|
||||
BView::Origin(void) const
|
||||
BView::Origin() const
|
||||
{
|
||||
if (fState->flags & B_VIEW_ORIGIN_BIT) {
|
||||
do_owner_check();
|
||||
|
@ -1291,6 +1277,7 @@ BView::ScrollBy(float dh, float dv)
|
|||
owner->fLink->Flush();
|
||||
|
||||
fState->flags |= B_VIEW_COORD_BIT;
|
||||
fState->flags |= B_VIEW_ORIGIN_BIT;
|
||||
}
|
||||
|
||||
// we modify our bounds rectangle by dh/dv coord units hor/ver.
|
||||
|
|
|
@ -931,6 +931,7 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||
if (view)
|
||||
{
|
||||
STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y));
|
||||
// TODO: only if B_FRAME_EVENTS, no?
|
||||
view->FrameMoved( where );
|
||||
}
|
||||
else
|
||||
|
@ -955,6 +956,7 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||
view = findView(top_view, token);
|
||||
if (view){
|
||||
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight));
|
||||
// TODO: only if B_FRAME_EVENTS, no?
|
||||
view->FrameResized( newWidth, newHeight );
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue