layout

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCellMargins

func ApplyCellMargins(cell entity.Cell, style *props.Cell) entity.Cell

ApplyCellMargins returns the visible content box inside the allocated cell.

func BumpZerosWithoutOverflow

func BumpZerosWithoutOverflow(sizes []int, _ int) []int

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

func Hamilton(weights []float64, total int) []int

Hamilton distributes total integer units across items proportionally to their weights using the largest-remainder method.

func NormalizeGridSize

func NormalizeGridSize(gridSize int) int

NormalizeGridSize replaces a zero or negative grid size with the default.

func ProportionalUnits

func ProportionalUnits(weights []float64, total int) []int

ProportionalUnits splits total units across items in proportion to weights.

func UnitWidth

func UnitWidth(totalWidth float64, unit, gridSize int) float64

UnitWidth returns the width of a column spanning unit grid units out of gridSize, within totalWidth.

func VerticalCellMargins

func VerticalCellMargins(style *props.Cell) float64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL