Calculate a better size limit in a stacking group.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2010-09-17 05:46:13 +00:00
parent dcbc4af5d1
commit d256161aec
6 changed files with 43 additions and 16 deletions
@@ -68,6 +68,31 @@ WindowArea::MoveWindowToPosition(SATWindow* window, int32 index)
} }
void
WindowArea::UpdateSizeLimits()
{
int32 minWidth, maxWidth, minHeight, maxHeight;
minWidth = minHeight = 1;
maxWidth = maxHeight = 1;
for (int i = 0; i < fWindowList.CountItems(); i++) {
int32 minW, maxW, minH, maxH;
fWindowList.ItemAt(i)->GetSizeLimits(&minW, &maxW, &minH, &maxH);
if (minW > minWidth)
minWidth = minW;
if (maxW > maxWidth)
maxWidth = maxW;
if (minH > minHeight)
minHeight = minH;
if (maxH > maxHeight)
maxHeight = maxH;
}
for (int i = 0; i < fWindowList.CountItems(); i++)
fWindowList.ItemAt(i)->SetSizeLimits(minWidth, maxWidth, minHeight,
maxHeight);
}
bool bool
WindowArea::_AddWindow(SATWindow* window, SATWindow* after) WindowArea::_AddWindow(SATWindow* window, SATWindow* after)
{ {
@@ -136,6 +136,7 @@ public:
const SATWindowList& LayerOrder() { return fWindowLayerOrder; } const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
bool MoveWindowToPosition(SATWindow* window, bool MoveWindowToPosition(SATWindow* window,
int32 index); int32 index);
void UpdateSizeLimits();
Crossing* LeftTopCrossing() Crossing* LeftTopCrossing()
{ return fLeftTopCrossing.Get(); } { return fLeftTopCrossing.Get(); }
@@ -87,8 +87,10 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
ResultType result; ResultType result;
for (int32 tries = 0; tries < 15; tries++) { for (int32 tries = 0; tries < 15; tries++) {
result = fSATGroup->GetLinearSpec()->Solve(); result = fSATGroup->GetLinearSpec()->Solve();
if (result == INFEASIBLE) if (result == INFEASIBLE) {
debug_printf("can't solve constraints!\n");
break; break;
}
if (result == OPTIMAL) { if (result == OPTIMAL) {
fSATGroup->AdjustWindows(triggerWindow); fSATGroup->AdjustWindows(triggerWindow);
break; break;
@@ -130,7 +132,7 @@ GroupCookie::MoveWindow(int32 workspace)
void void
GroupCookie::SetSizeLimit(int32 minWidth, int32 maxWidth, int32 minHeight, GroupCookie::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight) int32 maxHeight)
{ {
fMinWidthConstraint->SetRightSide(minWidth); fMinWidthConstraint->SetRightSide(minWidth);
@@ -375,9 +377,7 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
return false; return false;
} }
int32 minWidth, maxWidth, minHeight, maxHeight; area->UpdateSizeLimits();
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
return true; return true;
} }
@@ -485,11 +485,10 @@ SATWindow::DoGroupLayout()
void void
SATWindow::SizeLimitChanged(int32 minWidth, int32 maxWidth, int32 minHeight, SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight) int32 maxHeight)
{ {
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); fGroupCookie->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
} }
@@ -32,7 +32,7 @@ public:
void DoGroupLayout(SATWindow* triggerWindow); void DoGroupLayout(SATWindow* triggerWindow);
void MoveWindow(int32 workspace); void MoveWindow(int32 workspace);
void SetSizeLimit(int32 minWidth, int32 maxWidth, void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight); int32 minHeight, int32 maxHeight);
SATGroup* GetGroup() { return fSATGroup.Get(); } SATGroup* GetGroup() { return fSATGroup.Get(); }
@@ -105,7 +105,7 @@ public:
void DoWindowLayout(); void DoWindowLayout();
void DoGroupLayout(); void DoGroupLayout();
void SizeLimitChanged(int32 minWidth, int32 maxWidth, void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight); int32 minHeight, int32 maxHeight);
//! \return the complete window frame including the Decorator //! \return the complete window frame including the Decorator
@@ -291,14 +291,16 @@ StackAndTile::WindowTabLocationChanged(Window* window, float location)
void void
StackAndTile::SizeLimitChanged(Window* window, int32 minWidth, int32 maxWidth, StackAndTile::SizeLimitsChanged(Window* window, int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight) int32 minHeight, int32 maxHeight)
{ {
SATWindow* satWindow = GetSATWindow(window); SATWindow* satWindow = GetSATWindow(window);
if (!satWindow) if (!satWindow)
return; return;
WindowArea* area = satWindow->GetWindowArea();
satWindow->SizeLimitChanged(minWidth, maxWidth, minHeight, maxHeight); if (!area)
return;
area->UpdateSizeLimits();
} }
@@ -73,9 +73,9 @@ public:
virtual void WindowTabLocationChanged(Window* window, virtual void WindowTabLocationChanged(Window* window,
float location); float location);
virtual void SizeLimitChanged(Window* window, int32 minWidth, virtual void SizeLimitsChanged(Window* window,
int32 maxWidth, int32 minHeight, int32 minWidth, int32 maxWidth,
int32 maxHeight); int32 minHeight, int32 maxHeight);
virtual bool SetDecoratorSettings(Window* window, virtual bool SetDecoratorSettings(Window* window,
const BMessage& settings); const BMessage& settings);