Stack through StickyHeader, with behavior tests and gallery demos. kit gains Arrive, Settle (paint-time layout check) and Shade. Several actions return named ui.Element results; mygo vet forbids elements in structs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
13 lines
419 B
Go
13 lines
419 B
Go
package layout
|
|
|
|
import "github.com/egoist/mygo/ui"
|
|
|
|
// AspectBox holds width over height at ratio; it resizes smoothly.
|
|
func AspectBox(c *ui.Context, ratio float32, content func()) ui.Element {
|
|
if !finite(ratio) || ratio <= 0 {
|
|
panic("layout: AspectBox ratio must be finite and positive")
|
|
}
|
|
return ui.Box(c).FillWidth().AspectRatio(ratio).Clip().Transition(ui.ElementTransition{Size: true}).
|
|
Children(content)
|
|
}
|