Commit 306c795c authored by Chinmay Garde's avatar Chinmay Garde

Minor: Add stubs for the symbol and solver

parent e788fe53
......@@ -11,3 +11,4 @@ part 'variable.dart';
part 'equation_member.dart';
part 'constant_member.dart';
part 'solver.dart';
part 'symbol.dart';
......@@ -6,6 +6,7 @@ part of cassowary;
class ConstantMember extends EquationMember {
double value = 0.0;
ConstantMember(this.value);
Expression asExpression() => new Expression([], this.value);
......
......@@ -9,9 +9,19 @@ enum Relation { equalTo, lessThanOrEqualTo, greaterThanOrEqualTo, }
class Constraint {
final Relation relation;
final Expression expression;
double priority = 1000.0;
final bool required;
Constraint(this.expression, this.relation);
static const double requiredPriority = 1000.0;
double _priority = requiredPriority - 1.0;
Constraint(this.expression, this.relation) : this.required = false;
Constraint.Required(this.expression, this.relation) : this.required = true {
this.priority = requiredPriority;
}
double get priority => required ? requiredPriority : _priority;
set priority(double p) => _priority =
required ? requiredPriority : p.clamp(0.0, requiredPriority - 1.0);
Constraint operator |(double p) => this..priority = p;
}
......@@ -13,5 +13,27 @@ class Solver {
return false;
}
bool hasConstraint(Constraint c) {
return false;
}
bool addEditVariable(Variable v, double priority) {
return false;
}
bool removeEditVariable(Variable v) {
return false;
}
bool hasEditVariable(Variable v) {
return false;
}
bool suggestVariable(Variable v, double value) {
return false;
}
void updateVariable() {}
Solver operator <<(Constraint c) => this..addConstraint(c);
}
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
part of cassowary;
enum SymbolType { invalid, external, slack, error, dummy, }
class Symbol {
SymbolType type;
Symbol(this.type);
}
......@@ -280,6 +280,8 @@ void main() {
var c1 = right - left >= CM(200.0);
var c2 = right + left >= CM(0.0);
expect((right >= left) is Constraint, true);
// TODO: Add assertions for this
s << c1 << c2;
});
......
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