Add layout components 0001-0025
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>
This commit is contained in:
1 parent
b34562333b
commit
4efaf2680f
41 files changed
+1765
-11
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package layout
|
||||
|
||||
import (
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/kit"
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
// AutoGrid fits as many columns as minWidth allows.
|
||||
func AutoGrid(c *ui.Context, minWidth float32, items []func()) ui.Element {
|
||||
if !finite(minWidth) || minWidth <= 0 {
|
||||
panic("layout: AutoGrid minWidth must be finite and positive")
|
||||
}
|
||||
gap := c.Theme().Space(3)
|
||||
root := ui.Grid(c).FillWidth().Gap(gap)
|
||||
w := root.LayoutBounds().W
|
||||
kit.Settle(c, root, []float32{w}, func() []float32 { return []float32{root.LayoutBounds().W} })
|
||||
return root.Columns(max(1, int((w+gap)/(minWidth+gap)))).Children(func() {
|
||||
for i, it := range items {
|
||||
ui.Box(c).Key(i).Transition(ui.ElementTransition{Position: true, Size: true}).Children(it)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user