Files
kryon/examples/button/button.zi
T
waozi 9994b820b0 Drop widget keys from the examples and older templates
Widgets are known by their call site now, so the examples and the pages,
tui and web templates stop numbering them: literal keys, `100 + index`
loop keys and the key parameters threaded through Label, Heading,
Paragraph and link helpers are gone. Keys stay where something points at
them: a guided tour's target, the gallery site's test handles and the
dashboard.
2026-11-22 23:07:25 -03:00

39 lines
1.5 KiB
Ziran

Button :: #import "kryon/button";
Text :: #import "kryon/text";
#import "kryon/control_props"
#import "kryon/geometry"
#import "kryon/session"
#import "std/number_text"
clicks: s32;
#program_export
Frame :: (session: Session, viewport: Rectangle) -> s32 {
Text.Draw(session, Text.Props.{.disabled = example_disabled, .bounds = .{viewport.x + 20.0, viewport.y + 16.0, viewport.width - 40.0, 40.0},
.text = "Button", .size = 28})
width := (viewport.width - 52.0) * 0.5
for tone: cast(s32)0..3 {
for emphasis: cast(s32)0..2 {
index := tone * 3 + emphasis
if Button.Draw(session, Button.Props.{.disabled = example_disabled, .bounds = .{viewport.x + 20.0 + cast(float32)(index % 2) * (width + 12.0),
viewport.y + 72.0 + cast(float32)(index / 2) * 56.0, width, 44.0},
.label = "Continue", .tone = cast(ButtonTone)tone,
.emphasis = cast(ButtonEmphasis)emphasis}) != 0 { clicks += 1 }
}
}
digits: [24]u8
Text.Draw(session, Text.Props.{.disabled = example_disabled, .bounds = .{viewport.x + 20.0, viewport.y + 420.0, viewport.width - 40.0, 36.0},
.text = FormatInteger(cast(s64)clicks, digits[:])})
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
}