~eliasnaur/gio

2d96e760d39a964c16a2de2e7f701f87ec590f22 — Elias Naur 2 years ago 3e5e9b2
ui/layout,ui/text,ui/widget: shorten Widget function names to W

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 files changed, 13 insertions(+), 13 deletions(-)

M ui/layout/layout.go
M ui/text/editor.go
M ui/text/label.go
M ui/widget/image.go
M ui/layout/layout.go => ui/layout/layout.go +10 -10
@@ 70,12 70,12 @@ func ExactConstraints(size image.Point) Constraints {
}

type Insets struct {
	W Widget
	C Widget

	Top, Right, Bottom, Left float32
}

func (in Insets) Layout(ops *ui.Ops, cs Constraints) Dimens {
func (in Insets) W(ops *ui.Ops, cs Constraints) Dimens {
	mcs := cs
	t, r, b, l := int(math.Round(float64(in.Top))), int(math.Round(float64(in.Right))), int(math.Round(float64(in.Bottom))), int(math.Round(float64(in.Left)))
	if mcs.Width.Max != ui.Inf {


@@ 100,7 100,7 @@ func (in Insets) Layout(ops *ui.Ops, cs Constraints) Dimens {
	}
	ops.Begin()
	ui.OpTransform{Transform: ui.Offset(toPointF(image.Point{X: l, Y: t}))}.Add(ops)
	dims := in.W(ops, mcs)
	dims := in.C(ops, mcs)
	ops.End().Add(ops)
	return Dimens{
		Size:     cs.Constrain(dims.Size.Add(image.Point{X: r + l, Y: t + b})),


@@ 109,7 109,7 @@ func (in Insets) Layout(ops *ui.Ops, cs Constraints) Dimens {
}

func EqualInsets(v float32, w Widget) Insets {
	return Insets{W: w, Top: v, Right: v, Bottom: v, Left: v}
	return Insets{C: w, Top: v, Right: v, Bottom: v, Left: v}
}

func isInf(v ui.Value) bool {


@@ 117,11 117,11 @@ func isInf(v ui.Value) bool {
}

type Sized struct {
	W             Widget
	C             Widget
	Width, Height float32
}

func (s Sized) Layout(ops *ui.Ops, cs Constraints) Dimens {
func (s Sized) W(ops *ui.Ops, cs Constraints) Dimens {
	if h := int(s.Height + 0.5); h != 0 {
		if cs.Height.Min < h {
			cs.Height.Min = h


@@ 138,17 138,17 @@ func (s Sized) Layout(ops *ui.Ops, cs Constraints) Dimens {
			cs.Width.Max = w
		}
	}
	return s.W(ops, cs)
	return s.C(ops, cs)
}

type Align struct {
	W         Widget
	C         Widget
	Alignment Direction
}

func (a Align) Layout(ops *ui.Ops, cs Constraints) Dimens {
func (a Align) W(ops *ui.Ops, cs Constraints) Dimens {
	ops.Begin()
	dims := a.W(ops, cs.Loose())
	dims := a.C(ops, cs.Loose())
	block := ops.End()
	sz := dims.Size
	if cs.Width.Max != ui.Inf {

M ui/text/editor.go => ui/text/editor.go +1 -1
@@ 128,7 128,7 @@ func (e *Editor) caretWidth() fixed.Int26_6 {
	return fixed.Int26_6(oneDp * 64)
}

func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
func (e *Editor) W(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
	twoDp := int(e.cfg.Pixels(ui.Dp(2)) + 0.5)
	e.padLeft, e.padRight = twoDp, twoDp
	maxWidth := cs.Width.Max

M ui/text/label.go => ui/text/label.go +1 -1
@@ 80,7 80,7 @@ func (l *lineIterator) Next() (String, f32.Point, bool) {
	return String{}, f32.Point{}, false
}

func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
func (l Label) W(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
	textLayout := l.Face.Layout(l.Text, false, cs.Width.Max)
	lines := textLayout.Lines
	dims := linesDimens(lines)

M ui/widget/image.go => ui/widget/image.go +1 -1
@@ 16,7 16,7 @@ type Image struct {
	Rect image.Rectangle
}

func (im Image) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
func (im Image) W(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
	d := image.Point{X: cs.Width.Max, Y: cs.Height.Max}
	if d.X == ui.Inf {
		d.X = cs.Width.Min