mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout,widget: transpose Constraints to use image.Points for limits
Instead of
type Contraints struct {
Width, Height Constraint
}
use
type Constraints struct {
Min, Max image.Point
}
which leads to simpler use. For example, the Min method is trivally replaced by
the field, and the RigidConstraints constructor is no longer a net win.
API Change. Rewrites:
gofmt -r 'gtx.Constraints.Min() -> gtx.Constraints.Min'
gofmt -r 'gtx.Constraints.Width.Min -> gtx.Constraints.Min.X'
gofmt -r 'gtx.Constraints.Height.Min -> gtx.Constraints.Min.Y'
gofmt -r 'gtx.Constraints.Height.Max -> gtx.Constraints.Max.Y'
gofmt -r 'gtx.Constraints.Width.Max -> gtx.Constraints.Max.X'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+2
-4
@@ -54,8 +54,7 @@ func (s Stack) Layout(gtx *Context, children ...StackChild) {
|
||||
continue
|
||||
}
|
||||
cs := gtx.Constraints
|
||||
cs.Width.Min = 0
|
||||
cs.Height.Min = 0
|
||||
cs.Min = image.Pt(0, 0)
|
||||
var m op.MacroOp
|
||||
m.Record(gtx.Ops)
|
||||
dims := ctxLayout(gtx, cs, w.widget)
|
||||
@@ -77,8 +76,7 @@ func (s Stack) Layout(gtx *Context, children ...StackChild) {
|
||||
var m op.MacroOp
|
||||
m.Record(gtx.Ops)
|
||||
cs := Constraints{
|
||||
Width: Constraint{Min: maxSZ.X, Max: gtx.Constraints.Width.Max},
|
||||
Height: Constraint{Min: maxSZ.Y, Max: gtx.Constraints.Height.Max},
|
||||
Min: maxSZ, Max: gtx.Constraints.Max,
|
||||
}
|
||||
dims := ctxLayout(gtx, cs, w.widget)
|
||||
m.Stop()
|
||||
|
||||
Reference in New Issue
Block a user