Added Layer::Push/PopState() and moved their implementation from ServerWindow.cpp. We definitely need more encapsulation
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13043 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b00025db9c
commit
e1bc5f2def
@ -69,46 +69,46 @@ enum {
|
||||
|
||||
Layer::Layer(BRect frame, const char* name, int32 token,
|
||||
uint32 resize, uint32 flags, DisplayDriver* driver)
|
||||
: fFrame(frame), // in parent coordinates
|
||||
// fBoundsLeftTop(0.0, 0.0),
|
||||
:
|
||||
fFrame(frame), // in parent coordinates
|
||||
// fBoundsLeftTop(0.0, 0.0),
|
||||
|
||||
// Layer does not start out as a part of the tree
|
||||
fOwner (NULL),
|
||||
fParent (NULL),
|
||||
fUpperSibling (NULL),
|
||||
fLowerSibling (NULL),
|
||||
fTopChild (NULL),
|
||||
fBottomChild (NULL),
|
||||
// Layer does not start out as a part of the tree
|
||||
fOwner(NULL),
|
||||
fParent(NULL),
|
||||
fUpperSibling(NULL),
|
||||
fLowerSibling(NULL),
|
||||
fTopChild(NULL),
|
||||
fBottomChild(NULL),
|
||||
fCurrent(NULL),
|
||||
|
||||
fCurrent (NULL),
|
||||
// all regions (fVisible, fFullVisible, fFull) start empty
|
||||
fVisible(),
|
||||
fFullVisible(),
|
||||
fFull(),
|
||||
|
||||
// all regions (fVisible, fFullVisible, fFull) start empty
|
||||
fVisible (),
|
||||
fFullVisible (),
|
||||
fFull (),
|
||||
fClipReg(&fVisible),
|
||||
|
||||
fServerWin(NULL),
|
||||
fName(new BString(name)),
|
||||
fViewToken(token),
|
||||
|
||||
fClipReg (&fVisible),
|
||||
fFlags(flags),
|
||||
fResizeMode(resize),
|
||||
fEventMask(0UL),
|
||||
fEventOptions(0UL),
|
||||
fHidden(false),
|
||||
fIsTopLayer(false),
|
||||
|
||||
fServerWin (NULL),
|
||||
fName (new BString(name ? name : B_EMPTY_STRING)),
|
||||
fViewToken (token),
|
||||
fAdFlags(0),
|
||||
fClassID(AS_LAYER_CLASS),
|
||||
|
||||
fFlags (flags),
|
||||
fResizeMode (resize),
|
||||
fEventMask (0UL),
|
||||
fEventOptions (0UL),
|
||||
fHidden (false),
|
||||
fIsTopLayer (false),
|
||||
fFrameAction(B_LAYER_ACTION_NONE),
|
||||
|
||||
fAdFlags (0),
|
||||
fClassID (AS_LAYER_CLASS),
|
||||
fDriver(driver),
|
||||
fLayerData(new LayerData()),
|
||||
|
||||
fFrameAction (B_LAYER_ACTION_NONE),
|
||||
|
||||
fDriver (driver),
|
||||
fLayerData (new LayerData()),
|
||||
|
||||
fRootLayer (NULL)
|
||||
fRootLayer(NULL)
|
||||
{
|
||||
if (!frame.IsValid()) {
|
||||
char helper[1024];
|
||||
@ -847,15 +847,15 @@ Layer::Redraw(const BRegion& reg, Layer *startFrom)
|
||||
|
||||
// Draw
|
||||
void
|
||||
Layer::Draw(const BRect &r)
|
||||
Layer::Draw(const BRect &rect)
|
||||
{
|
||||
#ifdef DEBUG_LAYER
|
||||
printf("Layer(%s)::Draw: ", GetName());
|
||||
r.PrintToStream();
|
||||
rect.PrintToStream();
|
||||
#endif
|
||||
|
||||
if (!fLayerData->ViewColor().IsTransparentMagic())
|
||||
fDriver->FillRect(r, fLayerData->ViewColor());
|
||||
fDriver->FillRect(rect, fLayerData->ViewColor());
|
||||
}
|
||||
|
||||
// EmptyGlobals
|
||||
@ -928,6 +928,31 @@ Layer::IsHidden(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Layer::PushState()
|
||||
{
|
||||
LayerData *data = new LayerData();
|
||||
data->prevState = fLayerData;
|
||||
fLayerData = data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Layer::PopState()
|
||||
{
|
||||
if (fLayerData->prevState == NULL) {
|
||||
fprintf(stderr, "WARNING: User called BView(%s)::PopState(), but there is NO state on stack!\n", fName->String());
|
||||
return;
|
||||
}
|
||||
|
||||
LayerData *data = fLayerData;
|
||||
fLayerData = fLayerData->prevState;
|
||||
data->prevState = NULL;
|
||||
delete data;
|
||||
}
|
||||
|
||||
|
||||
//! Matches the BView call of the same name
|
||||
BRect
|
||||
Layer::Bounds(void) const
|
||||
|
@ -117,7 +117,11 @@ class Layer {
|
||||
void Show(bool invalidate = true);
|
||||
void Hide(bool invalidate = true);
|
||||
bool IsHidden() const;
|
||||
|
||||
|
||||
// graphic state
|
||||
void PushState();
|
||||
void PopState();
|
||||
|
||||
// coordinate system
|
||||
BRect Bounds() const;
|
||||
BRect Frame() const;
|
||||
|
@ -697,11 +697,8 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
case AS_LAYER_PUSH_STATE:
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
||||
// TODO: refactor, put this in Layer
|
||||
LayerData *ld = new LayerData();
|
||||
ld->prevState = fCurrentLayer->fLayerData;
|
||||
fCurrentLayer->fLayerData = ld;
|
||||
|
||||
fCurrentLayer->PushState();
|
||||
fCurrentLayer->RebuildFullRegion();
|
||||
|
||||
break;
|
||||
@ -709,17 +706,8 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
case AS_LAYER_POP_STATE:
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
||||
if (!(fCurrentLayer->fLayerData->prevState))
|
||||
{
|
||||
DTRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fName, fCurrentLayer->fName->String()));
|
||||
break;
|
||||
}
|
||||
// TODO: refactor, put this in Layer
|
||||
LayerData *ld = fCurrentLayer->fLayerData;
|
||||
fCurrentLayer->fLayerData = fCurrentLayer->fLayerData->prevState;
|
||||
ld->prevState = NULL;
|
||||
delete ld;
|
||||
|
||||
fCurrentLayer->PopState();
|
||||
fCurrentLayer->RebuildFullRegion();
|
||||
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user