all: rename layout.Dimens to layout.Dimensions

Dimens is only 4 characters shorter and not worth the abbreviation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-30 15:00:17 +02:00
parent 7f29293f16
commit 12089ea62a
10 changed files with 29 additions and 29 deletions
+2 -2
View File
@@ -8,8 +8,8 @@ Constraints and dimensions
Constraints and dimensions form the the interface between
layouts and interface child elements. Every layout operation
start with a set of constraints for acceptable widths and heights
of a child. The operation ends by the child computing and returning
its chosen size in the form of a Dimens.
of a child. The operation ends with the child computing and returning
its size and baseline (if any).
For example, to add space above a widget:
+4 -4
View File
@@ -33,7 +33,7 @@ type Flex struct {
// FlexChild is the layout result of a call End.
type FlexChild struct {
macro ui.MacroOp
dims Dimens
dims Dimensions
}
// Spacing determine the spacing mode for a Flex.
@@ -124,7 +124,7 @@ func (f *Flex) Flexible(weight float32) Constraints {
// End a child by specifying its dimensions. Pass the returned layout result
// to Layout.
func (f *Flex) End(dims Dimens) FlexChild {
func (f *Flex) End(dims Dimensions) FlexChild {
if f.mode <= modeBegun {
panic("End called without an active child")
}
@@ -146,7 +146,7 @@ func (f *Flex) End(dims Dimens) FlexChild {
// Layout a list of children. The order of the children determines their laid
// out order.
func (f *Flex) Layout(children ...FlexChild) Dimens {
func (f *Flex) Layout(children ...FlexChild) Dimensions {
mainc := axisMainConstraint(f.Axis, f.cs)
crossSize := axisCrossConstraint(f.Axis, f.cs).Constrain(f.maxCross)
var space int
@@ -213,7 +213,7 @@ func (f *Flex) Layout(children ...FlexChild) Dimens {
if baseline == 0 {
baseline = sz.Y
}
return Dimens{Size: sz, Baseline: baseline}
return Dimensions{Size: sz, Baseline: baseline}
}
func axisPoint(a Axis, main, cross int) image.Point {
+6 -6
View File
@@ -21,9 +21,9 @@ type Constraint struct {
Min, Max int
}
// Dimens are the resolved size and baseline for a user
// Dimensions are the resolved size and baseline for a user
// interface element.
type Dimens struct {
type Dimensions struct {
Size image.Point
Baseline int
}
@@ -143,13 +143,13 @@ func (in *Inset) Begin(c ui.Config, ops *ui.Ops, cs Constraints) Constraints {
// End the inset operation and return the dimensions for the
// inset child.
func (in *Inset) End(dims Dimens) Dimens {
func (in *Inset) End(dims Dimensions) Dimensions {
if !in.begun {
panic("must Begin before End")
}
in.begun = false
in.stack.Pop()
return Dimens{
return Dimensions{
Size: in.cs.Constrain(dims.Size.Add(image.Point{X: in.right + in.left, Y: in.top + in.bottom})),
Baseline: dims.Baseline + in.top,
}
@@ -177,7 +177,7 @@ func (a *Align) Begin(ops *ui.Ops, cs Constraints) Constraints {
// End the align operation and return the dimensions for the
// aligned child.
func (a *Align) End(dims Dimens) Dimens {
func (a *Align) End(dims Dimensions) Dimensions {
if !a.begun {
panic("must Begin before End")
}
@@ -209,7 +209,7 @@ func (a *Align) End(dims Dimens) Dimens {
ui.TransformOp{}.Offset(toPointF(p)).Add(ops)
a.macro.Add(ops)
stack.Pop()
return Dimens{
return Dimensions{
Size: sz,
Baseline: dims.Baseline,
}
+2 -2
View File
@@ -140,8 +140,8 @@ func ExampleList() {
// 5
}
func layoutWidget(width, height int, cs layout.Constraints) layout.Dimens {
return layout.Dimens{
func layoutWidget(width, height int, cs layout.Constraints) layout.Dimensions {
return layout.Dimensions{
Size: image.Point{
X: width,
Y: height,
+3 -3
View File
@@ -158,7 +158,7 @@ func (l *List) next() (int, bool) {
}
// End the current child by specifying its dimensions.
func (l *List) End(dims Dimens) {
func (l *List) End(dims Dimensions) {
l.child.Stop()
child := scrollChild{dims.Size, l.child}
switch l.dir {
@@ -179,7 +179,7 @@ func (l *List) End(dims Dimens) {
}
// Layout the List and return its dimensions.
func (l *List) Layout() Dimens {
func (l *List) Layout() Dimensions {
if l.more {
panic("unfinished child")
}
@@ -254,5 +254,5 @@ func (l *List) Layout() Dimens {
pointer.RectAreaOp{Rect: image.Rectangle{Max: dims}}.Add(ops)
l.scroll.Add(ops)
l.macro.Add(ops)
return Dimens{Size: dims}
return Dimensions{Size: dims}
}
+4 -4
View File
@@ -27,7 +27,7 @@ type Stack struct {
// StackChild is the layout result of a call to End.
type StackChild struct {
macro ui.MacroOp
dims Dimens
dims Dimensions
}
// Init a stack before calling Rigid or Expand.
@@ -69,7 +69,7 @@ func (s *Stack) Expand() Constraints {
}
// End a child by specifying its dimensions.
func (s *Stack) End(dims Dimens) StackChild {
func (s *Stack) End(dims Dimensions) StackChild {
s.macro.Stop()
s.begun = false
if w := dims.Size.X; w > s.maxSZ.X {
@@ -88,7 +88,7 @@ func (s *Stack) End(dims Dimens) StackChild {
// Layout a list of children. The order of the children determines their laid
// out order.
func (s *Stack) Layout(children ...StackChild) Dimens {
func (s *Stack) Layout(children ...StackChild) Dimensions {
for _, ch := range children {
sz := ch.dims.Size
var p image.Point
@@ -114,7 +114,7 @@ func (s *Stack) Layout(children ...StackChild) Dimens {
if b == 0 {
b = s.maxSZ.Y
}
return Dimens{
return Dimensions{
Size: s.maxSZ,
Baseline: b,
}
+3 -3
View File
@@ -48,7 +48,7 @@ type Editor struct {
viewSize image.Point
valid bool
lines []Line
dims layout.Dimens
dims layout.Dimensions
padTop, padBottom int
padLeft, padRight int
requestFocus bool
@@ -165,7 +165,7 @@ func (e *Editor) Focus() {
e.requestFocus = true
}
func (e *Editor) Layout(cfg ui.Config, queue input.Queue, ops *ui.Ops, cs layout.Constraints) layout.Dimens {
func (e *Editor) Layout(cfg ui.Config, queue input.Queue, ops *ui.Ops, cs layout.Constraints) layout.Dimensions {
for _, ok := e.Next(cfg, queue); ok; _, ok = e.Next(cfg, queue) {
}
twoDp := cfg.Px(ui.Dp(2))
@@ -270,7 +270,7 @@ func (e *Editor) Layout(cfg ui.Config, queue input.Queue, ops *ui.Ops, cs layout
pointer.RectAreaOp{Rect: r}.Add(ops)
e.scroller.Add(ops)
e.clicker.Add(ops)
return layout.Dimens{Size: e.viewSize, Baseline: baseline}
return layout.Dimensions{Size: e.viewSize, Baseline: baseline}
}
// Text returns the contents of the editor.
+1 -1
View File
@@ -92,7 +92,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) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimensions {
textLayout := l.Face.Layout(l.Text, LayoutOptions{MaxWidth: cs.Width.Max})
lines := textLayout.Lines
if max := l.MaxLines; max > 0 && len(lines) > max {
+2 -2
View File
@@ -61,7 +61,7 @@ const (
Middle
)
func linesDimens(lines []Line) layout.Dimens {
func linesDimens(lines []Line) layout.Dimensions {
var width fixed.Int26_6
var h int
var baseline int
@@ -78,7 +78,7 @@ func linesDimens(lines []Line) layout.Dimens {
h += lines[len(lines)-1].Descent.Ceil()
}
w := width.Ceil()
return layout.Dimens{
return layout.Dimensions{
Size: image.Point{
X: w,
Y: h,
+2 -2
View File
@@ -25,7 +25,7 @@ type Image struct {
Scale float32
}
func (im Image) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimens {
func (im Image) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimensions {
size := im.Src.Bounds()
wf, hf := float32(size.Dx()), float32(size.Dy())
var w, h int
@@ -49,5 +49,5 @@ func (im Image) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.D
}
paint.ImageOp{Src: im.Src, Rect: im.Rect}.Add(ops)
paint.PaintOp{Rect: dr}.Add(ops)
return layout.Dimens{Size: d, Baseline: d.Y}
return layout.Dimensions{Size: d, Baseline: d.Y}
}