From 8858a54b5ddb3a2d8a42ecb1a837c02800bc934f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 2 Mar 2026 17:38:55 -0500 Subject: create lay/strain package The lay/strain package uses the Cassowary algorithm to solve systems of layout constraints. --- lay/strain/constraint.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lay/strain/constraint.go (limited to 'lay/strain/constraint.go') diff --git a/lay/strain/constraint.go b/lay/strain/constraint.go new file mode 100644 index 0000000..44c9e0a --- /dev/null +++ b/lay/strain/constraint.go @@ -0,0 +1,28 @@ +package strain + +import ( + "github.com/lithdew/casso" + "golang.org/x/exp/shiny/unit" +) + +// Constraint imposes a restriction on the size of a widget or layout. +type Constraint struct { + // Dimension is the dimension to constrain: width/height. + Dimension + + // Relation declares whether the constraint is an upper, lower, + // or exact bound. + casso.Op + + // Value is the target or threshold value. + unit.Value +} + +// Dim is a dimension of a widget or layout that can be constrained. +type Dimension int + +const ( + _ Dimension = iota + Width + Height +) -- cgit v1.2.3