From d256161aece4f50a6cb369c1192561323afceb35 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Fri, 17 Sep 2010 05:46:13 +0000 Subject: [PATCH] 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 --- .../decorators/SATDecorator/SATGroup.cpp | 25 +++++++++++++++++++ .../decorators/SATDecorator/SATGroup.h | 1 + .../decorators/SATDecorator/SATWindow.cpp | 15 ++++++----- .../decorators/SATDecorator/SATWindow.h | 4 +-- .../decorators/SATDecorator/StackAndTile.cpp | 8 +++--- .../decorators/SATDecorator/StackAndTile.h | 6 ++--- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/SATGroup.cpp b/src/add-ons/decorators/SATDecorator/SATGroup.cpp index d29e157f14..a1e5cdc69f 100644 --- a/src/add-ons/decorators/SATDecorator/SATGroup.cpp +++ b/src/add-ons/decorators/SATDecorator/SATGroup.cpp @@ -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) { diff --git a/src/add-ons/decorators/SATDecorator/SATGroup.h b/src/add-ons/decorators/SATDecorator/SATGroup.h index a0a3897002..2701123a75 100644 --- a/src/add-ons/decorators/SATDecorator/SATGroup.h +++ b/src/add-ons/decorators/SATDecorator/SATGroup.h @@ -136,6 +136,7 @@ public: const SATWindowList& LayerOrder() { return fWindowLayerOrder; } bool MoveWindowToPosition(SATWindow* window, int32 index); + void UpdateSizeLimits(); Crossing* LeftTopCrossing() { return fLeftTopCrossing.Get(); } diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.cpp b/src/add-ons/decorators/SATDecorator/SATWindow.cpp index cdf979fdb7..54f3422e35 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.cpp +++ b/src/add-ons/decorators/SATDecorator/SATWindow.cpp @@ -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); } diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.h b/src/add-ons/decorators/SATDecorator/SATWindow.h index 25d25f8179..16a4acb5b2 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.h +++ b/src/add-ons/decorators/SATDecorator/SATWindow.h @@ -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 diff --git a/src/add-ons/decorators/SATDecorator/StackAndTile.cpp b/src/add-ons/decorators/SATDecorator/StackAndTile.cpp index 961e1133e7..33a5d66605 100644 --- a/src/add-ons/decorators/SATDecorator/StackAndTile.cpp +++ b/src/add-ons/decorators/SATDecorator/StackAndTile.cpp @@ -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(); } diff --git a/src/add-ons/decorators/SATDecorator/StackAndTile.h b/src/add-ons/decorators/SATDecorator/StackAndTile.h index 2baea23d48..c6b72bb2f9 100644 --- a/src/add-ons/decorators/SATDecorator/StackAndTile.h +++ b/src/add-ons/decorators/SATDecorator/StackAndTile.h @@ -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);