layout: rename "exp" layout variants to "max"; add "min" variants

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-17 13:55:03 +02:00
parent 7835d6999f
commit 862061b363
+26 -4
View File
@@ -47,9 +47,12 @@ type formatError string
// is one of north, northeast, east, southeast, south, southwest, west,
// northwest, center.
//
// hexp/vexp/exp(widget) forces the horizontal, vertical or both
// hmax/vmax/max(widget) forces the horizontal, vertical or both
// constraints to their maximum before laying out widget.
//
// hmin/vmin/min(widget) forces the horizontal, vertical or both
// constraints to their minimum before laying out widget.
//
// hcap/vcap(size, widget) caps the maximum horizontal or vertical
// constraints to size.
//
@@ -119,25 +122,44 @@ func formatLayout(gtx *Context, state *formatState, widgets []Widget) {
formatFlex(gtx, Vertical, state, widgets)
case "stack":
formatStack(gtx, state, widgets)
case "hexp":
case "hmax":
cs := gtx.Constraints
cs.Width.Min = cs.Width.Max
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "vexp":
case "vmax":
cs := gtx.Constraints
cs.Height.Min = cs.Height.Max
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "exp":
case "max":
cs := gtx.Constraints
cs.Width.Min = cs.Width.Max
cs.Height.Min = cs.Height.Max
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "hmin":
cs := gtx.Constraints
cs.Width.Max = cs.Width.Min
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "vmin":
cs := gtx.Constraints
cs.Height.Max = cs.Height.Min
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "min":
cs := gtx.Constraints
cs.Width.Max = cs.Width.Min
cs.Height.Max = cs.Height.Min
ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets)
})
case "hcap":
w := parseValue(state)
expect(state, ",")