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:
@@ -45,11 +45,11 @@ func (e EditorStyle) Layout(gtx *layout.Context, editor *widget.Editor) {
|
||||
tl := widget.Label{Alignment: editor.Alignment}
|
||||
tl.Layout(gtx, e.shaper, e.Font, e.TextSize, e.Hint)
|
||||
macro.Stop()
|
||||
if w := gtx.Dimensions.Size.X; gtx.Constraints.Width.Min < w {
|
||||
gtx.Constraints.Width.Min = w
|
||||
if w := gtx.Dimensions.Size.X; gtx.Constraints.Min.X < w {
|
||||
gtx.Constraints.Min.X = w
|
||||
}
|
||||
if h := gtx.Dimensions.Size.Y; gtx.Constraints.Height.Min < h {
|
||||
gtx.Constraints.Height.Min = h
|
||||
if h := gtx.Dimensions.Size.Y; gtx.Constraints.Min.Y < h {
|
||||
gtx.Constraints.Min.Y = h
|
||||
}
|
||||
editor.Layout(gtx, e.shaper, e.Font, e.TextSize)
|
||||
if editor.Len() > 0 {
|
||||
|
||||
Reference in New Issue
Block a user