* ViewLayer::ViewAt() must not use the screen clipping to find the view
in question as it used to find the view that is under the mouse (found during a short phone session with stippi :-)). This fixes bug #1714. * The local view clipping is still not correctly maintained by the app_server, but that only affects the drawing now. I've added some commented out code that give you some visual feedback on this problem (ViewLayer::MarkAt()). * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007, Haiku, Inc.
|
* Copyright (c) 2001-2008, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -171,8 +171,10 @@ ViewLayer::AttachedToWindow(WindowLayer* window)
|
|||||||
fIsDesktopBackground = true;
|
fIsDesktopBackground = true;
|
||||||
|
|
||||||
// insert view into local token space
|
// insert view into local token space
|
||||||
if (fWindow != NULL)
|
if (fWindow != NULL) {
|
||||||
fWindow->ServerWindow()->App()->ViewTokens().SetToken(fToken, B_HANDLER_TOKEN, this);
|
fWindow->ServerWindow()->App()->ViewTokens().SetToken(fToken,
|
||||||
|
B_HANDLER_TOKEN, this);
|
||||||
|
}
|
||||||
|
|
||||||
// attach child views as well
|
// attach child views as well
|
||||||
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
||||||
@@ -244,7 +246,8 @@ bool
|
|||||||
ViewLayer::RemoveChild(ViewLayer* layer)
|
ViewLayer::RemoveChild(ViewLayer* layer)
|
||||||
{
|
{
|
||||||
if (layer->fParent != this) {
|
if (layer->fParent != this) {
|
||||||
printf("ViewLayer::RemoveChild(%p - %s) - ViewLayer is not child of this (%p) layer!\n", layer, layer ? layer->Name() : NULL, this);
|
printf("ViewLayer::RemoveChild(%p - %s) - ViewLayer is not child of "
|
||||||
|
"this (%p) layer!\n", layer, layer ? layer->Name() : NULL, this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,36 +337,67 @@ ViewLayer::CollectTokensForChildren(BList* tokenMap) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
bool
|
||||||
|
ViewLayer::MarkAt(DrawingEngine* engine, const BPoint& where, int32 level)
|
||||||
|
{
|
||||||
|
BRect rect(fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
|
||||||
|
|
||||||
|
if (Parent() != NULL) {
|
||||||
|
Parent()->ConvertToScreen(&rect);
|
||||||
|
if (!rect.Contains(where))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
engine->StrokeRect(rect, (rgb_color){level * 30, level * 30, level * 30});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
||||||
|
found |= child->MarkAt(engine, where, level + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
rgb_color color = {0};
|
||||||
|
switch (level % 2) {
|
||||||
|
case 0: color.green = rand() % 256; break;
|
||||||
|
case 1: color.blue = rand() % 256; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rect.InsetBy(1, 1);
|
||||||
|
//engine->FillRegion(fLocalClipping, (rgb_color){255, 255, 0, 10});
|
||||||
|
engine->StrokeRect(rect, color);
|
||||||
|
rect.InsetBy(1, 1);
|
||||||
|
engine->StrokeRect(rect, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ViewLayer*
|
ViewLayer*
|
||||||
ViewLayer::ViewAt(const BPoint& where, BRegion* windowContentClipping)
|
ViewLayer::ViewAt(const BPoint& where)
|
||||||
{
|
{
|
||||||
if (!fVisible)
|
if (!fVisible)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// NOTE: if this view can draw on children, it's screen clipping
|
IntRect frame = Frame();
|
||||||
// excludes these children, so we need to ask those first if they
|
if (Parent() != NULL)
|
||||||
// contain "where", otherwise we check the screen clipping before
|
Parent()->ConvertToScreen(&frame);
|
||||||
// recursing into the children
|
|
||||||
|
|
||||||
if (!(fFlags & B_DRAW_ON_CHILDREN)) {
|
if (!frame.Contains(where))
|
||||||
if (ScreenClipping(windowContentClipping).Contains(where))
|
return NULL;
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
||||||
ViewLayer* layer = child->ViewAt(where, windowContentClipping);
|
ViewLayer* layer = child->ViewAt(where);
|
||||||
if (layer)
|
if (layer != NULL)
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fFlags & B_DRAW_ON_CHILDREN) {
|
|
||||||
if (ScreenClipping(windowContentClipping).Contains(where))
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
@@ -1418,8 +1452,7 @@ ViewLayer::MarkBackgroundDirty()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewLayer::AddTokensForLayersInRegion(BMessage* message,
|
ViewLayer::AddTokensForLayersInRegion(BMessage* message, BRegion& region,
|
||||||
BRegion& region,
|
|
||||||
BRegion* windowContentClipping)
|
BRegion* windowContentClipping)
|
||||||
{
|
{
|
||||||
if (!fVisible)
|
if (!fVisible)
|
||||||
@@ -1428,15 +1461,15 @@ ViewLayer::AddTokensForLayersInRegion(BMessage* message,
|
|||||||
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
||||||
message->AddInt32("_token", fToken);
|
message->AddInt32("_token", fToken);
|
||||||
|
|
||||||
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
||||||
child->AddTokensForLayersInRegion(message, region,
|
child->AddTokensForLayersInRegion(message, region,
|
||||||
windowContentClipping);
|
windowContentClipping);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewLayer::AddTokensForLayersInRegion(BPrivate::PortLink& link,
|
ViewLayer::AddTokensForLayersInRegion(BPrivate::PortLink& link, BRegion& region,
|
||||||
BRegion& region,
|
|
||||||
BRegion* windowContentClipping)
|
BRegion* windowContentClipping)
|
||||||
{
|
{
|
||||||
if (!fVisible)
|
if (!fVisible)
|
||||||
@@ -1450,9 +1483,9 @@ ViewLayer::AddTokensForLayersInRegion(BPrivate::PortLink& link,
|
|||||||
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
||||||
link.Attach<int32>(fToken);
|
link.Attach<int32>(fToken);
|
||||||
|
|
||||||
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
||||||
child->AddTokensForLayersInRegion(link, region,
|
child->AddTokensForLayersInRegion(link, region, windowContentClipping);
|
||||||
windowContentClipping);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1541,8 +1574,8 @@ ViewLayer::ScreenClipping(BRegion* windowContentClipping, bool force) const
|
|||||||
// the parent, the local clipping does not account for this
|
// the parent, the local clipping does not account for this
|
||||||
IntRect clippedBounds = Bounds();
|
IntRect clippedBounds = Bounds();
|
||||||
ConvertToVisibleInTopView(&clippedBounds);
|
ConvertToVisibleInTopView(&clippedBounds);
|
||||||
if (clippedBounds.Width() < fScreenClipping.Frame().Width() ||
|
if (clippedBounds.Width() < fScreenClipping.Frame().Width()
|
||||||
clippedBounds.Height() < fScreenClipping.Frame().Height()) {
|
|| clippedBounds.Height() < fScreenClipping.Frame().Height()) {
|
||||||
BRegion* temp = fWindow->GetRegion();
|
BRegion* temp = fWindow->GetRegion();
|
||||||
if (temp) {
|
if (temp) {
|
||||||
temp->Set((clipping_rect)clippedBounds);
|
temp->Set((clipping_rect)clippedBounds);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007, Haiku, Inc.
|
* Copyright (c) 2001-2008, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -101,8 +101,7 @@ class ViewLayer {
|
|||||||
uint32 CountChildren(bool deep = false) const;
|
uint32 CountChildren(bool deep = false) const;
|
||||||
void CollectTokensForChildren(BList* tokenMap) const;
|
void CollectTokensForChildren(BList* tokenMap) const;
|
||||||
|
|
||||||
ViewLayer* ViewAt(const BPoint& where,
|
ViewLayer* ViewAt(const BPoint& where);
|
||||||
BRegion* windowContentClipping);
|
|
||||||
|
|
||||||
// coordinate conversion
|
// coordinate conversion
|
||||||
void ConvertToParent(BPoint* point) const;
|
void ConvertToParent(BPoint* point) const;
|
||||||
@@ -232,6 +231,10 @@ class ViewLayer {
|
|||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
void PrintToStream() const;
|
void PrintToStream() const;
|
||||||
|
#if 0
|
||||||
|
bool MarkAt(DrawingEngine* engine, const BPoint& where,
|
||||||
|
int32 level = 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _MoveScreenClipping(int32 x, int32 y,
|
void _MoveScreenClipping(int32 x, int32 y,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007, Haiku, Inc.
|
* Copyright (c) 2001-2008, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -508,14 +508,7 @@ WindowLayer::SetTopLayer(ViewLayer* topLayer)
|
|||||||
ViewLayer*
|
ViewLayer*
|
||||||
WindowLayer::ViewAt(const BPoint& where)
|
WindowLayer::ViewAt(const BPoint& where)
|
||||||
{
|
{
|
||||||
ViewLayer* view = NULL;
|
return fTopLayer->ViewAt(where);
|
||||||
|
|
||||||
if (!fContentRegionValid)
|
|
||||||
_UpdateContentRegion();
|
|
||||||
|
|
||||||
view = fTopLayer->ViewAt(where, &fContentRegion);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -930,6 +923,17 @@ void
|
|||||||
WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
||||||
bool isLatestMouseMoved)
|
bool isLatestMouseMoved)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
if (fDecorator != NULL && fTopLayer != NULL) {
|
||||||
|
DrawingEngine* engine = fDecorator->GetDrawingEngine();
|
||||||
|
engine->LockParallelAccess();
|
||||||
|
engine->ConstrainClippingRegion(&VisibleRegion());
|
||||||
|
|
||||||
|
fTopLayer->MarkAt(engine, where);
|
||||||
|
engine->UnlockParallelAccess();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ViewLayer* view = ViewAt(where);
|
ViewLayer* view = ViewAt(where);
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
*_viewToken = view->Token();
|
*_viewToken = view->Token();
|
||||||
|
|||||||
Reference in New Issue
Block a user