Commit Graph
110 Commits
Author SHA1 Message Date
waozi 5da8134ad0 Consolidate Kry language documentation 2026-08-19 18:31:28 -03:00
waozi 668f4d16f1 Document Kry language and publish benchmarks 2026-08-19 18:21:07 -03:00
waozi 2726d54f72 Advance Kry compile-time checks and expression KIR 2026-08-19 18:12:26 -03:00
waozi a585f1ced5 Implement Canvas WebAudio backend 2026-08-19 16:35:44 -03:00
waozi 27ce4cbb4a Add website backend and widget matrices 2026-08-19 16:03:56 -03:00
waozi 8f8a2736e6 Align installed desktop metadata names 2026-08-19 15:53:17 -03:00
waozi e0c588cd23 Add Linux desktop integration helpers 2026-08-19 15:47:56 -03:00
waozi 7b6048a9df canvas: split the backend into per-concern sources
canvas_backend.c (1882 lines) becomes canvas_window/input/draw/texture/
text/os/audio.c plus canvas_internal.h, one file per banner section the
monolith had already grown. Pure code motion: the node call-sequence
gate records an identical 413-call trace before and after.

The canvas branches in Makefile, mk/common.mk, and examples/Makefile no
longer append the backend file on top of the src/ find sweep — that
would have compiled every canvas TU twice. docs: BACKENDS.md path and
empty-TU wording, FEATURE_MATRIX.md stale 'approximated' note.
2026-08-18 22:29:08 -03:00
waozi dae552ec17 krb-run: remove the Linux framebuffer presentation backend
The fb host (mmap of /dev/fb0 or a raw-file stand-in, xrgb8888/rgb565
dirty-rect conversion) served no user: raylib covers desktop
presentation, the Canvas2D backend covers native web, and TUI is the
remaining terminal story. Drop the --backend fb / --fb-device /
--fb-format surface; krb-run keeps the headless PNG/recording flow the
conformance tests drive.
2026-08-18 18:16:43 -03:00
waozi eb9967ce29 theme: drop the dedicated Aero palette, keep the style palette-agnostic
The Aero widget style derives its glass tints from whichever palette is
active, so a 13th palette entry was redundant. Remove THEME_AERO (and
its ini mirrors, locale label and picker slot); the style now defaults
to Sky. Saved theme ids beyond the shrunken count normalize through the
existing out-of-range fallback.
2026-08-18 18:08:54 -03:00
waozi f3dc8a6f3e canvas: real rounded rects, annulus rings, full tint, clipboard mirror
Rounded rectangles draw through ctx.roundRect with an arcTo fallback
(radius from raylib's roundness semantics), rings become true filled
annulus segments (outer arc forward, inner arc back, even-odd fill),
and vertical gradients now carry both full colors instead of reusing
the top RGB for the bottom stop.

Texture tinting is a real multiply: cached per (texture, tint) canvases
do multiply + destination-in, so RGBA tints on glyph atlases and render
targets composite exactly — pixel-verified in a real browser, where the
tinted sample read back the precise multiplied color.

The clipboard keeps a mirror of the last text the app wrote and attempts
the async browser write fire-and-forget: copy/paste round-trips within
the app; cross-app paste stays behind the sync API.

The node gate now asserts roundRect, the annulus arcs, and the
dual-stop gradient alongside the existing sequence.
2026-08-18 17:47:47 -03:00
waozi dc86744139 k2g: reach Go parity on the Runtime surface
The Runtime interface now covers every widget family go/kryui itself
exposes, not just the .kry whitelist: the positional controls
(GenericButton, TextButton, LocaleDropdown, VerticalSlider, CanvasGrid,
SelectableText, ShowUIToast(For)), the Props widgets (TextInputControl,
ReadonlyTextBox, TextArea, Radio, Spinbox, Combobox, LabelFrame,
Notebook, PanedView, Collapsible, ListBox, SourceView, TableView), the
dialogs, the canvas (BeginUICanvas/EndUICanvas), the Tk layout helpers
(BeginUIFrameBox, UIFramePack, UIGridCell, UIPlace), and theme control
(SetCurrentTheme/SetThemeDarkMode/SetThemeStyle with THEME_STYLE_*
constants under their C names).

k2g lowers .kry array declarations to Go slices at the use site
(state and local 'name: [N] const char*' references emit 'name[:]'),
accepts UICanvas literals like Props/Spec, and maps the canvas/Tk
handle types. The syntax gate now exercises the whole parity set and
still compiles the output against the real cgo runtime.

Honest remainder, noted in the matrix: DropdownEx's rich option
arrays, forward-goto-over-declarations, and C pointer/Texture2D
values stay outside what .kry can express.
2026-08-18 17:06:20 -03:00
waozi 4669ffb1b3 canvas: implement the HTML5 Canvas2D Tier A backend
src/backend/canvas_backend.c now exists: the full required surface
against a 2d canvas context through EM_JS. Draws are canvas paths,
textures are offscreen canvases (putImageData/drawImage stay
synchronous), text is glyph atlases rasterized from FontFace data
(EM_ASYNC_JS awaits face loading), input flows through the
KryonBackendRaw_* hooks fed by JS listeners, and the shared front-ends
(kry_instance, kry_screenshot, kry_input) are honored via the
KryonRaylibBackend_* seam names. Images decode through kryon's own
kry_sw PNG decoder; no raylib anywhere in the link.

The app while-loop survives the browser via -sASYNCIFY with a frame-end
yield. make canvas-test builds a complete app with this backend under
emcc and verifies the draw-call sequence in node against a recording
Canvas2D shim (glyph rasterize, atlas upload, and per-glyph drawImage
included); it skips cleanly where emcc is absent.

Approximations documented in BACKENDS.md: square rounded rects,
mid-radius ring strokes, no clipboard bridge, alpha-only tint.
2026-08-18 17:06:20 -03:00
waozi 78e9c369ca docs: k2c column, bare widget names, and a permanent HTML renderer
The widget matrix gains an explicit k2c column (always equal to C —
.kry reaches the whole API through plain call statements; the note was
prose-only before) and drops every DrawUI*-prefixed spelling in favor
of the bare widget names.

go/kryui now aliases the remaining prefixed calls (TextInputControl,
GenericButton, TextButton, ReadonlyTextBox, Dropdown(DropdownEx,
LocaleDropdown), VerticalSlider, Checkbox, ToggleSwitch, Hyperlink,
IconBtn) so the bare surface is complete; the C-mirroring spellings
stay as the definitions for existing callers.

scripts/feature-matrix-html.py renders the browsable color-coded view
(regenerate after every matrix change); the current HTML is committed
alongside.
2026-08-18 16:55:59 -03:00
waozi eac6c16ea4 docs: cover the Aero style with an example, tests and API notes
- examples/30_aero.kry: all-widget showcase pinned to Aero with live
  palette/mode switching; the theme example's style clamp now accepts
  THEME_STYLE_AERO
- examples/Makefile: the generic codegen rule ran k2b where it meant
  k2c (from the kc->k2c rename), so examples with calls outside the
  KRB vocabulary could not generate their C at all
- ui_tk_test: Aero round-trip, tokens, palette id/label and scheme
  derivation checks
- API.md: document the style, UIAeroScheme and the THEME_AERO id
2026-08-18 16:10:15 -03:00
waozi 8c8bbb0dfa theme: add the Aero widget style
Add THEME_STYLE_AERO after MATERIAL so existing app clamps treat it as
invalid (SYSTEM fallback) until they opt in. The style renders Windows
Vista/7 glass from plain primitives only - translucent fills, gloss
highlights, hover glow, layered shadows, inset fields, gradient tracks -
so every backend (raylib, Android, web, software, null) draws the same
picture.

- UIStyleTokens preset: 4px/8px radii, translucent control/panel alpha,
  gloss shine, soft shadow offset
- New src/ui/ui_aero.c: UIAeroScheme derived from the active palette
  (GetUIAeroScheme) plus paint helpers for controls, glass panels,
  inset fields and gradient tracks
- ui_draw_control_background/ui_draw_box_background route Aero through
  the new helpers, so shared-path widgets pick glass up for free
- New THEME_AERO palette (13th, the style default) with sky-glass light
  and slate-blue dark scopes + themes/aero*.ini mirrors
- Theme settings picker offers the style; locale gains theme_aero
- Go binding ThemeStyleAero
2026-08-18 16:10:15 -03:00
waozi ecaa07b4f6 k2g: cover the full widget whitelist on the Go Runtime interface
Grow go/kryui so every whitelisted .kry widget statement lowers and
compiles through k2g: new Props/Spec types (PictureProps,
UIParagraphSpec, BottomNav/TopNav/Toolbar), cgo wrappers (TextInRect,
Paragraph, TextLines, Bevel, IconTexture by icon type, Picture, Toggle,
Modal, TitleBar, nav bars), the raylib color palette and picture-fit
constants under their C names, and the matching Runtime methods
(including Row/Stack, Key, Fade, theme getters, optional-border Rect).

k2g lowers positional Props/Spec literals through a C field-order table,
maps Id to ID, converts int-typed bool Props fields, and resolves the
color/fit constants. The syntax gate now exercises every widget and
still compiles the generated Go against the real cgo runtime.
2026-08-18 16:10:15 -03:00
waozi 12e862e70b docs: add FEATURE_MATRIX.md mapping widgets and features across targets and backends
Widget-by-widget support for the C (.kry->k2c), Go (k2g/go/kryui), and KRB
(k2b) targets, cross-cutting feature coverage, and the Tier A surface /
Tier B cartridge-host backend inventory with per-platform raylib flavors.
Cross-linked from README.md and docs/BACKENDS.md.
2026-08-18 15:40:40 -03:00
waozi 66fb62de40 ui: keep font atlases immutable while typing 2026-08-17 21:35:43 -03:00
waozi 537912b0a6 k2g: host bridge, enums, switch and full for headers
k2g now compiles real declarative apps, not just the smoke subset:

- '#extern "pkg.Fn"' lowers to a generated <Guard>Host interface with a
  Set<Guard>Host setter; extern calls become host.Method(...) with numeric
  argument conversions so int/long/float widening always compiles. The Kir
  frontend keeps the quoted host symbol on KirFunction.extern_target.
- 'Name :: enum' lowers to untyped Go constants with C counter semantics
  (explicit literal resets the counter; explicit expressions chain +1), and
  bare member names rewrite to the qualified Go constant at every use site.
- switch bodies translate: case/default labels, including brace-open forms
  and same-line bodies; Go auto-break replaces C fallthrough by design.
- C-style three-clause for headers ('for int i = 0; i < n; i++') become
  Go for headers with typed initializers; Go-style headers pass through.
- 'guard cond' lowers to a plain if (the body is the exit path).
- Assignments lower as statements; '} else {' chains emit on one line.
- Extended C-to-Go type map (short/size_t/long long/unsigned variants,
  char** slices, [N]T arrays, T* pointers, const stripping) removes the
  any-fallback for real signatures.
- Output is flat: nested source trees no longer nest Go files into
  separate packages; duplicate basenames are rejected.

go/kryui grows the widget surface declarative apps need: TabBar (real
DrawUITabBar cgo wrapper with plain string labels), Rect, RectGradientH,
Line, Progress, Checkbox, Dropdown and screen-size getters on the k2g
Runtime interface, plus DropdownLabels for ';' option lists.

tests/k2g_syntax_test.sh now covers the whole subset and keeps the
compile-against-the-real-runtime gate; the full suite passes.
2026-08-17 21:34:07 -03:00
waozi f8f5cd4c71 ui: add retained declarative tree and typed events 2026-08-17 18:55:05 -03:00
waozi 525e7aa1cb ui: add fixed-subset font sources 2026-08-17 17:35:16 -03:00
waozi 99bd4a01a9 ui: finalize deferred overlays at frame end 2026-08-17 12:20:36 -03:00
waozi 6d9702870a atlas: sub-pixel advances; language cartridge from traced values
KFA1 glyph advances are now 1/256-px fixed point ((int)(adv*scale*256
+0.5) at bake; single rounding at draw/measure, matching ui_text.c's
float path). Spec updated.

The instrumented title run exposed the real screen content: the title
is 'Choose Language' (locale key), not 'Language' — resolving the
width anomaly. The cartridge now uses the traced strings, sizes,
and positions ('Choose Language' fs24 phys(159,32), 'Language' fs16
(45,273), 'Next' fs12 (230,377)); per-mille scale verified in-binary
(scale=1125, scale_px(141)=159).

Native parity 5765 -> 5179/307200 (98.3%). The residual is the
classic last mile: every glyph edge sits one sub-pixel off between
an exact integer blit and GL quad rasterization — closing it means
emulating the GPU's quad fill/sample rule in kry_sw. Cross-engine
8/8 byte-identical (after rebuilding the stale SDL host); suites and
goldens green.
2026-08-17 07:12:25 -03:00
waozi f8d8c7fd1a k2g: .kry -> Go backend on the shared Kir frontend
Third backend alongside k2c/k2b: k2g lowers a KirProgram to Go source
that drives a Go kryon runtime (the cgo surface binding app uses), so
Go-native apps can be written in .kry. One frontend, three backends —
kry -> kir -> {c, krb, go}.

v1 fully translates the declarative subset: state blocks (Go struct +
instance), app metadata (generated main loop), frames, widget/surface
calls (rt.-qualified), compound literals (Vector2/Rectangle/Color),
scalar casts, hex/float literals, and state-field references including
address-of for scroll offsets. Imperative constructs are best-effort;
unsupported ones are emitted as commented TODOs rather than miscompiled.

Usage: k2g [--no-main] [--pkg NAME] [--runtime IMPORT] --root DIR -o DIR file.kry ...
Smoke-tested by tests/k2g_syntax_test.sh in 'make test'.
2026-08-16 23:51:09 -03:00
waozi e9fe1e17e0 krb v2: dropdown controls
KRB_CTRL_DROPDOWN (kind 4) implemented end to end: the control record's
reserved options_off/option_count now carry consecutive NUL-terminated
option strings (k2b appends them without interning so they stay
contiguous; Dropdown(id,x,y,w,"a;b;c",&val)). Click toggles the popup,
clicking a row writes the selected index to the bound int and closes.
Loader initializes the open-dropdown slot to -1 (0 is a valid index).
2026-08-16 22:11:03 -03:00
waozi cb6faf430d krb v2: scroll containers
SCROLL node (type 12): viewport bounds, content height in font_size,
mounted pixel offset at name_off. Children (parent = scroll index)
draw translated by -offset and clipped to the viewport; a new
optional KryBackend.wheel entry drives the offset when the pointer is
over the viewport, clamped to [0, content_h - h]. Implemented in
kry_sw (+KrySwWheel injection), the raylib surface backend, the null
and recorder backends; krb-sdl maps SDL_MOUSEWHEEL, krb-web exposes
krb_web_wheel from canvas wheel events. k2b compiles

  Scroll(x, y, w, h, contentH, &state.off) ... EndScroll()

bracketing child widgets (parent-linked). Fixed a compounding-offset
bug where draw_tree's origin was mutated across children.
2026-08-16 22:03:44 -03:00
waozi c1be0cb82d k2b+engines: KFA1 glyph atlas — antialiased Noto text in cartridges
- k2b bakes a per-cartridge atlas (stb_truetype over the vendored
  NotoSans) covering the cartridge's charset at its used pixel sizes,
  embeds it as the kind 1 asset '@atlas'. K2B_FONT overrides the face.
- kry_sw renders atlas text: UTF-8 decoding, per-glyph advances,
  source-over coverage blending, nearest-size scaling; measure uses
  real advance widths. KrySwSetAtlas installs it; krb-run, krb-sdl,
  and krb-web all load '@atlas' after KrbLoad.
- Cartridge cap raised 64 KiB -> 16 MiB (output buffer static) to fit
  atlases/images; krb_cartridge_test budget adjusted. Engine goldens
  regenerated (atlas advances change text layout).
- Fixed on the way: atlas record stride (18 bytes), pack buffer
  ownership, and a realloc'd-header write in the baker.

Verified: 'Ag' at 24px renders as antialiased glyphs from embedded
bytes; full krb suite green.
2026-08-16 21:59:11 -03:00
waozi f17bc26987 krb v2: embedded asset section + texture_rgba blit
Cartridges can now carry their pictures: a v2 asset section (header
offset 28 = asset_bytes) after controls[] holds a directory of
20-byte entries (path, absolute data offset, size, kind, w, h) plus
blobs. KrbAssetFind looks paths up; a PICTURE node whose path is
embedded renders from cartridge pixels through the new optional
KryBackend.texture_rgba (nearest-neighbor scaled, tint-modulated,
clipped) — kry_sw implements it, so krb-run, krb-web, and krb-sdl all
get embedded assets. Non-embedded paths still fall back to host
texture loading. kinds: 0 raw RGBA8, 1 reserved for the glyph atlas.

tests/krb_asset_test.c proves lookup + 2x2->8x8 scaled, tinted blit
with correct bounds; spec updated in KRB_FORMAT.md. k2b embedding of
decoded image files is the follow-up.
2026-08-16 21:29:13 -03:00
waozi d35b412a96 docs: KRB_FORMAT.md rewritten as an exact byte-level specification
Every record now carries explicit field offsets and sizes (header 32B,
node 28B, control 24B), section layout formulas, encoding rules
(little-endian, string references, absolute prog offsets), validation
requirements, per-node-type rendering and interaction semantics, full
VM opcode table with stack/jump rules, limits, and the host surface a
renderer must provide — enough to write an independent parser and
renderer from the document alone.
2026-08-16 21:07:52 -03:00
waozi 89dc220fda krb v2: in-cartridge logic VM + circle/ring geometry nodes
The plan-07 core: cartridges stop being static pictures.

- New v2 opcodes: a 16-deep int stack machine (PUSH_CONST/PUSH_PATH/
  POP_STORE, ADD..GE, JMP/JZ, TIME) plus OP_DRAW_NODE so UI can be
  conditional on mounted state. Loader accepts v1 and v2; k2b now
  writes version 2.
- New node types CIRCLE (center+radius) and RING (annulus), the shapes
  the inbe breath visualizer needs; k2b parses DrawCircleV/DrawRing
  (with (Color){r,g,b,a} literals). KryBackend gains optional circle/
  ring entries — implemented in kry_sw, the raylib surface backend,
  the null backend, and forwarded+logged by the recorder.
- tests/krb_logic_test.c: hand-assembled v2 cartridge proving counter
  increments per frame, conditional node visibility across frames,
  circle/ring rasterization bounds, and TIME. Engine golden test passes
  unchanged on v2 output (render back-compat).
- KRB_FORMAT.md documents v2 and the R>=0x80 theme-slot color caveat.
2026-08-16 20:37:44 -03:00
waozi f817374347 docs: plan 11 — renderer engines for KRB cartridges
Tier-B engines behind the KryBackend vtable: conformance harness,
kry_sw software rasterizer, web canvas, Android, ESP32, plus profiles
and the pre-baked asset pipeline.
2026-08-16 19:48:02 -03:00
waozi 3a06ea6004 mem: diagnostics; ui_text: single-tier font rasters; tray: lazy GTK
- KryonMemReport/KryonMemDebugEnabled (KRYON_MEM_DEBUG) print RSS and the
glibc arena breakdown; UIFontMemoryReport prints per-font raster stats.
- Source fonts rasterize once at the DPI-scaled base size plus one lazily
built large tier, replacing the 8-slot per-size cache. New codepoints
batch into at most one rebuild per frame per font, and atlas build churn
is returned via malloc_trim on glibc.
- KRYON_TRAY_GTK_DL: GTK_STATUS_ICON tray resolves GTK via dlopen (gtk_dl
shim) so tray-less processes never map the GTK chain.
2026-08-16 17:13:46 -03:00
waozi ccec103ebc k2b: report call kinds the KRB vocabulary cannot express
A cartridge that comes out thin (inbe's pet screen: an egg widget,
locale text, Paragraphs) was silently missing everything k2b cannot
lower. The builder now tracks dropped call kinds per file and prints
one stderr line: 'k2b: <file>: N call kinds not in KRB: Paragraph x2
draw_egg x1 ...' - pet_screen.kry reports seven, which is the honest
content of the gap.
2026-08-16 07:52:09 -05:00
waozi 3eb82d33b4 site: add Discord and Telegram community links
Footer gains a Community column (Discord invite, Telegram channel) on
the landing page and the same links under Ecosystem in the API page;
the site's link list mentions them with what they're for. Landed page:
https://discord.gg/ep7gCWzHJD and https://t.me/kryonlabs_com.
2026-08-15 18:37:13 -05:00
waozi 577681423a kc is fully gone: CHANGELOG/docs/comments now say k2c
- k2b drops its KC_* macro aliases (56 uses) for the KIR_* names.
- CHANGELOG, plan docs, examples README, scene-source comments all say
  k2c; the removed 512-statement cap entry no longer names the dead
  KC_BODY_MAX constant.
- k2c_lower: fix '&&' within '||' precedence in the member-access skip
  and three scope_stack[scope_top++] sequence-point UBs that -Wextra
  on the Android host build surfaced.
2026-08-14 21:00:34 -05:00
waozi e2df69c01b Remove the last kc remnants
- docs/KC_PARSER_PLAN.md: the pre-split kc parser plan — the parser it
  describes is deleted; the shipped architecture (kir frontend, k2c/k2b
  backends) lives in the sources.
- stale build/*/bin/kc binaries from before the rename.
- Comments/variable names still saying 'kc' in scene_tree.h,
  kry_animation.h, kryon-preview, k2b, krait's GNUmakefile/native_krb.c.
  CHANGELOG history entries keep the name each release actually shipped
  with.
2026-08-14 17:05:04 -05:00
waozi 2f11e1e773 Rename kc to k2c (kry-to-C compiler)
The .kry->C compiler is now k2c, not kc. This is the first step toward making
Kir the single source of truth (k2c and k2b will both lower from Kir).

- cmd/kc/ -> cmd/k2c/ (directory moved; internal file names unchanged).
- Makefile: KC -> K2C, LEGACY_KC -> LEGACY_K2C, build/bin/kc -> build/bin/k2c.
- tests/kc_syntax_test.sh -> tests/k2c_syntax_test.sh (default binary updated).
- examples/Makefile: KC -> K2C; the two stale --emit-krb lines now use k2b.
- make test green (k2c_syntax_test passes via k2c).
2026-08-13 20:09:53 -05:00
waozi ca90d232ed Improve site text readability 2026-08-13 13:31:46 -03:00
waozi d1d6c7a6ec Add Kryon browser IDE 2026-08-13 13:16:14 -03:00
waozi c2ea589251 Improve Kryon site button contrast 2026-08-13 12:25:44 -03:00
waozi ef5d313e16 Fix CI links and platform icons 2026-08-13 12:12:34 -03:00
waozi c89e034ef4 Add k2ir tool scaffold 2026-08-13 11:31:30 -03:00
waozi d84db61262 Document KIR compiler roadmap 2026-08-13 10:36:32 -03:00
waozi 115a104457 krb: controls[] section + range widgets (Slider, VerticalSlider, Spinbox)
Add a controls[] table to the format for interactive widgets whose args don't
fit the 28-byte node. The header's reserved field becomes control_count
(backward compatible: old files have 0 -> no section). Each 24-byte KrbControl
record carries kind/id/min/max/step + value_off/label_off/options_off; a
KRB_NODE_CONTROL (9) node references it by bind_slot.

Range widgets bind a state{} field (value_off), render with KryBackend
primitives, and update the value on interaction:
- Slider / VerticalSlider: a held drag sets the value across [min,max].
- Spinbox: a click steps by 'step' (clamped), left half down / right half up.

The cartridge owns the value (read/write via the mount), like Checkbox/Toggle.
Dropdown/Combobox (need a state-array option parser) and by-value Radio/TabBar
remain deferred.

Verified: 03_theme.kry emits a Slider as a CONTROL node + control record;
krb_mount_test builds a SLIDER cartridge and asserts a drag sets 0->80 (and a
no-drag frame leaves it); make test green. KRB_FORMAT.md documents the
controls[] section and the CONTROL node.
2026-08-13 06:50:14 -05:00
waozi 0397d5e6c1 krb: interactive Checkbox + Toggle widgets (value-bound, self-contained toggle)
Add the first interactive cartridge widgets. CHECKBOX (7) and TOGGLE (8) bind
to a state{} field by name (the widget's &val arg -> name_off), render with
KryBackend primitives (box outline + check / track + thumb + label), and on an
in-bounds mouse press flip the value back through the mount. The cartridge
owns the toggle (no host handler, unlike BUTTON) — the host just reads the
resulting state. Only state{} fields bind (what the host mounts).

These two fit the existing 28-byte node (path/label/id map to spare fields);
range/options widgets (Slider/Spinbox/Dropdown/Combobox) and by-value widgets
(Radio/TabBar) need a controls[] args section and are deferred.

Verified: krb_mount_test builds a CHECKBOX, mounts a value, and asserts an
in-bounds press flips 0->1 (and no-press leaves it); the cartridge frame
fixture now carries a Checkbox and asserts its value path lands in the string
table; make test green.
2026-08-13 06:27:36 -05:00
waozi 2b9e54f128 krb compiler: widen widget coverage (color literals, Line/Separator/Bevel/TextInRect, Picture)
The .kry->.krb slice only captured Background/Text/Rect/Button and collapsed
every non-theme color to opaque black. Broaden it:

- parse_color now understands hex (0xRRGGBBAA / 0xRRGGBB) and the raylib color
  sentinels (WHITE/BLACK/BLANK/RED/GREEN/BLUE/...), not just theme getters.
- New parsers map static widgets onto existing node types: Separator (themed
  rail RECT), Line (axis-aligned bounding RECT), Bevel (light-face RECT),
  TextInRect (TEXT). A shared node_rect() helper parses (Rectangle){...}.
- Picture becomes a first-class node type KRB_NODE_PICTURE=6 (additive; old
  loaders hit default:break). text_off carries the asset path, color the tint,
  style the UIPictureFit. KryBackend gains a texture() entry (implemented via
  KryLoadPictureTexture + KryPictureFitRect in the raylib backend, no-op in the
  null backend), and draw_node renders it. A depth-aware find_match_brace() is
  needed because PictureProps nests Rectangle/Vector2 braces.

Interactive stateful widgets (Slider/Toggle/Checkbox/TextField/Dropdown/etc.)
are deferred: they need host-side state + event capture. Verified: 19_pictures
compiles to 2 PICTURE nodes and kryon-preview cartridge renders the real
textures; all krait samples still compile; make test green.
2026-08-13 06:04:55 -05:00
waozi a9d7694dc9 krb: drop unused GROUP node and export enums for a clean v1
KRB_NODE_GROUP, KRB_EXPORT_LOCAL/R/RW, and KRB_FLAG_EXPORT_MASK were
defined but never emitted, set, or read. Per the no-dead-code rule, remove
them so the shipped v1 surface is honest: node types are BACKGROUND/TEXT/
RECT/BUTTON/DATA (type 0 reserved), and flags carry only SCALE_X/Y/W/H
(bits 0-1 reserved). The three opcodes stay (they are implemented and
host-appendable). KRB_FORMAT.md updated to match and to document DATA.
2026-08-12 19:12:13 -05:00
waozi 5b15a1272b Expose kry_term and krb in kryon.h; document the cartridge API
Include kry_term.h, kry_backend.h, and krb.h from the kryon umbrella so
apps reach them through the public header. Document the .krb load/bind/draw
flow and KrbMount in docs/API.md, mention kc --emit-krb in the README, and
add an examples Makefile target that builds the 02_buttons cartridge host.
CHANGELOG entries for the kry_term and krb slices.
2026-08-12 19:03:36 -05:00
waozi 2c84504c6a Add krb: a packed, mmapable Kryon cartridge format
A .krb file is a little-endian image: a 32-byte header (magic "KRB\0",
version 1), a 28-byte VFS node table (group/background/text/rect/button/
data), a UTF-8 string table, a tiny program (OP_DRAW_TREE/OP_CALL_HOST/
OP_SET_I32), and a host-import name list. Behavior stays in C.

KrbLoad/KrbLoadFile validate and map the image in place; KrbDraw/KrbExec
walk it through a KryBackend; KrbMount/KrbBindMem map live C fields onto
paths so TEXT nodes draw live values; KrbBind wires host functions to
import slots. Format spec in docs/KRB_FORMAT.md.
2026-08-12 19:02:44 -05:00