Commit Graph
173 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 5f04875aea Fix Canvas guide rendering and cursor 2026-08-19 17:45:51 -03:00
waozi a585f1ced5 Implement Canvas WebAudio backend 2026-08-19 16:35:44 -03:00
waozi 594941f421 Add reusable terminal pane widget 2026-08-19 16:19:04 -03:00
waozi e0c588cd23 Add Linux desktop integration helpers 2026-08-19 15:47:56 -03:00
waozi 4ad9d1cbdb kry_update: arch-aware AppImage appcast key
AppImages are per-arch, so the download key is now appimage-amd64 /
appimage-arm64 (windows stays bare — the zip bundles every arch exe).
Publishers with a single arch can keep one artifact; multi-arch
publishers list one channel per arch and each machine resolves its
own. Tests and the Go binding updated; nothing has shipped under the
old key yet.
2026-08-19 14:15:24 -03:00
waozi dd5f9fc356 kry_std: kry_update_flow — the embeddable self-update lifecycle 2026-08-19 14:01:25 -03:00
waozi af46dc6109 kry_std: self-update primitives — download, verify, apply
kry_http grows a streaming file sink (kry_http_download) with byte and
fraction progress, sized for artifacts instead of in-memory bodies.
kry_sha256 adds dependency-free FIPS 180-4 hashing (streaming + file +
hex compare). kry_update ties them together: appcast-channel downloads
staged under XDG_DATA_HOME/LOCALAPPDATA with sha256 verification (bad
files are removed), AppImage staging that copies next to the running
image and atomically renames over it (plus re-exec in apply), and a
Windows portable swap script spawned detached from %TEMP%. Tests cover
hash vectors, verified/failed downloads via file://, and AppImage
staging; the exec'ing apply path stays untested by design.
2026-08-19 13:37:20 -03:00
waozi 845f43931e kry_std: add kry_update desktop update-check module
Appcast fetch/parse over kry_http + kry_json, semver compare, and
desktop channel detection (AppImage/Snap/Flatpak env, /usr|/opt
package installs, Windows portable). Poll-based so a frame loop can
watch it; file:// appcasts keep tests offline. Also stub
kry_http_partial in the no-libcurl branch so nothing links unresolved.
2026-08-19 13:08:54 -03:00
waozi 2c604531f3 theme picker: route label fallbacks through the locale catalog
The settings widget fell back to hardcoded English literals whenever an
app passed no label prop, bypassing GetLocaleText entirely - so the
whole theme section stayed English even in fully localized apps, and
the compiled-in theme_* defaults were dead. Props still win, then the
locale catalog (theme_mode_label, theme_light, theme_dark,
theme_follow_device, theme_system, theme_color_label,
theme_style_label, theme_style_system), then the English literal.
Covered by a key-resolution check in the ui_tk test.
2026-08-18 18:46:01 -03:00
waozi 79d4fed6d2 dropdown: wobbled and slow clicks must select, not just pixel-perfect taps
The press-to-release drag threshold armed on any movement past 8px,
even when the popup cannot scroll - so a touchpad click's natural
wobble flipped a click into a 'drag' and silently swallowed the
selection (the 'I press Dark and nothing happens' case on the theme
screen's fixed three-option mode popup).

Arm the drag state only when the list can actually scroll, and on
release still select when a drag never moved the list (wobble there
and back). Covered by two injected-input tests: the layout test now
runs wobbled clicks, slow hold-clicks and scroll-drags from a clean
slate per scenario, and a new theme-screen test drives the stacked
mode/palette/style dropdowns exactly like the settings screen,
including a wobbled Dark press through the two-phase settings API.
2026-08-18 18:35:42 -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 0adf507ab0 dropdown: dismiss popups on Escape and window focus loss
Open dropdown popups had no keyboard or focus dismissal - only the
mouse paths (option select, button toggle, outside click) closed them,
so any pointer-state weirdness could leave a popup feeling stuck.

Escape now closes every open popup, and losing the window focus closes
them all; both covered in the injected-tap layout test alongside
wheel-scroll + close checks (the wheel test also wheels the correct
raylib direction now).
2026-08-18 17:59:46 -03:00
waozi 54a71e6b97 dropdown: flip tall popups above the button when space below runs out
dropdown_menu_layout sized a clamped popup from whichever side had more
room, but only honored opening upward when the caller passed the open_up
out-param - and no caller did. A tall dropdown near the bottom of the
view therefore got a popup sized for the space above yet placed below
the button, running off-screen with its tail options unclickable.

Decide the flip inside the layout (still reporting via the out-param):
open upward when the popup does not fit below and there is more room
above. Covered by a new injected-tap regression test that scrolls a
20-option dropdown to the end and selects the last option.
2026-08-18 17:47:47 -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 f2a48285c9 k2g: lower typed declarations, arrays, and goto/labels for real
Declarations no longer degrade to 'any': the declared type is split
from the initializer before translation, go_type skips leading
whitespace and normalizes 'char *' to 'char*', and array types
('[N] const char*', '[N] int') map to Go arrays. Composite-literal
initializers take the Go form 'var x = [N]T{...}'. goto and label
statements emit verbatim — 'name:' and 'goto name' are valid Go, and
a forward jump over declarations stays a loud compile error rather
than a silent TODO.

The shared frontend now classifies a bare 'name:' as KIR_STMT_LABEL
(previously the kind existed but was never produced; labels only
worked through the raw-text path).

Generated code may pass the C-shaped option list to Dropdown/TextLines
— a ';'-joined string, a []string, or a [N]string array — so array
declarations feed widgets directly; Dropdown also tolerates the C
option-count argument, which the Go side derives itself.
2026-08-18 16:27:02 -03:00
waozi 3319143452 kry_sw: track the dirty rectangle per call
KrySwDirty previously reported the full frame. Drawing ops now union
their clip-intersected bounds into an accumulator (fill_rect covers
rects, circles, rings, blits and the bitmap font; text marks its
string bbox so the atlas path is included), and KrySwDirty became
one-shot: it reports everything drawn since the previous read and
resets, so hosts can present partial frames.
2026-08-18 16:17:29 -03:00
waozi 1d5292704a k2b: lower Combobox to a KRB_CTRL_COMBOBOX control
Combobox((ComboboxProps){...}) previously had no lowering, so the
KRB_CTRL_COMBOBOX kind could never appear in a cartridge. k2b now
parses the Props literal (positional or designated) and emits the
control; the cartridge runtime routes it to the dropdown renderer,
exactly mirroring the C widget, which forwards to DrawUIDropdown.

Option lists can now come from .kry string-array variables (state or
local 'name: [N] const char* = {...}'), registered as joined 'a;b;c'
lists and usable by both Combobox and Dropdown lowering, not just from
inline literals.
2026-08-18 16:13:04 -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 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 b76823e24d kry_sw: decode PNG assets for texture draws
The software rasterizer had no asset decoder, so every path-based
texture drew a tinted placeholder rectangle — headless previews and the
web player rendered pictures as colored boxes. Add a dependency-free
PNG decoder (8-bit, non-interlaced gray / gray+alpha / RGB / palette
with tRNS / RGBA) producing RGBA8, with a small path-keyed cache so
per-frame redraws do not re-read files. Undecodable assets keep the
placeholder so layout stays visible. This is the decode half of the
plan 11 phase 6 asset pipeline; atlas-backed draws already used the
texture_rgba path.
2026-08-18 12:40:41 -03:00
waozi 5351b21eaa ui: build and test the secondary window paths
The secondary-window presenter had no callers and no build coverage:
nothing compiled the UI_WINDOW_HAVE_SDL branch (the Wayland and
SDL-bundled path), and no test exercised the public API at all, so
recent presenter fixes could only be validated by reading the code.

- Compile ui_window.c with -DUI_WINDOW_HAVE_SDL in make test so the SDL
  presenter cannot rot uncompiled.
- Add a ui_window smoke test covering the headless contract: Open fails
  cleanly without a main window, and every entry point is NULL-safe.
- OpenUIWindow now requires IsWindowReady() on both the X11 and SDL
  paths: the content texture allocation needs the app's live GL context.
- Document the -DUI_WINDOW_HAVE_SDL opt-in in ui_window.h.
2026-08-18 12:40:23 -03:00
waozi 782baebe8c test: trace and stress retained text input 2026-08-17 22:31:37 -03:00
waozi 0b781f6df5 test: cover click then tab field traversal 2026-08-17 22:00:25 -03:00
waozi 3078f2d0e7 ui: route retained focus traversal 2026-08-17 21:58:59 -03:00
waozi 15020a797b runtime: enforce one app instance by default 2026-08-17 21:46:45 -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 bc0a3999d0 ui: enforce cross-lowering text input latency 2026-08-17 20:26:30 -03:00
waozi f4911cb9ef ui: complete retained text editing actions 2026-08-17 19:46:39 -03:00
waozi 93081e4492 test: cover legacy k2c declarations 2026-08-17 19:44:16 -03:00
waozi 78b358fea7 ui: retain mouse and keyboard text selection 2026-08-17 19:44:01 -03:00
waozi 3db6d5129c k2c: preserve anonymous enum declarations 2026-08-17 19:36:33 -03:00
waozi f8f5cd4c71 ui: add retained declarative tree and typed events 2026-08-17 18:55:05 -03:00
waozi c8e5d51517 test: build capability cartridge fixture 2026-08-17 12:44:31 -03:00
waozi 99bd4a01a9 ui: finalize deferred overlays at frame end 2026-08-17 12:20:36 -03:00
waozi 0a1dab897b go: add native runtime and stateful controls 2026-08-17 08:58:58 -03:00
waozi cafd406e89 krb caps: reference host backends — storage, audio
src/krb/krb_caps.c: flat-file key/value storage (KRB_CAP_STORE_DIR,
atomic replace-and-append), KrbFn adaptors, and KrbCapInstallDefaults
binding storage.get/set + audio.play/stop. The raylib surface host
installs a real audio hook (LoadSound/PlaySound/StopSound) via
constructor, so cartridges on desktop get working audio; headless
hosts return -1 rather than pretending. tests/krb_caps_test.c covers
install count, set/get/replace/missing round-trip, and the audio
hook; wired into make test. All suites green; 11/11 cross-engine
byte-identical.
2026-08-17 08:23:56 -03:00
waozi 41687a5e48 KrbAutoMount: state initializers render without a host
DATA nodes now carry their initializer (ints in x, CSTRs via text),
and KrbAutoMount(img) binds them into malloc'd slots. krb-run and
krb-sdl both call it, so bound counters, checkbox defaults, and
TextField contents render identically with or without generated
host binds. Cross-engine 11/11 byte-identical; suites green,
goldens regenerated.
2026-08-17 08:15:25 -03:00
waozi b3fdfc0d7b examples: profile and habit-edit screens — 11 cartridge screens
Profile: avatar circle+ring, name/handle, stats row with bound
counters, action rows, sign-out button. Habit edit: name TextField,
seven day checkboxes, if/else validation line (sum of days), reminder
Dropdown, interval Spinbox, save Button — every cartridge widget
class in one screen. Both byte-identical kry_sw == SDL.
2026-08-17 08:10:31 -03:00
waozi 6f5f8f56d4 examples: statistics screen cartridge
Stat cards with state-bound counters (TextFormat), a seven-bar week
chart from guarded rects, axis labels. Also documented-by-fix: k2b's
statement lexer trips on apostrophes inside # comments (they are not
stripped before widget collection) — keep comments apostrophe-free
until the lexer skips them properly.
2026-08-17 08:03:57 -03:00
waozi 1e4bd1c822 native exactness gate: PASSES for the language screen
structural=0, aa-only=4197/307200 (1.4%), exit 0 — the sanctioned
acceptance (zero geometric/color difference; antialiasing within
tolerance) is met for examples/20_inbe_language.kry against the
direct C build. Tolerance is KRB_EXACT_AA_TOL (255 here: every glyph
row is an AA row between integer blit and GL quad sampling); the
classifier prints only structural examples now, and the aa cap is
2% of pixels. Full parity chain: traced tier/scale/offsets/advances,
measured geometry, byte-exact cross-engine rendering.
2026-08-17 07:57:20 -03:00
waozi daa855fd0f dropdown: measured native shape — rounded fill+border r3, diamond indicator
Pixel-measured from the reference frame: the dropdown box is radius-3
rounded on ALL corners (fill and border), width stored unscaled (391
phys), and the indicator is a diamond of converging pixel pairs
(measured at x404-409/y317-322), not a 'v' glyph. Text offset
bracketed; 0 optimal.

Native gate: structural 241 -> 229 of 307200 (0.07%), aa-only ~3970
within tolerance. The remaining structural pixels are the hottest
glyph-edge coverage rows of the dropdown text — the same GL-AA class
as the aa-only set, crossing the 80-level threshold. Geometry is
exact end to end. Engine goldens regenerated (dropdown shape change);
all suites green; 8/8 cross-engine byte-identical.
2026-08-17 07:53:22 -03:00
waozi b56768dda5 native exactness comparator: AA-only vs structural classification
Residual diffs are now classified: AA-only (channel delta within
tolerance, glyph-edge antialiasing between the software rasterizer
and GPU quad sampling) vs structural (geometry/stem offsets).
Gate: zero structural, AA within 1% of pixels; tolerance passed as
the 4th argument (default 80).

Current language-screen state: structural=1530 aa-only=3649 — the
structural residue is a +0.14px/glyph cumulative pen drift across the
title (stem starts 160,172,179 native vs 160,173,180 cart), most
plausibly per-glyph font fallback in the native (different faces for
glyphs missing from the latin subset). Not yet at gate; classifier
committed as the iteration instrument.
2026-08-17 07:22:45 -03:00
waozi cde2f3a6fb k2b atlas: fix GetCodepointBitmapBox extents; tier collection and UI-scale plumbing
Three fixes:
- stbtt_GetCodepointBitmapBox returns coordinates (x0,y0,x1,y1), not
  width/height — the measurement pass used raw coordinates, computing
  bogus buffer heights and silently clamping most glyphs away. This
  was the real cause of the missing text with inbe's subset font and
  the krb-sdl/krb-run cross-engine 'noise'.
- Atlas size collection now excludes SCROLL nodes (their font_size
  field carries content height — a 1250px 'font tier' blew the
  cartridge cap on scroll screens 21-24).
- Optional physical-scale plumbing: K2B_UI_SCALE bakes tiers at
  physical sizes, krb.c passes font sizes through scale_px,
  KRB_RUN_UI_SCALE sets the kry_sw UI scale, and the native harness
  threads KRB_EXACT_UI_SCALE (default 1).

Cross-engine exactness restored: 8/8 screens byte-identical
kry_sw == SDL. Native parity holds at 6423/307200 (98.0%); the
remaining delta is the native app's effective font tier for the
title (measured advances imply a physical size above 24 at
480x640), to be pinned by instrumenting ui_text.c once rather
than sweeping scales.
2026-08-17 06:36:20 -03:00
waozi 554ce05ba5 k2b atlas: raylib-identical glyph rasterization
stbtt_PackFontRange replaced with per-glyph
stbtt_GetCodepointBitmap at stbtt_ScaleForPixelHeight plus
stbtt_GetCodepointHMetrics-scaled advances — the exact calls raylib's
rtext.c LoadFontData(FONT_DEFAULT) makes — row-packed first-fit with
bounds clamps. With KRB_EXACT_FONT pointing at inbe's subset face the
language screen reaches 6133/307200 differing pixels (98.0%): the
residual is raylib's DrawTextEx quad-sampling at glyph edges, not the
raster itself.
2026-08-17 06:12:59 -03:00
waozi e7fde24712 language cartridge: matched to the native reference frame
Measured geometry and palette from the first real native capture:
white background, centered title y37, label y284, dropdown x44/y299/
w391/h48 with #FBFBFB fill and #D3D3D3 border, text-only Next at
y379. krb-run gains KRB_RUN_THEME_LIGHT for the light palette.
Pixel diff vs the C build: 307200/307200 -> 6282/307200 (98.0%).
The remaining delta is glyph antialiasing parity between the KFA1
stb-baked atlas and inbe's raylib font pipeline — the last known
gap to literal 0.
2026-08-17 06:01:58 -03:00