mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 07:57:29 +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:
@@ -34,8 +34,7 @@ func (c *checkable) layout(gtx *layout.Context, checked bool) {
|
||||
icon = c.uncheckedStateIcon
|
||||
}
|
||||
|
||||
hmin := gtx.Constraints.Width.Min
|
||||
vmin := gtx.Constraints.Height.Min
|
||||
min := gtx.Constraints.Min
|
||||
layout.Flex{Alignment: layout.Middle}.Layout(gtx,
|
||||
layout.Rigid(func() {
|
||||
layout.Center.Layout(gtx, func() {
|
||||
@@ -51,8 +50,7 @@ func (c *checkable) layout(gtx *layout.Context, checked bool) {
|
||||
}),
|
||||
|
||||
layout.Rigid(func() {
|
||||
gtx.Constraints.Width.Min = hmin
|
||||
gtx.Constraints.Height.Min = vmin
|
||||
gtx.Constraints.Min = min
|
||||
layout.W.Layout(gtx, func() {
|
||||
layout.UniformInset(unit.Dp(2)).Layout(gtx, func() {
|
||||
paint.ColorOp{Color: c.Color}.Add(gtx.Ops)
|
||||
|
||||
Reference in New Issue
Block a user