*** empty log message ***
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8000 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+181
-303
@@ -14,7 +14,7 @@
|
||||
#include "LayerData.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//#define DEBUG_LAYER
|
||||
#define DEBUG_LAYER
|
||||
#ifdef DEBUG_LAYER
|
||||
# define STRACE(x) printf x
|
||||
#else
|
||||
@@ -32,15 +32,6 @@ BRegion gRedrawReg;
|
||||
BList gCopyRegList;
|
||||
BList gCopyList;
|
||||
|
||||
enum
|
||||
{
|
||||
B_LAYER_NONE = 0x00001000UL,
|
||||
B_LAYER_MOVE = 0x00002000UL,
|
||||
B_LAYER_SIMPLE_MOVE = 0x00004000UL,
|
||||
B_LAYER_RESIZE = 0x00008000UL,
|
||||
B_LAYER_MASK_RESIZE = 0x00010000UL,
|
||||
};
|
||||
|
||||
Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
||||
uint32 flags, DisplayDriver *driver)
|
||||
{
|
||||
@@ -62,24 +53,25 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
||||
fDriver = driver;
|
||||
|
||||
// Layer does not start out as a part of the tree
|
||||
fParent = NULL;
|
||||
fUpperSibling = NULL;
|
||||
fLowerSibling = NULL;
|
||||
fTopChild = NULL;
|
||||
fBottomChild = NULL;
|
||||
fParent = NULL;
|
||||
fUpperSibling = NULL;
|
||||
fLowerSibling = NULL;
|
||||
fTopChild = NULL;
|
||||
fBottomChild = NULL;
|
||||
|
||||
fCurrent = NULL;
|
||||
fRootLayer = NULL;
|
||||
fCurrent = NULL;
|
||||
fRootLayer = NULL;
|
||||
|
||||
fFlags = flags;
|
||||
fResizeMode = resize;
|
||||
fHidden = false;
|
||||
fFlags = flags;
|
||||
fAdFlags = 0;
|
||||
fResizeMode = resize;
|
||||
fHidden = false;
|
||||
|
||||
fIsUpdating = false;
|
||||
fIsTopLayer = false;
|
||||
fLevel = 0;
|
||||
fIsUpdating = false;
|
||||
fIsTopLayer = false;
|
||||
fLevel = 0;
|
||||
|
||||
fViewToken = token;
|
||||
fViewToken = token;
|
||||
fServerWin = NULL;
|
||||
clipToPicture = NULL;
|
||||
|
||||
@@ -117,7 +109,7 @@ Layer::~Layer(void)
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
|
||||
void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
||||
{
|
||||
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
|
||||
|
||||
@@ -127,7 +119,7 @@ void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
|
||||
return;
|
||||
}
|
||||
|
||||
// attach layer to the tree structure
|
||||
// 1) attach layer to the tree structure
|
||||
layer->fParent = this;
|
||||
if( fBottomChild )
|
||||
{
|
||||
@@ -140,66 +132,49 @@ void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
|
||||
}
|
||||
fBottomChild = layer;
|
||||
|
||||
layer->SetRootLayer(fRootLayer);
|
||||
// if no RootLayer, there is no need to set any parameters.
|
||||
// they will be set when the root Layer for this tree will be added
|
||||
// to the main tree structure.
|
||||
if (fRootLayer == NULL)
|
||||
return;
|
||||
|
||||
// higher level objects like RootLayers do not have ServerWindow objects attached
|
||||
// This is in case o a WinBorder object which already has a valid fServerWin member.
|
||||
if(!(layer->fServerWin))
|
||||
layer->SetServerWindow(this->SearchForServerWindow());
|
||||
|
||||
layer->RebuildFullRegion();
|
||||
|
||||
//c = short for: current
|
||||
Layer *c = layer->fTopChild;
|
||||
Layer *stop = layer;
|
||||
|
||||
if( c != NULL )
|
||||
{
|
||||
while( true )
|
||||
// 2) set some fields for this new layer and its children.
|
||||
Layer *c = layer; //c = short for: current
|
||||
Layer *stop = layer;
|
||||
while( true ){
|
||||
// action block
|
||||
{
|
||||
// action block
|
||||
{
|
||||
c->SetRootLayer(fRootLayer);
|
||||
c->SetServerWindow(c->SearchForServerWindow());
|
||||
c->RebuildFullRegion();
|
||||
// 2.1) set the RootLayer for this object.
|
||||
c->SetRootLayer(c->fParent->fRootLayer);
|
||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||
c->SetServerWindow(serverWin);//c->fParent->fServerWin);
|
||||
// 2.3) we are attached to the main tree so build our full region.
|
||||
c->RebuildFullRegion();
|
||||
}
|
||||
|
||||
// tree parsing algorithm
|
||||
if( c->fTopChild ){ // go deep
|
||||
c = c->fTopChild;
|
||||
}
|
||||
else{ // go right or up
|
||||
if (c == stop) // out trip is over
|
||||
break;
|
||||
if( c->fLowerSibling ){ // go right
|
||||
c = c->fLowerSibling;
|
||||
}
|
||||
|
||||
// tree parsing algorithm
|
||||
|
||||
// go deep
|
||||
if( c->fTopChild )
|
||||
{
|
||||
c = c->fTopChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go right or up
|
||||
|
||||
if( c->fLowerSibling )
|
||||
{
|
||||
// go right
|
||||
c = c->fLowerSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go up
|
||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||
c = c->fParent;
|
||||
|
||||
// that enough! We've reached this view.
|
||||
if( c->fParent == stop )
|
||||
break;
|
||||
|
||||
c = c->fParent->fLowerSibling;
|
||||
}
|
||||
else{ // go up
|
||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||
c = c->fParent;
|
||||
|
||||
if( c->fParent == stop ) // that enough!
|
||||
break;
|
||||
|
||||
c = c->fParent->fLowerSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !(layer->IsHidden()) && layer->fRootLayer && !IsHidden())
|
||||
FullInvalidate( layer->fFull );
|
||||
|
||||
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
||||
|
||||
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
||||
}
|
||||
|
||||
void Layer::RemoveChild(Layer *layer)
|
||||
@@ -218,87 +193,63 @@ void Layer::RemoveChild(Layer *layer)
|
||||
return;
|
||||
}
|
||||
|
||||
// 1) remove this layer the main tree.
|
||||
// Take care of fParent
|
||||
layer->fParent = NULL;
|
||||
layer->fParent = NULL;
|
||||
if( fTopChild == layer )
|
||||
fTopChild = layer->fLowerSibling;
|
||||
|
||||
fTopChild = layer->fLowerSibling;
|
||||
if( fBottomChild == layer )
|
||||
fBottomChild = layer->fUpperSibling;
|
||||
fBottomChild = layer->fUpperSibling;
|
||||
|
||||
// Take care of siblings
|
||||
if( layer->fUpperSibling != NULL )
|
||||
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling;
|
||||
|
||||
if( layer->fLowerSibling != NULL )
|
||||
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling;
|
||||
|
||||
layer->fUpperSibling = NULL;
|
||||
layer->fLowerSibling = NULL;
|
||||
|
||||
//c = short for: current
|
||||
Layer *c = layer->fTopChild;
|
||||
Layer *stop = layer;
|
||||
layer->fUpperSibling = NULL;
|
||||
layer->fLowerSibling = NULL;
|
||||
|
||||
if( c != NULL )
|
||||
{
|
||||
while( true )
|
||||
// 2) clear some fields for this layer and its children.
|
||||
Layer *c = layer; //c = short for: current
|
||||
Layer *stop = layer;
|
||||
while( true ){
|
||||
// action block
|
||||
{
|
||||
// action block
|
||||
{
|
||||
c->SetRootLayer(NULL);
|
||||
c->SetServerWindow(NULL);
|
||||
c->fFull.MakeEmpty();
|
||||
c->fFullVisible.MakeEmpty();
|
||||
c->fVisible.MakeEmpty();
|
||||
}
|
||||
// 2.1) set the RootLayer for this object.
|
||||
c->SetRootLayer(NULL);
|
||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||
c->SetServerWindow(NULL);
|
||||
// 2.3) we were removed from the main tree so clear our full region.
|
||||
c->fFull.MakeEmpty();
|
||||
// 2.4) clear fullVisible region.
|
||||
c->fFullVisible.MakeEmpty();
|
||||
// 2.5) we don't have a visible region anymore.
|
||||
c->fVisible.MakeEmpty();
|
||||
}
|
||||
|
||||
// tree parsing algorithm
|
||||
|
||||
if( c->fTopChild )
|
||||
{
|
||||
// go deep
|
||||
c = c->fTopChild;
|
||||
// tree parsing algorithm
|
||||
if( c->fTopChild ){ // go deep
|
||||
c = c->fTopChild;
|
||||
}
|
||||
else{ // go right or up
|
||||
if (c == stop) // out trip is over
|
||||
break;
|
||||
|
||||
if( c->fLowerSibling ){ // go right
|
||||
c = c->fLowerSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go right or up
|
||||
|
||||
if( c->fLowerSibling )
|
||||
{
|
||||
// go right
|
||||
c = c->fLowerSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go up
|
||||
|
||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||
c = c->fParent;
|
||||
|
||||
// that's enough! We've reached this view.
|
||||
if( c->fParent == stop )
|
||||
break;
|
||||
|
||||
c = c->fParent->fLowerSibling;
|
||||
}
|
||||
else{ // go up
|
||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||
c = c->fParent;
|
||||
|
||||
if( c->fParent == stop ) // that enough!
|
||||
break;
|
||||
|
||||
c = c->fParent->fLowerSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !(layer->IsHidden()) && layer->fRootLayer)
|
||||
{
|
||||
PrintTree();
|
||||
FullInvalidate( layer->fFullVisible );
|
||||
}
|
||||
|
||||
layer->fRootLayer = NULL;
|
||||
layer->fServerWin = NULL;
|
||||
layer->fFull.MakeEmpty();
|
||||
layer->fFullVisible.MakeEmpty();
|
||||
layer->fVisible.MakeEmpty();
|
||||
|
||||
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
|
||||
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
|
||||
}
|
||||
|
||||
void Layer::RemoveSelf()
|
||||
@@ -455,113 +406,69 @@ void Layer::Invalidate(const BRegion& region)
|
||||
void Layer::Redraw(const BRegion& reg, Layer *startFrom)
|
||||
{
|
||||
STRACE(("Layer(%s)::Redraw();\n", GetName()));
|
||||
|
||||
if (IsHidden())
|
||||
// this layer has nothing visible on screen, so bail out.
|
||||
return;
|
||||
|
||||
BRegion *pReg = const_cast<BRegion*>(®);
|
||||
|
||||
if(fServerWin)
|
||||
{
|
||||
if (pReg->CountRects() > 0)
|
||||
RequestClientUpdate(reg, startFrom);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// call Draw() for all server layers
|
||||
if (pReg->CountRects() > 0)
|
||||
RequestDraw(reg, startFrom);
|
||||
|
||||
}
|
||||
if (pReg->CountRects() > 0)
|
||||
RequestDraw(reg, startFrom);
|
||||
|
||||
STRACE(("Layer::Redraw ENDED\n"));
|
||||
}
|
||||
|
||||
void Layer::RequestClientUpdate(const BRegion ®, Layer *startFrom)
|
||||
void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
||||
{
|
||||
STRACE(("Layer(%s)::RequestClientUpdate()\n", GetName()));
|
||||
|
||||
if (IsHidden())
|
||||
{
|
||||
// this layer has nothing visible on screen, so bail out.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
|
||||
|
||||
int redraw = false;
|
||||
|
||||
if (startFrom == NULL)
|
||||
redraw = true;
|
||||
|
||||
if (fVisible.CountRects() > 0)
|
||||
{
|
||||
fUpdateReg = fVisible;
|
||||
fUpdateReg.IntersectWith(®);
|
||||
|
||||
// NOTE: CLEAR to the background color!
|
||||
|
||||
// draw itself.
|
||||
if (fUpdateReg.CountRects() > 0)
|
||||
{
|
||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
||||
Draw(fUpdateReg.Frame());
|
||||
fDriver->ConstrainClippingRegion(NULL);
|
||||
}
|
||||
|
||||
fUpdateReg.MakeEmpty();
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
// TODO: use startFrom
|
||||
|
||||
// TODO: Do that! here? or after a message sent by the client just before calling BView::Draw(r)
|
||||
// clear the area in the low color
|
||||
// only the visible area is cleared, because DisplayDriver does the clipping to it.
|
||||
// draw background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
|
||||
|
||||
BMessage msg;
|
||||
|
||||
msg.what = _UPDATE_;
|
||||
msg.AddInt32("_token", fViewToken);
|
||||
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
||||
|
||||
// for test purposes only!
|
||||
msg.AddRect("_rect2", reg.Frame());
|
||||
if (fUpdateReg.CountRects() > 0){
|
||||
if (fServerWin){
|
||||
// clear background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
|
||||
// TODO: DO That!
|
||||
// TODO: UNcomment!!!
|
||||
// TODO !!! UPDATE code !!!
|
||||
/*
|
||||
BMessage msg;
|
||||
msg.what = _UPDATE_;
|
||||
msg.AddInt32("_token", fViewToken);
|
||||
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
||||
|
||||
fServerWin->SendMessageToClient( &msg );
|
||||
}
|
||||
// for test purposes only!
|
||||
msg.AddRect("_rect2", reg.Frame());
|
||||
|
||||
void Layer::RequestDraw(const BRegion ®, Layer *startFrom, bool redraw)
|
||||
{
|
||||
STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
|
||||
|
||||
if (fVisible.CountRects() > 0 && !IsHidden())
|
||||
{
|
||||
fUpdateReg = fVisible;
|
||||
fUpdateReg.IntersectWith(®);
|
||||
|
||||
// NOTE: do not clear background for internal server layers!
|
||||
|
||||
// draw itself.
|
||||
if (fUpdateReg.CountRects() > 0)
|
||||
{
|
||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
||||
Draw(fUpdateReg.Frame());
|
||||
fDriver->ConstrainClippingRegion(NULL);
|
||||
}
|
||||
|
||||
fUpdateReg.MakeEmpty();
|
||||
}
|
||||
fServerWin->SendMessageToClient( &msg );
|
||||
*/
|
||||
}
|
||||
else{
|
||||
// NOTE: do not clear background for internal server layers!
|
||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
||||
Draw(fUpdateReg.Frame());
|
||||
fDriver->ConstrainClippingRegion(NULL);
|
||||
|
||||
// tell children to draw. YES, it's OK - if we're hidden don't tell children to draw
|
||||
if (!IsHidden())
|
||||
{
|
||||
for (Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
|
||||
{
|
||||
if (!redraw && startFrom && lay == startFrom)
|
||||
redraw = true;
|
||||
|
||||
if ((startFrom && redraw) || !startFrom)
|
||||
{
|
||||
if ( !(lay->IsHidden()) )
|
||||
lay->RequestDraw( reg, startFrom, redraw );
|
||||
fUpdateReg.MakeEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
|
||||
{
|
||||
if (lay == startFrom)
|
||||
redraw = true;
|
||||
|
||||
if (redraw && !(lay->IsHidden()))
|
||||
lay->RequestDraw(reg, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::Draw(const BRect &r)
|
||||
@@ -590,9 +497,9 @@ void Layer::Show(bool invalidate)
|
||||
if(invalidate)
|
||||
{
|
||||
if(fParent)
|
||||
fParent->FullInvalidate(fFull);
|
||||
fParent->FullInvalidate( BRegion(fFull) );
|
||||
else
|
||||
FullInvalidate( fFull );
|
||||
FullInvalidate( BRegion(fFull) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,60 +511,13 @@ void Layer::Hide(bool invalidate)
|
||||
|
||||
fHidden = true;
|
||||
|
||||
//c = short for: current
|
||||
Layer *c = fTopChild;
|
||||
Layer *stop = this;
|
||||
|
||||
if( c != NULL )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
// action block
|
||||
{
|
||||
c->fFullVisible.MakeEmpty();
|
||||
c->fVisible.MakeEmpty();
|
||||
}
|
||||
|
||||
// tree parsing algorithm
|
||||
|
||||
if( c->fTopChild )
|
||||
{
|
||||
// go deep
|
||||
c = c->fTopChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go right or up
|
||||
if( c->fLowerSibling )
|
||||
{
|
||||
// go right
|
||||
c = c->fLowerSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
// go up
|
||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||
c = c->fParent;
|
||||
|
||||
// that's enough! We've reached this view.
|
||||
if( c->fParent == stop )
|
||||
break;
|
||||
|
||||
c = c->fParent->fLowerSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(invalidate)
|
||||
{
|
||||
if(fParent)
|
||||
fParent->FullInvalidate( fFullVisible );
|
||||
fParent->FullInvalidate( BRegion(fFullVisible) );
|
||||
else
|
||||
FullInvalidate( fFullVisible );
|
||||
FullInvalidate( BRegion(fFullVisible) );
|
||||
}
|
||||
fFullVisible.MakeEmpty();
|
||||
fVisible.MakeEmpty();
|
||||
}
|
||||
|
||||
bool Layer::IsHidden(void) const
|
||||
@@ -694,6 +554,7 @@ void Layer::RebuildFullRegion( )
|
||||
else
|
||||
fFull.Set( fFrame );
|
||||
|
||||
// TODO: restrict to screen coordinates!!!
|
||||
// TODO: Convert to screen coordinates!
|
||||
LayerData *ld;
|
||||
ld = fLayerData;
|
||||
@@ -712,15 +573,6 @@ void Layer::RebuildFullRegion( )
|
||||
else
|
||||
fFull.IntersectWith( clipToPicture );
|
||||
}
|
||||
|
||||
if(IsTopLayer() && fServerWin)
|
||||
{
|
||||
if (fServerWin->fWinBorder->fDecorator)
|
||||
{
|
||||
// decorator overlapping topLayer? put decorator in front.
|
||||
fFull.Exclude( fServerWin->fWinBorder->fDecFull );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset)
|
||||
@@ -840,14 +692,39 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint
|
||||
|
||||
if (!IsHidden())
|
||||
{
|
||||
fFullVisible.MakeEmpty();
|
||||
fVisible = fFull;
|
||||
if (fParent)
|
||||
{
|
||||
fVisible.IntersectWith( &(fParent->fVisible) );
|
||||
|
||||
// exclude from parent's visible area.
|
||||
if ( !IsHidden() && fVisible.CountRects() > 0)
|
||||
fParent->fVisible.Exclude( &(fVisible) );
|
||||
if (fParent && fVisible.CountRects() >0){
|
||||
// not the usual case, but support fot this is needed.
|
||||
if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT){
|
||||
// because we're skipping one level, we need to do out
|
||||
// parent business as well.
|
||||
|
||||
// our visible area is relative to our parent's parent.
|
||||
if (fParent->fParent)
|
||||
fVisible.IntersectWith(&(fParent->fParent->fVisible));
|
||||
|
||||
// exclude parent's visible area which could be composed by
|
||||
// prior siblings' visible areas.
|
||||
if (fVisible.CountRects() > 0)
|
||||
fVisible.Exclude(&(fParent->fVisible));
|
||||
|
||||
// we have a final visible area. Include it to our parent's one,
|
||||
// exclude from parent's parent.
|
||||
if (fVisible.CountRects() > 0){
|
||||
fParent->fFullVisible.Include(&fVisible);
|
||||
if (fParent->fParent)
|
||||
fParent->fParent->fVisible.Exclude(&fVisible);
|
||||
}
|
||||
}
|
||||
// for 95+% of cases
|
||||
else{
|
||||
// the visible area is the one common with parent's one.
|
||||
fVisible.IntersectWith(&(fParent->fVisible));
|
||||
// exclude from parent's visible area. we're the owners now.
|
||||
if (fVisible.CountRects() > 0)
|
||||
fParent->fVisible.Exclude(&fVisible);
|
||||
}
|
||||
}
|
||||
fFullVisible = fVisible;
|
||||
}
|
||||
@@ -1001,8 +878,9 @@ void Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 actio
|
||||
// if this is the first time
|
||||
if (oldVisible.CountRects() > 0)
|
||||
redrawReg.Exclude(&oldVisible);
|
||||
|
||||
gRedrawReg.Include(&redrawReg);
|
||||
|
||||
if (redrawReg.CountRects() > 0)
|
||||
gRedrawReg.Include(&redrawReg);
|
||||
|
||||
#ifdef DEBUG_LAYER_REBUILD
|
||||
printf("Layer(%s)::StartRebuildREgions() ended! Redraw Region:\n", GetName());
|
||||
|
||||
@@ -10,6 +10,17 @@
|
||||
#include <Locker.h>
|
||||
#include "RGBColor.h"
|
||||
|
||||
enum
|
||||
{
|
||||
B_LAYER_NONE = 0x00001000UL,
|
||||
B_LAYER_MOVE = 0x00002000UL,
|
||||
B_LAYER_SIMPLE_MOVE = 0x00004000UL,
|
||||
B_LAYER_RESIZE = 0x00008000UL,
|
||||
B_LAYER_MASK_RESIZE = 0x00010000UL,
|
||||
|
||||
B_LAYER_CHILDREN_DEPENDANT = 0x10000000UL,
|
||||
};
|
||||
|
||||
class ServerWindow;
|
||||
class RootLayer;
|
||||
class DisplayDriver;
|
||||
@@ -22,7 +33,7 @@ public:
|
||||
uint32 flags, DisplayDriver *driver);
|
||||
virtual ~Layer(void);
|
||||
|
||||
void AddChild(Layer *child, RootLayer *rootLayer = NULL);
|
||||
void AddChild(Layer *child, ServerWindow *serverWin);
|
||||
void RemoveChild(Layer *child);
|
||||
void RemoveSelf(void);
|
||||
bool HasChild(Layer *layer);
|
||||
@@ -78,7 +89,8 @@ public:
|
||||
BRect ConvertFromTop(BRect rect);
|
||||
|
||||
DisplayDriver *GetDisplayDriver(void) const { return fDriver; }
|
||||
|
||||
ServerWindow *Window(void) const { return fServerWin; }
|
||||
|
||||
void PruneTree(void);
|
||||
|
||||
void PrintToStream(void);
|
||||
@@ -126,6 +138,7 @@ protected:
|
||||
bool fHidden;
|
||||
bool fIsUpdating;
|
||||
bool fIsTopLayer;
|
||||
uint16 fAdFlags;
|
||||
|
||||
DisplayDriver *fDriver;
|
||||
LayerData *fLayerData;
|
||||
@@ -134,8 +147,7 @@ protected:
|
||||
RootLayer *fRootLayer;
|
||||
|
||||
private:
|
||||
void RequestClientUpdate(const BRegion ®, Layer *startFrom);
|
||||
void RequestDraw(const BRegion ®, Layer *startFrom, bool redraw=false);
|
||||
void RequestDraw(const BRegion ®, Layer *startFrom);
|
||||
ServerWindow *SearchForServerWindow(void) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -217,21 +217,22 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
STRACE(("*RootLayer::AddWinBorder(%s) - General lock acquired\n", winBorder->GetName()));
|
||||
fMainLock.Lock();
|
||||
|
||||
|
||||
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName()));
|
||||
|
||||
|
||||
// in case we want to be added to the current workspace
|
||||
if (winBorder->Window()->Workspaces() == 0)
|
||||
winBorder->Window()->QuietlySetWorkspaces(0x00000001 << (ActiveWorkspaceIndex()-1));
|
||||
|
||||
|
||||
// add winBorder to the known list of WinBorders so we can keep track of it.
|
||||
AddChild(winBorder, this);
|
||||
|
||||
AddChild(winBorder, winBorder->Window());
|
||||
|
||||
// add winBorder to the desired workspaces
|
||||
switch(winBorder->Window()->Feel())
|
||||
{
|
||||
case B_MODAL_SUBSET_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 21\n");
|
||||
// this kind of window isn't added anywhere. It will be added
|
||||
// to main window's subset when winBorder::AddToSubsetOf(main)
|
||||
// will be called.
|
||||
@@ -239,6 +240,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
}
|
||||
case B_MODAL_APP_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 22\n");
|
||||
// add to app's list of Floating/Modal windows (as opposed to the system's)
|
||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
||||
|
||||
@@ -267,6 +269,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
case B_MODAL_ALL_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 23\n");
|
||||
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
|
||||
fMainFMWList.AddItem(winBorder);
|
||||
|
||||
@@ -277,6 +280,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 24\n");
|
||||
// this kind of window isn't added anywhere. It *will* be added to WS's list
|
||||
// when its main window will become the front one.
|
||||
// Also, it will be added to MainWinBorder's list when
|
||||
@@ -286,6 +290,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
case B_FLOATING_APP_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 25\n");
|
||||
// add to app's list of Floating/Modal windows (as opposed to the system's)
|
||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
||||
|
||||
@@ -304,6 +309,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
case B_FLOATING_ALL_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 26\n");
|
||||
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
|
||||
fMainFMWList.AddItem(winBorder);
|
||||
|
||||
@@ -314,6 +320,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
|
||||
case B_NORMAL_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 27\n");
|
||||
// add this winBorder to the specified workspaces
|
||||
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
|
||||
break;
|
||||
@@ -321,14 +328,17 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
case B_SYSTEM_LAST:
|
||||
case B_SYSTEM_FIRST:
|
||||
{
|
||||
printf("XXXXXXXX1: 28\n");
|
||||
// add this winBorder to all workspaces
|
||||
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default:{
|
||||
printf("XXXXXXXX1: 29\n");
|
||||
break;
|
||||
}
|
||||
} // end switch(winborder->Feel())
|
||||
|
||||
printf("XXXXXXXX1: 4\n");
|
||||
fMainLock.Unlock();
|
||||
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "CursorManager.h"
|
||||
#include "Workspace.h"
|
||||
|
||||
//#define DEBUG_SERVERWINDOW
|
||||
#define DEBUG_SERVERWINDOW
|
||||
//#define DEBUG_SERVERWINDOW_MOUSE
|
||||
//#define DEBUG_SERVERWINDOW_KEYBOARD
|
||||
|
||||
@@ -174,9 +174,6 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
||||
fTopLayer->SetAsTopLayer(true);
|
||||
cl = fTopLayer;
|
||||
|
||||
fWinBorder = new WinBorder( fFrame, fTitle.String(),wlook, wfeel, wflags,
|
||||
this, desktop->GetDisplayDriver());
|
||||
|
||||
STRACE(("ServerWindow %s:\n",fTitle.String()));
|
||||
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
|
||||
STRACE(("\tPort: %ld\n",fMessagePort));
|
||||
@@ -185,7 +182,12 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
||||
|
||||
void ServerWindow::Init(void)
|
||||
{
|
||||
fWinBorder->AddChild(fTopLayer);
|
||||
fWinBorder = new WinBorder( fFrame, fTitle.String(), fLook, fFeel, fFlags,
|
||||
this, desktop->GetDisplayDriver());
|
||||
fWinBorder->RebuildFullRegion();
|
||||
|
||||
// connect decorator and top layer.
|
||||
fWinBorder->AddChild(fTopLayer, NULL);
|
||||
|
||||
// NOTE: this MUST be before the monitor thread is spawned!
|
||||
desktop->AddWinBorder(fWinBorder);
|
||||
@@ -632,7 +634,7 @@ void ServerWindow::SetLayerFontState(Layer *layer)
|
||||
layer->fLayerData->font.SetFlags(flags);
|
||||
}
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",
|
||||
fTitle.String(), layer->_name->String()));
|
||||
fTitle.String(), layer->fName->String()));
|
||||
}
|
||||
|
||||
void ServerWindow::SetLayerState(Layer *layer)
|
||||
@@ -687,7 +689,7 @@ void ServerWindow::SetLayerState(Layer *layer)
|
||||
}
|
||||
}
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(),
|
||||
layer->_name->String()));
|
||||
layer->fName->String()));
|
||||
}
|
||||
|
||||
Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
|
||||
@@ -736,7 +738,7 @@ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
|
||||
|
||||
// add the new Layer to the tree structure.
|
||||
if(localRoot)
|
||||
localRoot->AddChild(newLayer);
|
||||
localRoot->AddChild(newLayer, NULL);
|
||||
|
||||
// attach newLayer's children...
|
||||
for(int i = 0; i < childCount; i++)
|
||||
@@ -748,7 +750,7 @@ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
|
||||
debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n");
|
||||
}
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(),
|
||||
newLayer->_name->String(), name));
|
||||
localRoot? localRoot->fName->String(): "NULL", newLayer->fName->String()));
|
||||
|
||||
return newLayer;
|
||||
}
|
||||
@@ -854,6 +856,7 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
}
|
||||
case AS_SET_CURRENT_LAYER:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
int32 token;
|
||||
|
||||
fSession->ReadInt32(&token);
|
||||
@@ -864,13 +867,21 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
cl=current;
|
||||
else // hope this NEVER happens! :-)
|
||||
debugger("Server PANIC: window cannot find Layer with ID\n");
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_CREATE:
|
||||
{
|
||||
CreateLayerTree(cl);
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
Layer *newLayer;
|
||||
|
||||
newLayer = CreateLayerTree(NULL);
|
||||
cl->AddChild(newLayer, this);
|
||||
|
||||
if (!(newLayer->IsHidden())){
|
||||
// cl is the parent of newLayer, so this call is OK.
|
||||
cl->FullInvalidate(newLayer->fFull.Frame());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_DELETE:
|
||||
@@ -888,11 +899,10 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
cl->RemoveSelf();
|
||||
|
||||
// TODO: invalidate the region occupied by this view.
|
||||
// Should be done in Layer::RemoveChild() though
|
||||
cl->PruneTree();
|
||||
|
||||
parent->PrintTree();
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->_name->String(), cl->_name->String()));
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->fName->String(), cl->fName->String()));
|
||||
|
||||
delete cl;
|
||||
|
||||
@@ -901,18 +911,21 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
}
|
||||
case AS_LAYER_SET_STATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
SetLayerState(cl);
|
||||
cl->RebuildFullRegion();
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_FONT_STATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
SetLayerFontState(cl);
|
||||
cl->RebuildFullRegion();
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_STATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
LayerData *ld;
|
||||
|
||||
// these 4 are here because of a compiler warning. Maybe he's right... :-)
|
||||
@@ -965,12 +978,11 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
fSession->WriteFloat(cl->fFrame.top);
|
||||
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_MOVETO:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
float x, y;
|
||||
|
||||
fSession->ReadFloat(&x);
|
||||
@@ -982,6 +994,7 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
}
|
||||
case AS_LAYER_RESIZETO:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
|
||||
float newWidth, newHeight;
|
||||
|
||||
fSession->ReadFloat(&newWidth);
|
||||
@@ -996,75 +1009,73 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
}
|
||||
case AS_LAYER_GET_COORD:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WriteFloat(cl->fFrame.left);
|
||||
fSession->WriteFloat(cl->fFrame.top);
|
||||
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_ORIGIN:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
float x, y;
|
||||
|
||||
fSession->ReadFloat(&x);
|
||||
fSession->ReadFloat(&y);
|
||||
|
||||
cl->fLayerData->coordOrigin.Set(x, y);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_ORIGIN:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WritePoint(cl->fLayerData->coordOrigin);
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_RESIZE_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->ReadUInt32(&(cl->fResizeMode));
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_CURSOR:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
int32 token;
|
||||
|
||||
|
||||
fSession->ReadInt32(&token);
|
||||
|
||||
cursormanager->SetCursor(token);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_FLAGS:
|
||||
{
|
||||
fSession->ReadUInt32(&(cl->fFlags));
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_HIDE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
cl->Hide();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SHOW:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
cl->Show();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_LINE_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
int8 lineCap, lineJoin;
|
||||
|
||||
// TODO: DW: Shouldn't we lock before modifying certain memebers?
|
||||
@@ -1079,35 +1090,35 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
cl->fLayerData->lineCap = (cap_mode)lineCap;
|
||||
cl->fLayerData->lineJoin = (join_mode)lineJoin;
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_LINE_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WriteInt8((int8)(cl->fLayerData->lineCap));
|
||||
fSession->WriteInt8((int8)(cl->fLayerData->lineJoin));
|
||||
fSession->WriteFloat(cl->fLayerData->miterLimit);
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_PUSH_STATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
LayerData *ld = new LayerData();
|
||||
ld->prevState = cl->fLayerData;
|
||||
cl->fLayerData = ld;
|
||||
|
||||
cl->RebuildFullRegion();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_POP_STATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
if (!(cl->fLayerData->prevState))
|
||||
{
|
||||
STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->_name->String()));
|
||||
STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->fName->String()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1116,20 +1127,21 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
delete ld;
|
||||
|
||||
cl->RebuildFullRegion();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_SCALE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->ReadFloat(&(cl->fLayerData->scale));
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_SCALE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
LayerData *ld = cl->fLayerData;
|
||||
|
||||
float scale = ld->scale;
|
||||
|
||||
while((ld = ld->prevState))
|
||||
@@ -1137,12 +1149,12 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
|
||||
fSession->WriteFloat(scale);
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_PEN_LOC:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
float x, y;
|
||||
|
||||
fSession->ReadFloat(&x);
|
||||
@@ -1150,56 +1162,56 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
|
||||
cl->fLayerData->penlocation.Set(x, y);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_PEN_LOC:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WritePoint(cl->fLayerData->penlocation);
|
||||
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_PEN_SIZE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->ReadFloat(&(cl->fLayerData->pensize));
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_PEN_SIZE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WriteFloat(cl->fLayerData->pensize);
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_HIGH_COLOR:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
rgb_color c;
|
||||
|
||||
fSession->ReadData(&c, sizeof(rgb_color));
|
||||
|
||||
cl->fLayerData->highcolor.SetColor(c);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_LOW_COLOR:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
rgb_color c;
|
||||
|
||||
fSession->ReadData(&c, sizeof(rgb_color));
|
||||
|
||||
cl->fLayerData->lowcolor.SetColor(c);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_VIEW_COLOR:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
rgb_color c;
|
||||
|
||||
fSession->ReadData(&c, sizeof(rgb_color));
|
||||
@@ -1208,11 +1220,11 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
|
||||
cl->Invalidate(cl->fVisible);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_COLORS:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
rgb_color highColor, lowColor, viewColor;
|
||||
|
||||
highColor = cl->fLayerData->highcolor.GetColor32();
|
||||
@@ -1223,12 +1235,12 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
fSession->WriteData(&lowColor, sizeof(rgb_color));
|
||||
fSession->WriteData(&viewColor, sizeof(rgb_color));
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_BLEND_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
int8 srcAlpha, alphaFunc;
|
||||
|
||||
fSession->ReadInt8(&srcAlpha);
|
||||
@@ -1237,46 +1249,47 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha;
|
||||
cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc;
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_BLEND_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WriteInt8((int8)(cl->fLayerData->alphaSrcMode));
|
||||
fSession->WriteInt8((int8)(cl->fLayerData->alphaFncMode));
|
||||
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_DRAW_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
int8 drawingMode;
|
||||
|
||||
fSession->ReadInt8(&drawingMode);
|
||||
|
||||
cl->fLayerData->draw_mode = (drawing_mode)drawingMode;
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_DRAW_MODE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->WriteInt8((int8)(cl->fLayerData->draw_mode));
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_PRINT_ALIASING:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
fSession->ReadBool(&(cl->fLayerData->fontAliasing));
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_CLIP_TO_PICTURE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// TODO: watch out for the coordinate system
|
||||
int32 pictureToken;
|
||||
BPoint where;
|
||||
@@ -1346,11 +1359,11 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
if (redraw)
|
||||
cl->Invalidate(reg);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_CLIP_TO_INVERSE_PICTURE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// TODO: watch out for the coordinate system
|
||||
int32 pictureToken;
|
||||
BPoint where;
|
||||
@@ -1385,43 +1398,45 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
cl->RebuildFullRegion();
|
||||
//cl->RequestDraw(cl->clipToPicture->Frame());
|
||||
}
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(),
|
||||
cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_GET_CLIP_REGION:
|
||||
{
|
||||
// TODO: watch out for the coordinate system
|
||||
BRegion reg;
|
||||
LayerData *ld;
|
||||
int32 noOfRects;
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// if this Layer is hidden, it is clear that its visible region is void.
|
||||
if (cl->IsHidden()){
|
||||
fSession->WriteInt32(0L);
|
||||
fSession->Sync();
|
||||
}
|
||||
else{
|
||||
// TODO: watch out for the coordinate system
|
||||
BRegion reg;
|
||||
LayerData *ld;
|
||||
int32 noOfRects;
|
||||
|
||||
ld = cl->fLayerData;
|
||||
reg = cl->ConvertFromParent(&(cl->fVisible));
|
||||
ld = cl->fLayerData;
|
||||
reg = cl->ConvertFromParent(&(cl->fVisible));
|
||||
|
||||
if(ld->clipReg)
|
||||
reg.IntersectWith(ld->clipReg);
|
||||
|
||||
while((ld = ld->prevState))
|
||||
{
|
||||
if(ld->clipReg)
|
||||
reg.IntersectWith(ld->clipReg);
|
||||
}
|
||||
|
||||
noOfRects = reg.CountRects();
|
||||
fSession->WriteInt32(noOfRects);
|
||||
while((ld = ld->prevState))
|
||||
{
|
||||
if(ld->clipReg)
|
||||
reg.IntersectWith(ld->clipReg);
|
||||
}
|
||||
|
||||
noOfRects = reg.CountRects();
|
||||
fSession->WriteInt32(noOfRects);
|
||||
|
||||
for(int i = 0; i < noOfRects; i++)
|
||||
fSession->WriteRect(reg.RectAt(i));
|
||||
|
||||
fSession->Sync();
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
for(int i = 0; i < noOfRects; i++)
|
||||
fSession->WriteRect(reg.RectAt(i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_CLIP_REGION:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// TODO: watch out for the coordinate system
|
||||
int32 noOfRects;
|
||||
BRect r;
|
||||
@@ -1438,28 +1453,33 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
fSession->ReadRect(&r);
|
||||
cl->fLayerData->clipReg->Include(r);
|
||||
}
|
||||
|
||||
|
||||
cl->RebuildFullRegion();
|
||||
// cl->RequestDraw(cl->clipToPicture->Frame());
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
if (!(cl->IsHidden()))
|
||||
{
|
||||
if (cl->fParent)
|
||||
cl->fParent->FullInvalidate(BRegion(cl->fFull));
|
||||
else
|
||||
cl->FullInvalidate(BRegion(cl->fFull));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_INVAL_RECT:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// TODO: watch out for the coordinate system
|
||||
BRect invalRect;
|
||||
|
||||
fSession->ReadRect(&invalRect);
|
||||
|
||||
cl->Invalidate(invalRect);
|
||||
//cl->RequestDraw(invalRect);
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_INVAL_REGION:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||
// TODO: watch out for the coordinate system
|
||||
BRegion invalReg;
|
||||
int32 noOfRects;
|
||||
@@ -1474,9 +1494,7 @@ void ServerWindow::DispatchMessage(int32 code)
|
||||
}
|
||||
|
||||
cl->Invalidate(invalReg);
|
||||
// cl->RequestDraw(invalReg.Frame());
|
||||
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
fKeyModifiers = 0;
|
||||
fMainWinBorder = NULL;
|
||||
fDecorator = NULL;
|
||||
fDecFull = NULL;
|
||||
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
||||
|
||||
fIsMoving = false;
|
||||
fIsResizing = false;
|
||||
@@ -101,16 +101,9 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
|
||||
fLastMousePosition.Set(-1,-1);
|
||||
SetLevel();
|
||||
fNewTopLayerFrame = &(win->fTopLayer->fFrame);
|
||||
|
||||
if (feel!= B_NO_BORDER_WINDOW_LOOK)
|
||||
{
|
||||
fDecorator = new_decorator(r, name, look, feel, flags, fDriver);
|
||||
fDecFull = new BRegion();
|
||||
fDecorator->GetFootprint(fDecFull);
|
||||
}
|
||||
|
||||
fFull.MakeEmpty();
|
||||
|
||||
STRACE(("WinBorder %s:\n",GetName()));
|
||||
STRACE(("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom));
|
||||
@@ -124,49 +117,18 @@ WinBorder::~WinBorder(void)
|
||||
{
|
||||
delete fDecorator;
|
||||
fDecorator = NULL;
|
||||
|
||||
delete fDecFull;
|
||||
fDecFull = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void WinBorder::RebuildFullRegion(void)
|
||||
{
|
||||
STRACE(("WinBorder(%s):~RebuildFullRegion()\n",GetName()));
|
||||
BRegion topLayerFull;
|
||||
Layer *topLayer = fServerWin->fTopLayer;
|
||||
topLayerFull.Set( ConvertToTop(*fNewTopLayerFrame) );
|
||||
fNewTopLayerFrame = &(fServerWin->fTopLayer->fFrame);
|
||||
|
||||
// TODO: Convert to screen coordinates
|
||||
LayerData *ld;
|
||||
ld = topLayer->fLayerData;
|
||||
do
|
||||
{
|
||||
// clip to user region
|
||||
if(ld->clipReg)
|
||||
topLayerFull.IntersectWith( ld->clipReg );
|
||||
|
||||
} while( (ld = ld->prevState) );
|
||||
|
||||
// clip to user picture region
|
||||
if(topLayer->clipToPicture)
|
||||
{
|
||||
if(topLayer->clipToPictureInverse)
|
||||
topLayerFull.Exclude( topLayer->clipToPicture );
|
||||
else
|
||||
topLayerFull.IntersectWith( topLayer->clipToPicture );
|
||||
}
|
||||
|
||||
fFull.MakeEmpty();
|
||||
fFull = topLayerFull;
|
||||
|
||||
// Winborder holds Decorator's full regions. if any...
|
||||
if (fDecorator)
|
||||
{
|
||||
fDecFull->MakeEmpty();
|
||||
fDecorator->GetFootprint(fDecFull);
|
||||
fFull.Include(fDecFull);
|
||||
}
|
||||
fDecorator->GetFootprint(&fFull);
|
||||
}
|
||||
|
||||
void WinBorder::MouseDown(PortMessage *msg)
|
||||
@@ -379,25 +341,20 @@ void WinBorder::HighlightDecorator(const bool &active)
|
||||
void WinBorder::Draw(const BRect &r)
|
||||
{
|
||||
STRACE(("WinBorder(%s)::Draw()\n", GetName()));
|
||||
// if we have a visible region, it is decorator's one.
|
||||
if(fDecorator)
|
||||
{
|
||||
// decorator is allowed to draw in its entire visible region, not just in the update one.
|
||||
fUpdateReg = fVisible;
|
||||
fUpdateReg.IntersectWith(fDecFull);
|
||||
// restrict Decorator drawing to the update region only.
|
||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
||||
|
||||
|
||||
/* fUpdateReg.PrintToStream();
|
||||
/*
|
||||
fUpdateReg.PrintToStream();
|
||||
RGBColor c(128, 56, 98);
|
||||
//fDriver->FillRect(r, c);
|
||||
fDriver->FillRect(fUpdateReg.Frame(), c);
|
||||
snooze(1000000);
|
||||
*/
|
||||
|
||||
// TODO: pass 'r' not as you do now!!! Let Decorator object handle update problems
|
||||
fDecorator->Draw(fUpdateReg.Frame());
|
||||
|
||||
// remove the additional clipping region.
|
||||
fDriver->ConstrainClippingRegion(NULL);
|
||||
}
|
||||
@@ -407,11 +364,8 @@ void WinBorder::MoveBy(float x, float y)
|
||||
{
|
||||
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
||||
if(fDecorator)
|
||||
{
|
||||
fDecorator->MoveBy(x,y);
|
||||
fDecFull->OffsetBy(x,y);
|
||||
}
|
||||
|
||||
// TODO: Repair! :-))
|
||||
Layer::MoveBy(x,y);
|
||||
}
|
||||
|
||||
@@ -420,16 +374,8 @@ void WinBorder::ResizeBy(float x, float y)
|
||||
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
||||
if(fDecorator)
|
||||
fDecorator->ResizeBy(x,y);
|
||||
|
||||
BRect *localRect = new BRect(fServerWin->fTopLayer->fFrame);
|
||||
fNewTopLayerFrame = localRect;
|
||||
|
||||
// force topLayer's frame to resize
|
||||
fNewTopLayerFrame->right += x;
|
||||
fNewTopLayerFrame->bottom += y;
|
||||
|
||||
// TODO: Repair! :-))
|
||||
Layer::ResizeBy(x,y);
|
||||
delete localRect;
|
||||
}
|
||||
|
||||
bool WinBorder::HasPoint(BPoint& pt) const
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
void UpdateFont(void);
|
||||
void UpdateScreen(void);
|
||||
|
||||
ServerWindow *Window(void) const { return fServerWin; }
|
||||
Decorator *GetDecorator(void) const { return fDecorator; }
|
||||
WinBorder *MainWinBorder() const;
|
||||
|
||||
@@ -87,17 +86,12 @@ protected:
|
||||
int32 fKeyModifiers;
|
||||
BPoint fLastMousePosition;
|
||||
|
||||
BRegion *fDecFull;
|
||||
|
||||
WinBorder *fMainWinBorder;
|
||||
bool fIsMoving;
|
||||
bool fIsResizing;
|
||||
bool fIsClosing;
|
||||
bool fIsMinimizing;
|
||||
bool fIsZooming;
|
||||
|
||||
// having a hard time doing resizing. It's not nice, but this helps a bit
|
||||
BRect *fNewTopLayerFrame;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user