Documentation
¶
Overview ¶
Package layout turns column weights into whole grid units and applies cell margins. Hamilton distributes units so the rounded values still add up to the row total.
Index ¶
- func ApplyCellMargins(cell entity.Cell, style *props.Cell) entity.Cell
- func BumpZerosWithoutOverflow(sizes []int, _ int) []int
- func DefaultGridSize() int
- func Hamilton(weights []float64, total int) []int
- func NormalizeGridSize(gridSize int) int
- func ProportionalUnits(weights []float64, total int) []int
- func UnitWidth(totalWidth float64, unit, gridSize int) float64
- func VerticalCellMargins(style *props.Cell) float64
- type ManualPlan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyCellMargins ¶
ApplyCellMargins returns the visible content box inside the allocated cell.
func BumpZerosWithoutOverflow ¶
BumpZerosWithoutOverflow ensures every zero size becomes at least 1 when a larger sibling can donate a unit, preserving the original sum.
func DefaultGridSize ¶
func DefaultGridSize() int
DefaultGridSize returns the number of grid units a row spans when the caller has not chosen one.
func Hamilton ¶
Hamilton distributes total integer units across items proportionally to their weights using the largest-remainder method.
func NormalizeGridSize ¶
NormalizeGridSize replaces a zero or negative grid size with the default.
func ProportionalUnits ¶
ProportionalUnits splits total units across items in proportion to weights.
func UnitWidth ¶
UnitWidth returns the width of a column spanning unit grid units out of gridSize, within totalWidth.
func VerticalCellMargins ¶
VerticalCellMargins returns the top and bottom margins added together, which is the height a cell loses to its own margins.
Types ¶
type ManualPlan ¶
type ManualPlan struct {
Units []int
GridSize int
TotalUnits int
Slack int
Overflow int
InvalidIndices []int
}
ManualPlan is the result of checking column sizes the caller set by hand. Slack is how many units are left over, Overflow how many the row is above the grid size, and InvalidIndices lists the columns whose size was not positive.
func ManualUnits ¶
func ManualUnits(units []int, gridSize int) ManualPlan
ManualUnits checks caller-supplied column sizes against the grid size and reports what it found, without changing the sizes.