Also manage a list of all areas in a group.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38516 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2010-09-03 00:34:54 +00:00
parent d4bbf5c221
commit 7fe05355e3
3 changed files with 33 additions and 5 deletions
@@ -18,6 +18,8 @@
WindowArea::WindowArea(Crossing* leftTop, Crossing* rightTop, WindowArea::WindowArea(Crossing* leftTop, Crossing* rightTop,
Crossing* leftBottom, Crossing* rightBottom) Crossing* leftBottom, Crossing* rightBottom)
: :
fGroup(NULL),
fLeftTopCrossing(leftTop), fLeftTopCrossing(leftTop),
fRightTopCrossing(rightTop), fRightTopCrossing(rightTop),
fLeftBottomCrossing(leftBottom), fLeftBottomCrossing(leftBottom),
@@ -27,9 +29,24 @@ WindowArea::WindowArea(Crossing* leftTop, Crossing* rightTop,
} }
bool
WindowArea::SetGroup(SATGroup* group)
{
if (group && !group->fWindowAreaList.AddItem(this))
return false;
if (fGroup)
fGroup->fWindowAreaList.RemoveItem(this);
fGroup = group;
return true;
}
WindowArea::~WindowArea() WindowArea::~WindowArea()
{ {
_CleanupCorners(); _CleanupCorners();
SetGroup(NULL);
} }
@@ -613,6 +630,11 @@ SATGroup::AddWindow(SATWindow* window, Tab* left, Tab* top, Tab* right,
leftBottomRef, rightBottomRef); leftBottomRef, rightBottomRef);
if (!area) if (!area)
return false; return false;
// the area register itself in our area list
if (!area->SetGroup(this)) {
delete area;
return false;
}
// delete the area if AddWindow failed / release our reference on it // delete the area if AddWindow failed / release our reference on it
BReference<WindowArea> areaRef(area, true); BReference<WindowArea> areaRef(area, true);
@@ -649,8 +671,9 @@ SATGroup::RemoveWindow(SATWindow* window)
_SplitGroupIfNecessary(window); _SplitGroupIfNecessary(window);
if (window->GetWindowArea()) WindowArea* area = window->GetWindowArea();
window->GetWindowArea()->_RemoveWindow(window); if (area)
area->_RemoveWindow(window);
for (int i = 0; i < CountItems(); i++) for (int i = 0; i < CountItems(); i++)
WindowAt(i)->DoGroupLayout(); WindowAt(i)->DoGroupLayout();
@@ -130,6 +130,8 @@ public:
Crossing* rightBottom); Crossing* rightBottom);
~WindowArea(); ~WindowArea();
bool SetGroup(SATGroup* group);
const SATWindowList& WindowList() { return fWindowList; } const SATWindowList& WindowList() { return fWindowList; }
bool MoveWindowToPosition(SATWindow* window, bool MoveWindowToPosition(SATWindow* window,
int32 index); int32 index);
@@ -174,6 +176,8 @@ private:
BReference<Crossing> _CrossingByPosition(Crossing* crossing, BReference<Crossing> _CrossingByPosition(Crossing* crossing,
SATGroup* group); SATGroup* group);
SATGroup* fGroup;
SATWindowList fWindowList; SATWindowList fWindowList;
BReference<Crossing> fLeftTopCrossing; BReference<Crossing> fLeftTopCrossing;
@@ -252,6 +256,7 @@ private:
BRect& screen); BRect& screen);
protected: protected:
WindowAreaList fWindowAreaList;
SATWindowList fSATWindowList; SATWindowList fSATWindowList;
LinearSpec fLinearSpec; LinearSpec fLinearSpec;
@@ -162,7 +162,7 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
fRightBorder, OperatorType(LE), -minWidth); fRightBorder, OperatorType(LE), -minWidth);
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0, fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0,
fBottomBorder, OperatorType(LE), -minHeight); fBottomBorder, OperatorType(LE), -minHeight);
// The width and height constraints have higher penalties than the // The width and height constraints have higher penalties than the
// position constraints (left, top), so a window will keep its size // position constraints (left, top), so a window will keep its size
// unless explicitly resized. // unless explicitly resized.
@@ -179,7 +179,7 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
Uninit(); Uninit();
return false; return false;
} }
fLeftBorderConstraint = area->LeftTab()->Connect(fLeftBorder); fLeftBorderConstraint = area->LeftTab()->Connect(fLeftBorder);
fTopBorderConstraint = area->TopTab()->Connect(fTopBorder); fTopBorderConstraint = area->TopTab()->Connect(fTopBorder);
fRightBorderConstraint = area->RightTab()->Connect(fRightBorder); fRightBorderConstraint = area->RightTab()->Connect(fRightBorder);
@@ -244,7 +244,7 @@ GroupCookie::PropagateToGroup(SATGroup* group, WindowArea* area)
if (!Init(group, area)) if (!Init(group, area))
return false; return false;
if (!group->fSATWindowList.AddItem(fSATWindow)) { if (!area->SetGroup(group) || !group->fSATWindowList.AddItem(fSATWindow)) {
Uninit(); Uninit();
return false; return false;
} }