Minor: Add stubs for the symbol and solver
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
13
packages/cassowary/lib/symbol.dart
Normal file
13
packages/cassowary/lib/symbol.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
// 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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user