32 lines
1.4 KiB
Ziran
32 lines
1.4 KiB
Ziran
HoldButton :: #import "kryon/hold_button";
|
|
Text :: #import "kryon/text";
|
|
#import "kryon/geometry"
|
|
#import "kryon/session"
|
|
#import "kryon/frame_snapshot"
|
|
|
|
state: HoldButton.HoldButtonState;
|
|
fired: bool;
|
|
#program_export
|
|
Frame :: (session: Session, viewport: Rectangle) -> s32 {
|
|
Text.Draw(session, Text.Props.{.disabled = example_disabled, .key = 1, .bounds = .{viewport.x + 20.0, viewport.y + 16.0, viewport.width - 40.0, 40.0}, .text = "Hold button", .size = 28})
|
|
bounds := Rectangle.{viewport.x + 20.0, viewport.y + 76.0, viewport.width - 40.0, 180.0}
|
|
input := CaptureFrameInput(session)
|
|
now := cast(float64)input.elapsed_ms / 1000.0
|
|
result := HoldButton.Draw(session, HoldButton.Props.{.button = .{.disabled = example_disabled, .key = 10, .bounds = .{bounds.x, bounds.y, 240.0, 48.0}, .label = "Hold to confirm"}, .now = cast(float32)now, .duration = 1.0}, *state)
|
|
if result.fired { fired = true }
|
|
label := "Hold for one second"
|
|
if fired { label = "Confirmed" }
|
|
Text.Draw(session, Text.Props.{.disabled = example_disabled, .key = 11, .bounds = .{bounds.x, bounds.y + 68.0, bounds.width, 36.0}, .text = label})
|
|
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
|
|
}
|