* pruned Layer::PruneTree()
* the Layer destructor now deletes all of the layer's children * WinBorder no longer has to delete its top layer, as it's also its child. * minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14919 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4a71b881a9
commit
618c515c4c
@ -113,10 +113,17 @@ Layer::~Layer()
|
||||
{
|
||||
delete fDrawState;
|
||||
|
||||
// TODO: uncomment!
|
||||
//PruneTree();
|
||||
Layer* child = fFirstChild;
|
||||
|
||||
while (child != NULL) {
|
||||
Layer* nextChild = child->fNextSibling;
|
||||
|
||||
delete child;
|
||||
child = nextChild;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Adds a child layer to the current one
|
||||
\param layer a new child layer
|
||||
@ -889,31 +896,7 @@ Layer::Scale() const
|
||||
return CurrentState()->Scale();
|
||||
}
|
||||
|
||||
//! Recursively deletes all children of the calling layer
|
||||
void
|
||||
Layer::PruneTree(void)
|
||||
{
|
||||
|
||||
Layer* child;
|
||||
Layer* nextChild;
|
||||
|
||||
child = fFirstChild;
|
||||
fFirstChild = NULL;
|
||||
|
||||
while (child != NULL) {
|
||||
if (child->fFirstChild != NULL)
|
||||
child->PruneTree();
|
||||
|
||||
nextChild = child->fNextSibling;
|
||||
child->fNextSibling = NULL;
|
||||
|
||||
delete child;
|
||||
child = nextChild;
|
||||
}
|
||||
// Man, this thing is short. Elegant, ain't it? :P
|
||||
}
|
||||
|
||||
// AddToViewsWithInvalidCoords
|
||||
void
|
||||
Layer::AddToViewsWithInvalidCoords() const
|
||||
{
|
||||
@ -925,7 +908,7 @@ Layer::AddToViewsWithInvalidCoords() const
|
||||
}
|
||||
}
|
||||
|
||||
// SendViewCoordUpdateMsg
|
||||
|
||||
void
|
||||
Layer::SendViewCoordUpdateMsg() const
|
||||
{
|
||||
@ -935,14 +918,14 @@ Layer::SendViewCoordUpdateMsg() const
|
||||
}
|
||||
}
|
||||
|
||||
// SetViewColor
|
||||
|
||||
void
|
||||
Layer::SetViewColor(const RGBColor& color)
|
||||
{
|
||||
fViewColor = color;
|
||||
}
|
||||
|
||||
// SetBackgroundBitmap
|
||||
|
||||
void
|
||||
Layer::SetBackgroundBitmap(const ServerBitmap* bitmap)
|
||||
{
|
||||
|
@ -81,6 +81,8 @@ class Layer {
|
||||
void RemoveChild(Layer* child);
|
||||
void RemoveSelf();
|
||||
bool HasChild(Layer* layer);
|
||||
Layer* Parent() const
|
||||
{ return fParent; }
|
||||
|
||||
uint32 CountChildren() const;
|
||||
Layer* FindLayer(const int32 token);
|
||||
@ -210,9 +212,6 @@ class Layer {
|
||||
virtual void Draw(const BRect& r);
|
||||
void _AllRedraw(const BRegion &invalid);
|
||||
|
||||
// others
|
||||
void PruneTree();
|
||||
|
||||
private:
|
||||
friend class RootLayer;
|
||||
friend class WinBorder;
|
||||
|
@ -642,21 +642,19 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
// layer, detach the layer itself, delete it, and invalidate the
|
||||
// area assuming that the view was visible when removed
|
||||
|
||||
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fTitle));
|
||||
|
||||
Layer *parent = fCurrentLayer->fParent;
|
||||
// BRegion *invalidRegion = NULL;
|
||||
|
||||
if (!fCurrentLayer->IsHidden() && parent && myRootLayer) {
|
||||
if (fCurrentLayer->FullVisible().Frame().IsValid()) {
|
||||
parent->MarkForRebuild(fCurrentLayer->FullVisible());
|
||||
myRootLayer->MarkForRedraw(fCurrentLayer->FullVisible());
|
||||
}
|
||||
STRACE(("ServerWindow %s: AS_LAYER_DELETE view: %p, parent: %p\n", fTitle,
|
||||
fCurrentLayer, parent));
|
||||
|
||||
if (!fCurrentLayer->IsHidden() && parent && myRootLayer
|
||||
&& fCurrentLayer->FullVisible().Frame().IsValid()) {
|
||||
parent->MarkForRebuild(fCurrentLayer->FullVisible());
|
||||
myRootLayer->MarkForRedraw(fCurrentLayer->FullVisible());
|
||||
}
|
||||
|
||||
// here we remove current layer from list.
|
||||
fCurrentLayer->RemoveSelf();
|
||||
fCurrentLayer->PruneTree();
|
||||
|
||||
if (parent)
|
||||
parent->TriggerRebuild();
|
||||
@ -665,14 +663,13 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
myRootLayer->LayerRemoved(fCurrentLayer);
|
||||
myRootLayer->TriggerRedraw();
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
parent->PrintTree();
|
||||
#endif
|
||||
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle, parent->Name(), fCurrentLayer->Name()));
|
||||
|
||||
delete fCurrentLayer;
|
||||
// TODO: It is necessary to do this, but I find it very obscure.
|
||||
// TODO: It is necessary to do this, but I find it very obscure.
|
||||
fCurrentLayer = parent;
|
||||
break;
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ WinBorder::~WinBorder()
|
||||
{
|
||||
STRACE(("WinBorder(%s)::~WinBorder()\n", Name()));
|
||||
|
||||
delete fTopLayer;
|
||||
delete fDecorator;
|
||||
}
|
||||
|
||||
|
||||
//! redraws a certain section of the window border
|
||||
void
|
||||
WinBorder::Draw(const BRect &r)
|
||||
@ -161,15 +161,16 @@ WinBorder::Draw(const BRect &r)
|
||||
|
||||
// if we have a visible region, it is decorator's one.
|
||||
if (fDecorator) {
|
||||
WinBorder* wb = GetRootLayer()->Focus();
|
||||
if (wb == this)
|
||||
if (GetRootLayer()->Focus() == this)
|
||||
fDecorator->SetFocus(true);
|
||||
else
|
||||
fDecorator->SetFocus(false);
|
||||
|
||||
fDecorator->Draw(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Moves the winborder with redraw
|
||||
void
|
||||
WinBorder::MoveBy(float x, float y)
|
||||
@ -278,7 +279,7 @@ WinBorder::ResizeBy(float x, float y)
|
||||
Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
||||
}
|
||||
|
||||
// SetName
|
||||
|
||||
void
|
||||
WinBorder::SetName(const char* name)
|
||||
{
|
||||
@ -306,7 +307,7 @@ WinBorder::SetName(const char* name)
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateStart
|
||||
|
||||
void
|
||||
WinBorder::UpdateStart()
|
||||
{
|
||||
@ -488,8 +489,6 @@ WinBorder::MouseDown(const BMessage *msg)
|
||||
GetRootLayer()->SetActive(this, false);
|
||||
} else {
|
||||
GetRootLayer()->SetNotifyLayer(this, B_POINTER_EVENTS, 0UL);
|
||||
|
||||
activateWindow:
|
||||
GetRootLayer()->SetActive(this);
|
||||
}
|
||||
} else if (target != NULL) {
|
||||
@ -632,7 +631,6 @@ WinBorder::Activated(bool active)
|
||||
}
|
||||
|
||||
|
||||
// SetTabLocation
|
||||
void
|
||||
WinBorder::SetTabLocation(float location)
|
||||
{
|
||||
@ -641,7 +639,6 @@ WinBorder::SetTabLocation(float location)
|
||||
}
|
||||
|
||||
|
||||
// TabLocation
|
||||
float
|
||||
WinBorder::TabLocation() const
|
||||
{
|
||||
@ -759,7 +756,7 @@ WinBorder::QuietlySetFeel(int32 feel)
|
||||
}
|
||||
}
|
||||
|
||||
// _ActionFor
|
||||
|
||||
click_type
|
||||
WinBorder::_ActionFor(const BMessage *msg) const
|
||||
{
|
||||
@ -773,8 +770,8 @@ WinBorder::_ActionFor(const BMessage *msg) const
|
||||
|
||||
if (fDecorator)
|
||||
return fDecorator->Clicked(where, buttons, modifiers);
|
||||
else
|
||||
return DEC_NONE;
|
||||
|
||||
return DEC_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user