Files
kryon/examples/23_inbe_app.kry
T
waozi f087c0654d krb v2: screen navigation — the whole app in one cartridge
KRB_FLAG_NAV buttons write a screen id to a state path on press
(cartridge-owned navigation; no host import). k2b compiles
NavButton(label, x, y, w, h, &state.screen, id). Screens are guarded
node ranges over one state field; examples/23_inbe_app.kry is Inner
Breeze as a single 6 MB cartridge — language, settings, and manual
screens with dropdowns, scroll, checkboxes, and the breath ring,
navigable end to end (verified: Next/Manual/Back transitions via
injected clicks). Scroll containers now draw a 1px outline instead
of a filled rect. All five exactness screens byte-identical
kry_sw == SDL.
2026-08-16 23:01:39 -03:00

69 lines
3.7 KiB
Plaintext

#import "kryon.h"
# Inner Breeze as ONE cartridge: three screens (language, settings,
# manual) with cartridge-owned navigation. NavButton writes the screen
# id to the `screen` state; each screen's widgets live under an
# if (screen == N) guard. No host C anywhere.
state {
screen: int = 0
language_index: int = 0
orientation_index: int = 0
fullscreen: int = 0
lang_scroll: int = 0
set_scroll: int = 0
man_scroll: int = 0
}
app "Inner Breeze" {
size 480 640
fps 60
frame main
}
frame main {
BeginDrawing()
ClearBackground(GetThemeBackground())
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale())
Background(GetThemeSurface())
if (screen == 0) {
Text("Language", ScaleUIPx(70), ScaleUIPx(28), UI_TEXT_24, GetThemeText())
Text("Choose your language", ScaleUIPx(40), ScaleUIPx(250), UI_TEXT_16, GetThemeIcon())
Dropdown(260, ScaleUIPx(40), ScaleUIPx(290), ScaleUIPx(340), ScaleUIPx(36), "English;Portugues;Espanol;Deutsch;Francais", &language_index)
if (language_index == 0) {
Text("Perfect for a calm start", ScaleUIPx(40), ScaleUIPx(380), UI_TEXT_16, GetThemeIcon())
} else {
Text("Otimo para um comeco calmo", ScaleUIPx(40), ScaleUIPx(380), UI_TEXT_16, GetThemeIcon())
}
NavButton("Next", ScaleUIPx(190), ScaleUIPx(430), ScaleUIPx(100), ScaleUIPx(40), &screen, 1)
} else {
if (screen == 1) {
Text("Settings", ScaleUIPx(70), ScaleUIPx(28), UI_TEXT_24, GetThemeText())
Text("Device", ScaleUIPx(40), ScaleUIPx(80), UI_TEXT_16, GetThemeIcon())
Scroll(ScaleUIPx(40), ScaleUIPx(110), ScaleUIPx(400), ScaleUIPx(440), ScaleUIPx(560), &set_scroll)
Text("Language", ScaleUIPx(40), ScaleUIPx(120), UI_TEXT_16, GetThemeText())
Dropdown(101, ScaleUIPx(40), ScaleUIPx(146), ScaleUIPx(340), ScaleUIPx(36), "System;English;Portugues", &language_index)
Text("Orientation", ScaleUIPx(40), ScaleUIPx(230), UI_TEXT_16, GetThemeText())
Dropdown(103, ScaleUIPx(40), ScaleUIPx(256), ScaleUIPx(340), ScaleUIPx(36), "System;Portrait;Landscape", &orientation_index)
Checkbox(0, ScaleUIPx(40), ScaleUIPx(340), "Fullscreen", &fullscreen)
EndScroll()
NavButton("Manual", ScaleUIPx(60), ScaleUIPx(570), ScaleUIPx(100), ScaleUIPx(40), &screen, 2)
NavButton("Back", ScaleUIPx(320), ScaleUIPx(570), ScaleUIPx(100), ScaleUIPx(40), &screen, 0)
} else {
Text("Manual", ScaleUIPx(70), ScaleUIPx(28), UI_TEXT_24, GetThemeText())
Scroll(ScaleUIPx(24), ScaleUIPx(80), ScaleUIPx(432), ScaleUIPx(470), ScaleUIPx(700), &man_scroll)
Text("Welcome to Inner Breeze", ScaleUIPx(24), ScaleUIPx(90), UI_TEXT_16, GetThemeText())
Text("Breathing practices with gentle visual and audio cues.", ScaleUIPx(24), ScaleUIPx(120), UI_TEXT_16, GetThemeIcon())
Text("Box breathing: four equal phases around a square.", ScaleUIPx(24), ScaleUIPx(190), UI_TEXT_16, GetThemeIcon())
DrawCircleV((Vector2){ScaleUIPx(240), ScaleUIPx(330)}, ScaleUIPx(50), (Color){0x2d, 0x4d, 0x7b, 0xff})
DrawRing((Vector2){ScaleUIPx(240), ScaleUIPx(330)}, ScaleUIPx(56), ScaleUIPx(64), 0.0f, 360.0f, 0, (Color){0x70, 0x90, 0xc0, 0xff})
Text("Always practice seated and never near water.", ScaleUIPx(24), ScaleUIPx(440), UI_TEXT_16, GetThemeIcon())
Text("Habits build streaks; missing one day is fine.", ScaleUIPx(24), ScaleUIPx(510), UI_TEXT_16, GetThemeIcon())
EndScroll()
NavButton("Back", ScaleUIPx(190), ScaleUIPx(570), ScaleUIPx(100), ScaleUIPx(40), &screen, 1)
}
}
EndUIFocus()
EndDrawing()
}