Change S&T to make it work with the new solver. It also still works with lp_solve.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40286 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7583db5a1e
commit
5ba9397df3
|
@ -57,6 +57,9 @@ GroupCookie::~GroupCookie()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const float kBigOffset = 5000;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
||||||
{
|
{
|
||||||
|
@ -64,25 +67,25 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect frame = triggerWindow->CompleteWindowFrame();
|
BRect frame = triggerWindow->CompleteWindowFrame();
|
||||||
|
// Make it also work for solver which don't support negative variables
|
||||||
|
frame.OffsetBy(kBigOffset, kBigOffset);
|
||||||
|
|
||||||
// adjust window size soft constraints
|
// adjust window size soft constraints
|
||||||
fWidthConstraint->SetRightSide(frame.Width());
|
fWidthConstraint->SetRightSide(frame.Width());
|
||||||
fHeightConstraint->SetRightSide(frame.Height());
|
fHeightConstraint->SetRightSide(frame.Height());
|
||||||
|
|
||||||
|
LinearSpec* linearSpec = fSATGroup->GetLinearSpec();
|
||||||
|
fLeftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, kEQ,
|
||||||
|
frame.left);
|
||||||
|
fTopConstraint = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
|
||||||
|
frame.top);
|
||||||
|
|
||||||
// adjust window position soft constraints
|
// adjust window position soft constraints
|
||||||
// (a bit more penalty for them so they take precedence)
|
// (a bit more penalty for them so they take precedence)
|
||||||
fLeftConstraint->SetRightSide(frame.left);
|
fWidthConstraint->SetPenaltyNeg(-1);
|
||||||
fTopConstraint->SetRightSide(frame.top);
|
fWidthConstraint->SetPenaltyPos(-1);
|
||||||
|
fHeightConstraint->SetPenaltyNeg(-1);
|
||||||
fWidthConstraint->SetPenaltyNeg(110);
|
fHeightConstraint->SetPenaltyPos(-1);
|
||||||
fWidthConstraint->SetPenaltyPos(110);
|
|
||||||
fHeightConstraint->SetPenaltyNeg(110);
|
|
||||||
fHeightConstraint->SetPenaltyPos(110);
|
|
||||||
|
|
||||||
fLeftConstraint->SetPenaltyNeg(100);
|
|
||||||
fLeftConstraint->SetPenaltyPos(100);
|
|
||||||
fTopConstraint->SetPenaltyNeg(100);
|
|
||||||
fTopConstraint->SetPenaltyPos(100);
|
|
||||||
|
|
||||||
// After we set the new parameter solve and apply the new layout.
|
// After we set the new parameter solve and apply the new layout.
|
||||||
ResultType result;
|
ResultType result;
|
||||||
|
@ -105,10 +108,10 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
||||||
fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
|
fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
|
||||||
fHeightConstraint->SetPenaltyPos(kExtentPenalty);
|
fHeightConstraint->SetPenaltyPos(kExtentPenalty);
|
||||||
|
|
||||||
fLeftConstraint->SetPenaltyNeg(1);
|
linearSpec->RemoveConstraint(fLeftConstraint);
|
||||||
fLeftConstraint->SetPenaltyPos(1);
|
fLeftConstraint = NULL;
|
||||||
fTopConstraint->SetPenaltyNeg(1);
|
linearSpec->RemoveConstraint(fTopConstraint);
|
||||||
fTopConstraint->SetPenaltyPos(1);
|
fTopConstraint = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,14 +122,18 @@ GroupCookie::MoveWindow(int32 workspace)
|
||||||
Desktop* desktop = window->Desktop();
|
Desktop* desktop = window->Desktop();
|
||||||
|
|
||||||
BRect frame = fSATWindow->CompleteWindowFrame();
|
BRect frame = fSATWindow->CompleteWindowFrame();
|
||||||
desktop->MoveWindowBy(window, round(fLeftBorder->Value() - frame.left),
|
BRect frameSAT(fLeftBorder->Value() - kBigOffset,
|
||||||
round(fTopBorder->Value() - frame.top), workspace);
|
fTopBorder->Value() - kBigOffset, fRightBorder->Value() - kBigOffset,
|
||||||
|
fBottomBorder->Value() - kBigOffset);
|
||||||
|
|
||||||
|
desktop->MoveWindowBy(window, round(frameSAT.left - frame.left),
|
||||||
|
round(frameSAT.top - frame.top), workspace);
|
||||||
|
|
||||||
// Update frame to the new position
|
// Update frame to the new position
|
||||||
frame.OffsetBy(round(fLeftBorder->Value() - frame.left),
|
frame.OffsetBy(round(frameSAT.left - frame.left),
|
||||||
round(fTopBorder->Value() - frame.top));
|
round(frameSAT.top - frame.top));
|
||||||
desktop->ResizeWindowBy(window, round(fRightBorder->Value() - frame.right),
|
desktop->ResizeWindowBy(window, round(frameSAT.right - frame.right),
|
||||||
round(fBottomBorder->Value() - frame.bottom));
|
round(frameSAT.bottom - frame.bottom));
|
||||||
|
|
||||||
_UpdateWindowSize(frame);
|
_UpdateWindowSize(frame);
|
||||||
}
|
}
|
||||||
|
@ -164,10 +171,6 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
||||||
|
|
||||||
// create constraints
|
// create constraints
|
||||||
BRect frame = fSATWindow->CompleteWindowFrame();
|
BRect frame = fSATWindow->CompleteWindowFrame();
|
||||||
fLeftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, kEQ,
|
|
||||||
frame.left, 1, 1);
|
|
||||||
fTopConstraint = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
|
|
||||||
frame.top, 1, 1);
|
|
||||||
|
|
||||||
int32 minWidth, maxWidth, minHeight, maxHeight;
|
int32 minWidth, maxWidth, minHeight, maxHeight;
|
||||||
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight,
|
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight,
|
||||||
|
@ -187,7 +190,7 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
||||||
fBottomBorder, kEQ, frame.Height(), kExtentPenalty,
|
fBottomBorder, kEQ, frame.Height(), kExtentPenalty,
|
||||||
kExtentPenalty);
|
kExtentPenalty);
|
||||||
|
|
||||||
if (!fLeftConstraint || !fTopConstraint || !fMinWidthConstraint
|
if (!fMinWidthConstraint
|
||||||
|| !fMinHeightConstraint || !fWidthConstraint || !fHeightConstraint) {
|
|| !fMinHeightConstraint || !fWidthConstraint || !fHeightConstraint) {
|
||||||
// clean up
|
// clean up
|
||||||
Uninit();
|
Uninit();
|
||||||
|
|
|
@ -92,7 +92,7 @@ StackAndTile::WindowAdded(Window* window)
|
||||||
if (!satWindow)
|
if (!satWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(fSATWindowMap.find(window) != fSATWindowMap.end());
|
ASSERT(fSATWindowMap.find(window) == fSATWindowMap.end());
|
||||||
fSATWindowMap[window] = satWindow;
|
fSATWindowMap[window] = satWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +454,10 @@ StackAndTile::GetSATWindow(Window* window)
|
||||||
if (it != fSATWindowMap.end())
|
if (it != fSATWindowMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
|
// TODO fix race condition with WindowAdded this method is called before
|
||||||
|
// WindowAdded and a SATWindow is created twice!
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// If we don't know this window, memory allocation might has been failed
|
// If we don't know this window, memory allocation might has been failed
|
||||||
// previously. Try to add the window now.
|
// previously. Try to add the window now.
|
||||||
SATWindow* satWindow = new (std::nothrow)SATWindow(this, window);
|
SATWindow* satWindow = new (std::nothrow)SATWindow(this, window);
|
||||||
|
|
Loading…
Reference in New Issue