Commit Graph
6 Commits
Author SHA1 Message Date
waozi 84bd26de20 krb v2: text input — TEXTINPUT node + typed-codepoint vtable path
New node type 13: bounded field drawing the mounted CSTR with a
blinking caret when focused (click to focus). Typed input flows through
the new optional KryBackend.text_key (codepoints, 0x08 backspace):
kry_sw queues via KrySwText (drained per frame by Advance), the raylib
surface backend maps GetCharPressed, SDL maps SDL_TEXTINPUT/BACKSPACE,
krb-web exports krb_web_text from keypress events. UTF-8 runes append
and strip correctly. k2b compiles TextField(x,y,w,h,&state.field).

Verified: click-focus, typing with backspace, and that unfocused
fields ignore keys.
2026-08-16 22:06:53 -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 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 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 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 5202861d6e Add kry_backend: a draw/input vtable for non-raylib cartridge hosts
Small backend table (clear, rect, text, measure_text, clip, mouse,
width/height/time/scale, theme_color) so a .krb walker can render through
raylib, a null backend, a framebuffer, or /dev/draw without depending on
raylib directly. KryBackendDraw is the raylib-backed implementation,
KryBackendNull is the headless one used by tests.
2026-08-12 19:02:27 -05:00