Author: czeidler Date: 2010-09-14 07:23:05 +0200 (Tue, 14 Sep 2010) New Revision: 38643 Changeset: http://dev.haiku-os.org/changeset/38643 Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h Log: Improve min constraints and add max constraints, not perfect yet but much better then before. Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp 2010-09-14 05:11:15 UTC (rev 38642) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp 2010-09-14 05:23:05 UTC (rev 38643) @@ -752,8 +752,6 @@ // set window locations and sizes for (int i = 0; i < fSATWindowList.CountItems(); i++) { SATWindow* windowSAT = fSATWindowList.ItemAt(i); - if (windowSAT == triggerWindow) - continue; windowSAT->MoveWindowToSAT( triggerWindow->GetWindow()->CurrentWorkspace()); } Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp 2010-09-14 05:11:15 UTC (rev 38642) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp 2010-09-14 05:23:05 UTC (rev 38643) @@ -38,6 +38,8 @@ fTopConstraint(NULL), fMinWidthConstraint(NULL), fMinHeightConstraint(NULL), + fMaxWidthConstraint(NULL), + fMaxHeightConstraint(NULL), fWidthConstraint(NULL), fHeightConstraint(NULL) { @@ -51,7 +53,7 @@ } -const uint32 kExtentPenalty = 25; +const uint32 kExtentPenalty = 10; void @@ -71,6 +73,13 @@ fLeftConstraint->SetRightSide(frame.left); fTopConstraint->SetRightSide(frame.top); + int32 minWidth, maxWidth, minHeight, maxHeight; + fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); + fMinWidthConstraint->SetRightSide(minWidth); + fMinHeightConstraint->SetRightSide(minHeight); + fMaxWidthConstraint->SetRightSide(maxWidth); + fMaxHeightConstraint->SetRightSide(maxHeight); + fWidthConstraint->SetPenaltyNeg(110); fWidthConstraint->SetPenaltyPos(110); fHeightConstraint->SetPenaltyNeg(110); @@ -85,9 +94,7 @@ ResultType result; for (int32 tries = 0; tries < 15; tries++) { result = fSATGroup->GetLinearSpec()->Solve(); - if (result == INFEASIBLE) - break; - if (result == OPTIMAL) { + if (result == OPTIMAL || result == INFEASIBLE) { fSATGroup->AdjustWindows(triggerWindow); break; } @@ -132,7 +139,6 @@ { ASSERT(fSATGroup.Get() == NULL); - Window* window = fSATWindow->GetWindow(); fSATGroup.SetTo(group); fWindowArea = area; @@ -157,11 +163,15 @@ OperatorType(EQ), frame.top, 1, 1); int32 minWidth, maxWidth, minHeight, maxHeight; - window->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); - fMinWidthConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, -1.0, - fRightBorder, OperatorType(LE), -minWidth); - fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0, - fBottomBorder, OperatorType(LE), -minHeight); + fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); + fMinWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0, + fLeftBorder, OperatorType(GE), minWidth); + fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0, + fTopBorder, OperatorType(GE), minHeight); + fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0, + fTopBorder, OperatorType(LE), maxHeight); + fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0, + fTopBorder, OperatorType(LE), maxHeight); // The width and height constraints have higher penalties than the // position constraints (left, top), so a window will keep its size @@ -220,12 +230,16 @@ delete fTopConstraint; delete fMinWidthConstraint; delete fMinHeightConstraint; + delete fMaxWidthConstraint; + delete fMaxHeightConstraint; delete fWidthConstraint; delete fHeightConstraint; fLeftConstraint = NULL; fTopConstraint = NULL; fMinWidthConstraint = NULL; fMinHeightConstraint = NULL; + fMaxWidthConstraint = NULL; + fMaxHeightConstraint = NULL; fWidthConstraint = NULL; fHeightConstraint = NULL; @@ -480,6 +494,20 @@ } +void +SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight, + int32* maxHeight) const +{ + fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); + + // TODO get this values from the decorator + *minWidth += 11; + *minHeight += 11; + *maxWidth += 32; + *maxHeight += 32; +} + + bool SATWindow::PositionManagedBySAT() { Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2010-09-14 05:11:15 UTC (rev 38642) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2010-09-14 05:23:05 UTC (rev 38643) @@ -62,6 +62,8 @@ Constraint* fTopConstraint; Constraint* fMinWidthConstraint; Constraint* fMinHeightConstraint; + Constraint* fMaxWidthConstraint; + Constraint* fMaxHeightConstraint; Constraint* fWidthConstraint; Constraint* fHeightConstraint; }; @@ -103,6 +105,8 @@ //! \return the complete window frame including the Decorator BRect CompleteWindowFrame(); + void GetSizeLimits(int32* minWidth, int32* maxWidth, + int32* minHeight, int32* maxHeight) const; //! \return true if window is in a group with a least another window bool PositionManagedBySAT();