From: Mikko Rasa Date: Wed, 12 Jun 2013 09:55:04 +0000 (+0300) Subject: Properly filter out duplicate constraints X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f7433e42e110637b80e3ca80f9d41c62ce6477d2;p=libs%2Fgltk.git Properly filter out duplicate constraints --- diff --git a/source/layout.cpp b/source/layout.cpp index 3f03ab9..1ffbcda 100644 --- a/source/layout.cpp +++ b/source/layout.cpp @@ -351,21 +351,21 @@ void Layout::solve_constraints(int dir, SolveMode mode) row.back() = (*i)->autosize_geom.*(ptrs.dim); } - /* Add rows for user-defined constraints. Below/above and left/right of - constraints are always added in pairs, so it's only necessary to create a - row for one half. */ + /* Add rows for user-defined constraints. Constraints are always added + in pairs, so it's only necessary to create a row for one half. */ for(list::iterator j=(*i)->constraints.begin(); j!=(*i)->constraints.end(); ++j) - if(j->target.index>=0 && (j->type&1)==dir && j->type!=BELOW && j->type!=LEFT_OF) + if(j->target.index>(*i)->index && (j->type&1)==dir) { LinearProgram::Row row = linprog.add_row(); + float polarity = ((j->type&SELF_DIM) ? -1 : 1); if(j->type&SELF_POS) - row[(*i)->index*5] = 1; + row[(*i)->index*5] = polarity; if(j->type&SELF_DIM) - row[(*i)->index*5+1] = 1; + row[(*i)->index*5+1] = polarity; if(j->type&TARGET_POS) - row[j->target.index*5] = -1; + row[j->target.index*5] = -polarity; if(j->type&TARGET_DIM) - row[j->target.index*5+1] = -1; + row[j->target.index*5+1] = -polarity; if(j->type&SPACING) row.back() = (j->spacing>=0 ? j->spacing : this->*(ptrs.spacing)); }