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.
50 lines
1.8 KiB
Ziran
50 lines
1.8 KiB
Ziran
App :: #import "kryon/app";
|
|
Button :: #import "kryon/button";
|
|
Layout :: #import "kryon/layout";
|
|
Text :: #import "kryon/text";
|
|
#import "kryon/grid_props"
|
|
#import "kryon/tree"
|
|
#import "kryon/control_props"
|
|
#import "kryon/geometry"
|
|
#import "kryon/session"
|
|
#import "std/number_text"
|
|
|
|
clicks: s32;
|
|
|
|
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 = "Button", .size = 28})
|
|
// Every tone in every emphasis, two to a row.
|
|
grid := Layout.Grid(session, GridProps.{.columns = 2, .gap = Layout.Gap(.ThemeMetricSpace3)})
|
|
if grid.container.opened {
|
|
for tone: cast(s32)0..3 {
|
|
for emphasis: cast(s32)0..2 {
|
|
if Button.Draw(session, Button.Props.{.disabled = example_disabled, .bounds = .{height = 44},
|
|
.label = "Continue", .tone = cast(ButtonTone)tone,
|
|
.emphasis = cast(ButtonEmphasis)emphasis}) != 0 { clicks += 1 }
|
|
}
|
|
}
|
|
unused End(session)
|
|
}
|
|
digits: [24]u8
|
|
Text.Draw(session, Text.Props.{.disabled = example_disabled, .bounds = .{height = 36},
|
|
.text = FormatInteger(cast(s64)clicks, digits[:])})
|
|
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 = "button"}, Frame) }
|