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, // is one of north, northeast, east, southeast, south, southwest, west,
// northwest, center. // 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. // 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 // hcap/vcap(size, widget) caps the maximum horizontal or vertical
// constraints to size. // constraints to size.
// //
@@ -119,25 +122,44 @@ func formatLayout(gtx *Context, state *formatState, widgets []Widget) {
formatFlex(gtx, Vertical, state, widgets) formatFlex(gtx, Vertical, state, widgets)
case "stack": case "stack":
formatStack(gtx, state, widgets) formatStack(gtx, state, widgets)
case "hexp": case "hmax":
cs := gtx.Constraints cs := gtx.Constraints
cs.Width.Min = cs.Width.Max cs.Width.Min = cs.Width.Max
ctxLayout(gtx, cs, func() { ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets) formatExpr(gtx, state, widgets)
}) })
case "vexp": case "vmax":
cs := gtx.Constraints cs := gtx.Constraints
cs.Height.Min = cs.Height.Max cs.Height.Min = cs.Height.Max
ctxLayout(gtx, cs, func() { ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets) formatExpr(gtx, state, widgets)
}) })
case "exp": case "max":
cs := gtx.Constraints cs := gtx.Constraints
cs.Width.Min = cs.Width.Max cs.Width.Min = cs.Width.Max
cs.Height.Min = cs.Height.Max cs.Height.Min = cs.Height.Max
ctxLayout(gtx, cs, func() { ctxLayout(gtx, cs, func() {
formatExpr(gtx, state, widgets) 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": case "hcap":
w := parseValue(state) w := parseValue(state)
expect(state, ",") expect(state, ",")