From c99ff181003c565385c21b92ca15161fbdff2bd8 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 24 Feb 2026 17:49:26 -0500 Subject: add layout constraints and abs/rel units --- constraint.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 constraint.go (limited to 'constraint.go') diff --git a/constraint.go b/constraint.go new file mode 100644 index 0000000..c08e222 --- /dev/null +++ b/constraint.go @@ -0,0 +1,34 @@ +package gui + +// Constraint imposes a restriction on the size of a widget or layout. +type Constraint struct { + // Dim is the dimension to constrain: width/height. + Dim + + // Relation declares whether the constraint is an upper, lower, or exact bound. + Relation + + // Length is the target or threshold value. + Length +} + +// Dim is a dimension of a widget or layout that can be constrained. +type Dim int + +const ( + _ Dim = iota + Width + Height +) + +// Relation is an (in)equality. +type Relation int + +const ( + _ Relation = iota + Eq // == + Gteq // >= + Gt // > + Lteq // <= + Lt // < +) -- cgit v1.2.3