mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
ui/layout,ui/text,ui/widget: shorten Widget function names to W
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+10
-10
@@ -70,12 +70,12 @@ func ExactConstraints(size image.Point) Constraints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Insets struct {
|
type Insets struct {
|
||||||
W Widget
|
C Widget
|
||||||
|
|
||||||
Top, Right, Bottom, Left float32
|
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
|
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)))
|
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 {
|
if mcs.Width.Max != ui.Inf {
|
||||||
@@ -100,7 +100,7 @@ func (in Insets) Layout(ops *ui.Ops, cs Constraints) Dimens {
|
|||||||
}
|
}
|
||||||
ops.Begin()
|
ops.Begin()
|
||||||
ui.OpTransform{Transform: ui.Offset(toPointF(image.Point{X: l, Y: t}))}.Add(ops)
|
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)
|
ops.End().Add(ops)
|
||||||
return Dimens{
|
return Dimens{
|
||||||
Size: cs.Constrain(dims.Size.Add(image.Point{X: r + l, Y: t + b})),
|
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 {
|
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 {
|
func isInf(v ui.Value) bool {
|
||||||
@@ -117,11 +117,11 @@ func isInf(v ui.Value) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Sized struct {
|
type Sized struct {
|
||||||
W Widget
|
C Widget
|
||||||
Width, Height float32
|
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 h := int(s.Height + 0.5); h != 0 {
|
||||||
if cs.Height.Min < h {
|
if cs.Height.Min < h {
|
||||||
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
|
cs.Width.Max = w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s.W(ops, cs)
|
return s.C(ops, cs)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Align struct {
|
type Align struct {
|
||||||
W Widget
|
C Widget
|
||||||
Alignment Direction
|
Alignment Direction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Align) Layout(ops *ui.Ops, cs Constraints) Dimens {
|
func (a Align) W(ops *ui.Ops, cs Constraints) Dimens {
|
||||||
ops.Begin()
|
ops.Begin()
|
||||||
dims := a.W(ops, cs.Loose())
|
dims := a.C(ops, cs.Loose())
|
||||||
block := ops.End()
|
block := ops.End()
|
||||||
sz := dims.Size
|
sz := dims.Size
|
||||||
if cs.Width.Max != ui.Inf {
|
if cs.Width.Max != ui.Inf {
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ func (e *Editor) caretWidth() fixed.Int26_6 {
|
|||||||
return fixed.Int26_6(oneDp * 64)
|
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)
|
twoDp := int(e.cfg.Pixels(ui.Dp(2)) + 0.5)
|
||||||
e.padLeft, e.padRight = twoDp, twoDp
|
e.padLeft, e.padRight = twoDp, twoDp
|
||||||
maxWidth := cs.Width.Max
|
maxWidth := cs.Width.Max
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ func (l *lineIterator) Next() (String, f32.Point, bool) {
|
|||||||
return String{}, f32.Point{}, false
|
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)
|
textLayout := l.Face.Layout(l.Text, false, cs.Width.Max)
|
||||||
lines := textLayout.Lines
|
lines := textLayout.Lines
|
||||||
dims := linesDimens(lines)
|
dims := linesDimens(lines)
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ type Image struct {
|
|||||||
Rect image.Rectangle
|
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}
|
d := image.Point{X: cs.Width.Max, Y: cs.Height.Max}
|
||||||
if d.X == ui.Inf {
|
if d.X == ui.Inf {
|
||||||
d.X = cs.Width.Min
|
d.X = cs.Width.Min
|
||||||
|
|||||||
Reference in New Issue
Block a user