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:
@@ -18,6 +18,8 @@
|
||||
WindowArea::WindowArea(Crossing* leftTop, Crossing* rightTop,
|
||||
Crossing* leftBottom, Crossing* rightBottom)
|
||||
:
|
||||
fGroup(NULL),
|
||||
|
||||
fLeftTopCrossing(leftTop),
|
||||
fRightTopCrossing(rightTop),
|
||||
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()
|
||||
{
|
||||
_CleanupCorners();
|
||||
SetGroup(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -613,6 +630,11 @@ SATGroup::AddWindow(SATWindow* window, Tab* left, Tab* top, Tab* right,
|
||||
leftBottomRef, rightBottomRef);
|
||||
if (!area)
|
||||
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
|
||||
BReference<WindowArea> areaRef(area, true);
|
||||
|
||||
@@ -649,8 +671,9 @@ SATGroup::RemoveWindow(SATWindow* window)
|
||||
|
||||
_SplitGroupIfNecessary(window);
|
||||
|
||||
if (window->GetWindowArea())
|
||||
window->GetWindowArea()->_RemoveWindow(window);
|
||||
WindowArea* area = window->GetWindowArea();
|
||||
if (area)
|
||||
area->_RemoveWindow(window);
|
||||
|
||||
for (int i = 0; i < CountItems(); i++)
|
||||
WindowAt(i)->DoGroupLayout();
|
||||
|
||||
@@ -130,6 +130,8 @@ public:
|
||||
Crossing* rightBottom);
|
||||
~WindowArea();
|
||||
|
||||
bool SetGroup(SATGroup* group);
|
||||
|
||||
const SATWindowList& WindowList() { return fWindowList; }
|
||||
bool MoveWindowToPosition(SATWindow* window,
|
||||
int32 index);
|
||||
@@ -174,6 +176,8 @@ private:
|
||||
BReference<Crossing> _CrossingByPosition(Crossing* crossing,
|
||||
SATGroup* group);
|
||||
|
||||
SATGroup* fGroup;
|
||||
|
||||
SATWindowList fWindowList;
|
||||
|
||||
BReference<Crossing> fLeftTopCrossing;
|
||||
@@ -252,6 +256,7 @@ private:
|
||||
BRect& screen);
|
||||
|
||||
protected:
|
||||
WindowAreaList fWindowAreaList;
|
||||
SATWindowList fSATWindowList;
|
||||
|
||||
LinearSpec fLinearSpec;
|
||||
|
||||
@@ -162,7 +162,7 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
||||
fRightBorder, OperatorType(LE), -minWidth);
|
||||
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0,
|
||||
fBottomBorder, OperatorType(LE), -minHeight);
|
||||
|
||||
|
||||
// The width and height constraints have higher penalties than the
|
||||
// position constraints (left, top), so a window will keep its size
|
||||
// unless explicitly resized.
|
||||
@@ -179,7 +179,7 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
||||
Uninit();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
fLeftBorderConstraint = area->LeftTab()->Connect(fLeftBorder);
|
||||
fTopBorderConstraint = area->TopTab()->Connect(fTopBorder);
|
||||
fRightBorderConstraint = area->RightTab()->Connect(fRightBorder);
|
||||
@@ -244,7 +244,7 @@ GroupCookie::PropagateToGroup(SATGroup* group, WindowArea* area)
|
||||
if (!Init(group, area))
|
||||
return false;
|
||||
|
||||
if (!group->fSATWindowList.AddItem(fSATWindow)) {
|
||||
if (!area->SetGroup(group) || !group->fSATWindowList.AddItem(fSATWindow)) {
|
||||
Uninit();
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user