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

View File

@ -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
WindowArea::_AddWindow(SATWindow* window, SATWindow* after)
{

View File

@ -136,6 +136,7 @@ public:
const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
bool MoveWindowToPosition(SATWindow* window,
int32 index);
void UpdateSizeLimits();
Crossing* LeftTopCrossing()
{ return fLeftTopCrossing.Get(); }

View File

@ -87,8 +87,10 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
ResultType result;
for (int32 tries = 0; tries < 15; tries++) {
result = fSATGroup->GetLinearSpec()->Solve();
if (result == INFEASIBLE)
if (result == INFEASIBLE) {
debug_printf("can't solve constraints!\n");
break;
}
if (result == OPTIMAL) {
fSATGroup->AdjustWindows(triggerWindow);
break;
@ -130,7 +132,7 @@ GroupCookie::MoveWindow(int32 workspace)
void
GroupCookie::SetSizeLimit(int32 minWidth, int32 maxWidth, int32 minHeight,
GroupCookie::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight)
{
fMinWidthConstraint->SetRightSide(minWidth);
@ -375,9 +377,7 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
return false;
}
int32 minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
area->UpdateSizeLimits();
return true;
}
@ -485,11 +485,10 @@ SATWindow::DoGroupLayout()
void
SATWindow::SizeLimitChanged(int32 minWidth, int32 maxWidth, int32 minHeight,
SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight)
{
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
fGroupCookie->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
}

View File

@ -32,7 +32,7 @@ public:
void DoGroupLayout(SATWindow* triggerWindow);
void MoveWindow(int32 workspace);
void SetSizeLimit(int32 minWidth, int32 maxWidth,
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
SATGroup* GetGroup() { return fSATGroup.Get(); }
@ -105,7 +105,7 @@ public:
void DoWindowLayout();
void DoGroupLayout();
void SizeLimitChanged(int32 minWidth, int32 maxWidth,
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
//! \return the complete window frame including the Decorator

View File

@ -291,14 +291,16 @@ StackAndTile::WindowTabLocationChanged(Window* window, float location)
void
StackAndTile::SizeLimitChanged(Window* window, int32 minWidth, int32 maxWidth,
StackAndTile::SizeLimitsChanged(Window* window, int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight)
{
SATWindow* satWindow = GetSATWindow(window);
if (!satWindow)
return;
satWindow->SizeLimitChanged(minWidth, maxWidth, minHeight, maxHeight);
WindowArea* area = satWindow->GetWindowArea();
if (!area)
return;
area->UpdateSizeLimits();
}

View File

@ -73,9 +73,9 @@ public:
virtual void WindowTabLocationChanged(Window* window,
float location);
virtual void SizeLimitChanged(Window* window, int32 minWidth,
int32 maxWidth, int32 minHeight,
int32 maxHeight);
virtual void SizeLimitsChanged(Window* window,
int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
virtual bool SetDecoratorSettings(Window* window,
const BMessage& settings);