Layer::Show/Hide now works. Improved some invalidating calls. fixed some potential problems
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -88,16 +88,13 @@ Layer::Layer(BRect frame, const char* name, int32 token,
|
|||||||
fFullVisible(),
|
fFullVisible(),
|
||||||
fFull(),
|
fFull(),
|
||||||
fFrameAction(B_LAYER_ACTION_NONE),
|
fFrameAction(B_LAYER_ACTION_NONE),
|
||||||
|
fClipReg(&fVisible),
|
||||||
#else
|
#else
|
||||||
fVisible2(),
|
fVisible2(),
|
||||||
fFullVisible2(),
|
fFullVisible2(),
|
||||||
|
fClipReg(&fVisible2),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NEW_CLIPPING
|
|
||||||
fClipReg(&fVisible),
|
|
||||||
#else
|
|
||||||
fClipReg(&fVisible2),
|
|
||||||
#endif
|
|
||||||
fServerWin(NULL),
|
fServerWin(NULL),
|
||||||
fName(name),
|
fName(name),
|
||||||
fViewToken(token),
|
fViewToken(token),
|
||||||
@@ -927,16 +924,23 @@ Layer::Show(bool invalidate)
|
|||||||
|
|
||||||
fHidden = false;
|
fHidden = false;
|
||||||
|
|
||||||
|
SendViewCoordUpdateMsg();
|
||||||
|
|
||||||
// NOTE: I added this here and it solves the invalid region problem
|
// NOTE: I added this here and it solves the invalid region problem
|
||||||
// for Windows that have been resized before they were shown. -Stephan
|
// for Windows that have been resized before they were shown. -Stephan
|
||||||
#ifndef NEW_CLIPPING
|
#ifndef NEW_CLIPPING
|
||||||
RebuildFullRegion();
|
RebuildFullRegion();
|
||||||
SendViewCoordUpdateMsg();
|
|
||||||
|
|
||||||
if (invalidate)
|
if (invalidate)
|
||||||
GetRootLayer()->GoInvalidate(this, fFull);
|
GetRootLayer()->GoInvalidate(this, fFull);
|
||||||
#else
|
#else
|
||||||
|
if (invalidate) {
|
||||||
|
// compute the region this layer wants for itself
|
||||||
|
BRegion invalidRegion;
|
||||||
|
get_user_regions(invalidRegion);
|
||||||
|
if (invalidRegion.CountRects() > 0)
|
||||||
|
GetRootLayer()->GoInvalidate(this, invalidRegion);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,6 +963,10 @@ Layer::Hide(bool invalidate)
|
|||||||
#ifndef NEW_CLIPPING
|
#ifndef NEW_CLIPPING
|
||||||
if (invalidate)
|
if (invalidate)
|
||||||
GetRootLayer()->GoInvalidate(this, fFullVisible);
|
GetRootLayer()->GoInvalidate(this, fFullVisible);
|
||||||
|
#else
|
||||||
|
if (invalidate && fFullVisible2.CountRects() > 0) {
|
||||||
|
GetRootLayer()->GoInvalidate(this, fFullVisible2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1654,6 +1662,14 @@ Layer::SetOverlayBitmap(const ServerBitmap* bitmap)
|
|||||||
|
|
||||||
#ifdef NEW_CLIPPING
|
#ifdef NEW_CLIPPING
|
||||||
|
|
||||||
|
void
|
||||||
|
Layer::GetWantedRegion(BRegion& reg) const
|
||||||
|
{
|
||||||
|
// this is the same as get_user_region.
|
||||||
|
// because get_user_region modifies nothing.
|
||||||
|
const_cast<Layer*>(this)->Layer::get_user_regions(reg);
|
||||||
|
}
|
||||||
|
|
||||||
//! converts a point from local to parent's coordinate system
|
//! converts a point from local to parent's coordinate system
|
||||||
void
|
void
|
||||||
Layer::ConvertToParent2(BPoint* pt) const
|
Layer::ConvertToParent2(BPoint* pt) const
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#include "RGBColor.h"
|
#include "RGBColor.h"
|
||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
|
|
||||||
//#define NEW_CLIPPING 1
|
#define NEW_CLIPPING 1
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
B_LAYER_NONE = 1,
|
B_LAYER_NONE = 1,
|
||||||
@@ -212,6 +212,8 @@ class Layer {
|
|||||||
inline const BRegion& VisibleRegion() const { return fVisible2; }
|
inline const BRegion& VisibleRegion() const { return fVisible2; }
|
||||||
inline const BRegion& FullVisible() const { return fFullVisible2; }
|
inline const BRegion& FullVisible() const { return fFullVisible2; }
|
||||||
|
|
||||||
|
virtual void GetWantedRegion(BRegion& reg) const;
|
||||||
|
|
||||||
virtual void MovedByHook(float dx, float dy) { }
|
virtual void MovedByHook(float dx, float dy) { }
|
||||||
virtual void ResizedByHook(float dx, float dy, bool automatic) { }
|
virtual void ResizedByHook(float dx, float dy, bool automatic) { }
|
||||||
virtual void ScrolledByHook(float dx, float dy) { }
|
virtual void ScrolledByHook(float dx, float dy) { }
|
||||||
|
|||||||
@@ -514,11 +514,15 @@ myRootLayer->Lock();
|
|||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
parent->AddChild(newLayer, this);
|
parent->AddChild(newLayer, this);
|
||||||
|
|
||||||
if (!newLayer->IsHidden())
|
if (!newLayer->IsHidden() && parent)
|
||||||
#ifndef NEW_CLIPPING
|
#ifndef NEW_CLIPPING
|
||||||
myRootLayer->GoInvalidate(newLayer, newLayer->fFull);
|
myRootLayer->GoInvalidate(newLayer, newLayer->fFull);
|
||||||
#else
|
#else
|
||||||
myRootLayer->GoInvalidate(newLayer, newLayer->Frame());
|
{
|
||||||
|
BRegion invalidRegion;
|
||||||
|
newLayer->GetWantedRegion(invalidRegion);
|
||||||
|
myRootLayer->GoInvalidate(newLayer, invalidRegion);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
myRootLayer->Unlock();
|
myRootLayer->Unlock();
|
||||||
@@ -532,16 +536,28 @@ myRootLayer->Unlock();
|
|||||||
// area assuming that the view was visible when removed
|
// area assuming that the view was visible when removed
|
||||||
|
|
||||||
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fTitle));
|
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fTitle));
|
||||||
Layer *parent;
|
myRootLayer->Lock();
|
||||||
parent = fCurrentLayer->fParent;
|
Layer *parent = fCurrentLayer->fParent;
|
||||||
|
BRegion *invalidRegion = NULL;
|
||||||
|
|
||||||
|
if (!fCurrentLayer->IsHidden() && parent) {
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
|
if (fCurrentLayer->fFullVisible.CountRects() > 0)
|
||||||
|
invalidRegion = new BRegion(fCurrentLayer->fFullVisible);
|
||||||
|
#else
|
||||||
|
if (fCurrentLayer->FullVisible().Frame().IsValid())
|
||||||
|
invalidRegion = new BRegion(fCurrentLayer->FullVisible());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// here we remove current layer from list.
|
// here we remove current layer from list.
|
||||||
myRootLayer->Lock();
|
|
||||||
fCurrentLayer->RemoveSelf();
|
fCurrentLayer->RemoveSelf();
|
||||||
fCurrentLayer->PruneTree();
|
fCurrentLayer->PruneTree();
|
||||||
|
|
||||||
if (parent)
|
if (invalidRegion) {
|
||||||
myRootLayer->GoInvalidate(parent, BRegion(fCurrentLayer->Frame()));
|
myRootLayer->GoInvalidate(parent, *invalidRegion);
|
||||||
|
delete invalidRegion;
|
||||||
|
}
|
||||||
myRootLayer->Unlock();
|
myRootLayer->Unlock();
|
||||||
|
|
||||||
#ifdef DEBUG_SERVERWINDOW
|
#ifdef DEBUG_SERVERWINDOW
|
||||||
@@ -827,13 +843,15 @@ myRootLayer->Unlock();
|
|||||||
rgb_color c;
|
rgb_color c;
|
||||||
|
|
||||||
link.Read(&c, sizeof(rgb_color));
|
link.Read(&c, sizeof(rgb_color));
|
||||||
|
myRootLayer->Lock();
|
||||||
fCurrentLayer->SetViewColor(RGBColor(c));
|
fCurrentLayer->SetViewColor(RGBColor(c));
|
||||||
|
|
||||||
// TODO: this should not trigger redraw, no?!?
|
|
||||||
#ifndef NEW_CLIPPING
|
#ifndef NEW_CLIPPING
|
||||||
myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->fVisible);
|
myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->fVisible);
|
||||||
|
#else
|
||||||
|
myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->VisibleRegion());
|
||||||
#endif
|
#endif
|
||||||
|
myRootLayer->Unlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_LAYER_GET_COLORS:
|
case AS_LAYER_GET_COLORS:
|
||||||
@@ -940,7 +958,11 @@ myRootLayer->Unlock();
|
|||||||
#ifndef NEW_CLIPPING
|
#ifndef NEW_CLIPPING
|
||||||
myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull);
|
myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull);
|
||||||
#else
|
#else
|
||||||
myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->Frame());
|
{
|
||||||
|
BRegion invalidRegion;
|
||||||
|
fCurrentLayer->GetWantedRegion(invalidRegion);
|
||||||
|
myRootLayer->GoInvalidate(fCurrentLayer, invalidRegion);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user