public cassowary.Constraint getConstraint(Dictionary <RectTransform, WrappedRect> dct) { WrappedRect f1; WrappedRect f2; cassowary.Expression ex1; cassowary.Expression ex2; if (first == null && second == null) { return(null); } if (first != null) { if (!dct.TryGetValue(first, out f1)) { f1 = new WrappedRect(first); dct[first] = f1; } ex1 = f1.getTermFromSide(firstSide) * firstcoef; } else { ex1 = new cassowary.Expression(firstcoef); } if (second != null) { if (!dct.TryGetValue(second, out f2)) { f2 = new WrappedRect(second); dct[second] = f2; } ex2 = f2.getTermFromSide(secondSide) * secondcoef; } else { ex2 = new cassowary.Expression(secondcoef); } switch (relation) { case Relation.Equal: { return(cassowary.Constraint.Eq(ex1 + freecoef, ex2) | cassowary.Strength.fromEnum(strength)); } case Relation.GreaterThan: { return(cassowary.Constraint.Ge(ex1 + freecoef, ex2) | cassowary.Strength.fromEnum(strength)); } case Relation.LessThan: { return(cassowary.Constraint.Le(ex1 + freecoef, ex2) | cassowary.Strength.fromEnum(strength)); } } return(null); }
public cassowary.Constraint getConstraint(Dictionary <RectTransform, WrappedRect> dct) { cassowary.Expression ex = new cassowary.Expression(); foreach (SingleTerm term in terms) { if (term.rect == null) { ex = ex + new cassowary.Expression(term.coef); } else { WrappedRect f1; if (!dct.TryGetValue(term.rect, out f1)) { f1 = new WrappedRect(term.rect); dct[term.rect] = f1; } ex = ex + f1.getTermFromSide(term.side) * term.coef; } } switch (relation) { case Relation.Equal: { return(cassowary.Constraint.Eq(ex, 0) | cassowary.Strength.fromEnum(strength)); } case Relation.GreaterThan: { return(cassowary.Constraint.Ge(ex, 0) | cassowary.Strength.fromEnum(strength)); } case Relation.LessThan: { return(cassowary.Constraint.Le(ex, 0) | cassowary.Strength.fromEnum(strength)); } } return(null); }