main is the only program entry. Frame stays an ordinary function that apps pass to App.Run; the frame-entry export mechanism (frame_entry, ProjectFrame binds, KRYON_FRAME_ENTRY, *_run.zi hosts) is gone. The pixmap, dom, terminal, zx and android frame loops are now frames_*.zi modules that App.Run selects. Consumer tests and fixtures build their own shot programs through the kryon package exports, and the desktop project probe imports Window explicitly. General #program_export component exports stay.
41 lines
1.9 KiB
Ziran
41 lines
1.9 KiB
Ziran
App :: #import "kryon/app";
|
|
Button :: #import "kryon/button";
|
|
ProgressRing :: #import "kryon/progress_ring";
|
|
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";
|
|
|
|
state: ProgressRing.ProgressRingState;
|
|
value: float32 = 0.25;
|
|
Frame :: (frame: App.Frame) {
|
|
session := Session.{.slot = frame.slot, .epoch = frame.epoch}
|
|
viewport := frame.viewport
|
|
page := Layout.Draw(session, Layout.Props.{.bounds = viewport, .padding = Layout.Gap(.ThemeMetricSpace5),
|
|
.gap = Layout.Gap(.ThemeMetricSpace4), .gap_override = true})
|
|
if !page.opened { return }
|
|
Text.Draw(session, Text.Props.{.disabled = example_disabled, .bounds = .{height = 40}, .text = "Progress ring", .size = 28})
|
|
input := CaptureFrameInput(session)
|
|
now := cast(float64)input.elapsed_ms / 1000.0
|
|
ProgressRing.ProgressRingAdvance(*state, value, cast(float32)input.delta_ms / 1000.0, (example_reduced_motion || DemoTheme.CurrentTheme().motion.reduced_motion))
|
|
props: ProgressRing.Props = .{.bounds = .{width = 180, height = 180}, .label = "Progress", .value = value, .show_percent = true, .reduced_motion = (example_reduced_motion || DemoTheme.CurrentTheme().motion.reduced_motion)}
|
|
ProgressRing.Draw(session, props, *state)
|
|
if Button.Draw(session, Button.Props.{.disabled = example_disabled, .bounds = .{width = 160, height = 40}, .label = "Advance"}) != 0 { value += 0.25; if value > 1.0 { value = 0.0 } }
|
|
unused End(session)
|
|
return
|
|
}
|
|
|
|
example_disabled: bool;
|
|
example_reduced_motion: bool;
|
|
|
|
// The gallery host calls this before drawing the example's frames.
|
|
SetExampleOptions :: (disabled: bool, reduced_motion: bool) {
|
|
example_disabled = disabled
|
|
example_reduced_motion = reduced_motion
|
|
}
|
|
|
|
main :: () -> s32 { return App.Run(App.Window.{.title = "progressring"}, Frame) }
|