mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
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:
+2
-2
@@ -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
@@ -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
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user