Pass more information to BadLayoutPolicy.
Also, re-add BadLayoutPolicy invocations, which were lost while creating SharedSolver.
This commit is contained in:
parent
93904ad087
commit
09e87fa352
@ -129,12 +129,14 @@ public:
|
||||
struct BadLayoutPolicy {
|
||||
virtual ~BadLayoutPolicy();
|
||||
/* return false to abandon layout, true to use layout */
|
||||
virtual bool OnBadLayout(BALMLayout* layout) = 0;
|
||||
virtual bool OnBadLayout(BALMLayout* layout,
|
||||
LinearProgramming::ResultType result, BLayoutContext* context) = 0;
|
||||
};
|
||||
|
||||
struct DefaultPolicy : public BadLayoutPolicy {
|
||||
virtual ~DefaultPolicy();
|
||||
virtual bool OnBadLayout(BALMLayout* layout);
|
||||
virtual bool OnBadLayout(BALMLayout* layout,
|
||||
LinearProgramming::ResultType result, BLayoutContext* context);
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -108,9 +108,13 @@ BALM::BALMLayout::DefaultPolicy::~DefaultPolicy()
|
||||
|
||||
|
||||
bool
|
||||
BALM::BALMLayout::DefaultPolicy::OnBadLayout(BALMLayout* layout)
|
||||
BALM::BALMLayout::DefaultPolicy::OnBadLayout(BALMLayout* layout,
|
||||
ResultType result, BLayoutContext* context)
|
||||
{
|
||||
if (layout->Solver()->Result() == kInfeasible) {
|
||||
if (!context)
|
||||
return true;
|
||||
|
||||
if (result == kInfeasible) {
|
||||
debugger("BALMLayout failed to solve your layout!");
|
||||
return false;
|
||||
} else
|
||||
@ -821,7 +825,9 @@ BALMLayout::GetBadLayoutPolicy() const
|
||||
BSize
|
||||
BALMLayout::BaseMinSize()
|
||||
{
|
||||
fSolver->ValidateMinSize();
|
||||
ResultType result = fSolver->ValidateMinSize();
|
||||
if (result != kOptimal && result != kUnbounded)
|
||||
fBadLayoutPolicy->OnBadLayout(this, result, NULL);
|
||||
return fMinSize;
|
||||
}
|
||||
|
||||
@ -832,7 +838,9 @@ BALMLayout::BaseMinSize()
|
||||
BSize
|
||||
BALMLayout::BaseMaxSize()
|
||||
{
|
||||
fSolver->ValidateMaxSize();
|
||||
ResultType result = fSolver->ValidateMaxSize();
|
||||
if (result != kOptimal && result != kUnbounded)
|
||||
fBadLayoutPolicy->OnBadLayout(this, result, NULL);
|
||||
return fMaxSize;
|
||||
}
|
||||
|
||||
@ -902,7 +910,12 @@ BALMLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
|
||||
void
|
||||
BALMLayout::DoLayout()
|
||||
{
|
||||
fSolver->ValidateLayout(LayoutContext());
|
||||
BLayoutContext* context = LayoutContext();
|
||||
ResultType result = fSolver->ValidateLayout(context);
|
||||
if (result != kOptimal
|
||||
&& !fBadLayoutPolicy->OnBadLayout(this, result, context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set the calculated positions and sizes for every area
|
||||
for (int32 i = 0; i < CountItems(); i++)
|
||||
|
Loading…
Reference in New Issue
Block a user