WIP components (as built)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 15:51:57 -04:00
1 parent 299e5fe720
commit 4b8fdf8df7
71 files changed
+3241 -468

No files matched your search

+7 -6
View File
@@ -4,27 +4,28 @@ import (
"time"
"github.com/egoist/mygo/ui"
"mujicaui/theme"
)
// LayoutTransitionOptions configure a LayoutTransition.
type LayoutTransitionOptions struct {
// Duration of a change; zero means 200 ms.
// Duration of a change; zero means StateDuration.
Duration time.Duration
// Row lays the content in a row instead of a column.
// Row lays the content in a row.
Row bool
// Clip hides content outside the box while it resizes.
Clip bool
}
// LayoutTransition holds content whose size and place animate from where they were (FLIP).
// Siblings that the change moves need a LayoutTransition of their own to move in step.
// LayoutTransition animates its size and place when they change.
func LayoutTransition(c *ui.Context, opts LayoutTransitionOptions, content func()) *ui.Element {
if opts.Duration < 0 {
panic("mujica: LayoutTransition Duration is negative")
}
d := opts.Duration
if d == 0 {
d = 200 * time.Millisecond
d = theme.StateDuration
}
box := ui.Column(c).AlignItems(ui.Stretch)
if opts.Row {
@@ -33,7 +34,7 @@ func LayoutTransition(c *ui.Context, opts LayoutTransitionOptions, content func(
if opts.Clip {
box.Clip()
}
box.Transition(ui.ElementTransition{Duration: d, Position: true, Size: true})
box.Transition(ui.ElementTransition{Duration: Motion(c, d), Position: true, Size: true})
if content != nil {
box.Children(content)
}