Commit 2152de9a authored by Chinmay Garde's avatar Chinmay Garde

Minor: Add support for priority updates on constraints

parent f6a32362
......@@ -12,4 +12,6 @@ class Constraint {
double priority = 1000.0;
Constraint(this.expression, this.relation);
Constraint operator |(double p) => this..priority = p;
}
......@@ -6,6 +6,7 @@ part of cassowary;
class Expression extends EquationMember {
final List<Term> terms;
final double constant;
double get value => terms.fold(constant, (value, term) => value + term.value);
......
......@@ -259,4 +259,15 @@ void main() {
expect(c3.expression.constant, -30.0);
expect(c3.relation, Relation.lessThanOrEqualTo);
});
test('constraint_strength_update', () {
var left = new Variable(2.0);
var right = new Variable(10.0);
var c = (right - left >= 200.0) | 750.0;
expect(c is Constraint, true);
expect(c.expression.terms.length, 2);
expect(c.expression.constant, -200.0);
expect(c.priority, 750.0);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment