Most widgets read their rect before they submit a node: they returned without a width, laid parts out from the measured rect, or painted with no node at all, so a column could not hold them. TreePlaceAhead asks the parent for the placed rect first; the widget lays out, paints and submits there, and its node is not placed or moved again. Alert, Banner, Breadcrumb, ButtonGroup, Carousel, Countdown, Keycap, Loading, LoadingScreen, ProgressRing, SvgIcon and Timeline place themselves this way, and Keycap draws its caps at its placed rect. widget-tree-test checks a keycap placed ahead lands where the column put it. The examples of those widgets and of ConfirmButton, CopyButton and HoldButton now draw in a Layout column. Shot digests, light theme, before -> after: alert 6a9598d13b12 -> 3d1654a7b0f9 banner 506158cb4840 -> 5e88c0cd5207 breadcrumb 06e733ee02b5 -> 80f42f379bc9 buttongroup 2837d933214d -> 8ac55d23e910 carousel 7d6ef6fc3f4a -> a61ee8229b79 confirmbutton 3d567fb7a29c -> e6d3f05fc4b0 copybutton c08cfc6132ab -> c61a372d25ad countdown b45d9dd0894c -> eaac1f2eb526 holdbutton ff643b518e5c -> c87c900c4d2d keycap dae61c9b364e -> 8b0aac195f74 loading c292e66a8e19 -> bff20371fb2a loadingscreen 03499f755726 -> 1b72c5fa37ba progressring 7c4f36e0a289 -> 4c363995d29d svgicon 1911b0f846eb -> d6cd03af7363 timeline 74e6f38f660b -> 62de0c7b4a0f
33 lines
1.3 KiB
Ziran
33 lines
1.3 KiB
Ziran
LoadingIndicator :: #import "kryon/loading_indicator";
|
|
Text :: #import "kryon/text";
|
|
Layout :: #import "kryon/layout";
|
|
#import "kryon/tree"
|
|
#import "kryon/geometry"
|
|
#import "kryon/session"
|
|
#import "kryon/frame_snapshot"
|
|
DemoTheme :: #import "kryon/Theme";
|
|
|
|
|
|
#program_export
|
|
Frame :: (session: Session, viewport: Rectangle) -> s32 {
|
|
page := Layout.Draw(session, Layout.Props.{.bounds = viewport, .padding = Layout.Gap(.ThemeMetricSpace5),
|
|
.gap = Layout.Gap(.ThemeMetricSpace4), .gap_override = true})
|
|
if !page.opened { return 0 }
|
|
Text.Draw(session, Text.Props.{.disabled = example_disabled, .bounds = .{height = 40}, .text = "Loading indicator", .size = 28})
|
|
input := CaptureFrameInput(session)
|
|
now := cast(float64)input.elapsed_ms / 1000.0
|
|
LoadingIndicator.Draw(session, LoadingIndicator.Props.{.bounds = .{height = 180}, .now = ifx (example_reduced_motion || DemoTheme.CurrentTheme().motion.reduced_motion) then 0.0 else now, .scale = 1.0})
|
|
unused End(session)
|
|
return 0
|
|
}
|
|
|
|
example_disabled: bool;
|
|
example_reduced_motion: bool;
|
|
|
|
// Hosts publish these options before the unchanged application entry point.
|
|
#program_export
|
|
SetExampleOptions :: (disabled: bool, reduced_motion: bool) {
|
|
example_disabled = disabled
|
|
example_reduced_motion = reduced_motion
|
|
}
|