Compare commits

...
139 Commits
Author SHA1 Message Date
github-actions[bot] 3390e82f26 Update CHANGELOG for v0.1.76 2026-09-07 20:03:45 +00:00
waozi e8927a64e2 release: bump version to v0.1.76 2026-09-07 17:01:09 -03:00
waozi 1d3f6e8970 Add temporary input to numeric controls 2026-09-07 17:00:38 -03:00
github-actions[bot] 0a7ed6f644 Update CHANGELOG for v0.1.75 2026-09-07 19:19:48 +00:00
github-actions[bot] ed4f6beb35 release: bump version to v0.1.75 2026-09-07 19:17:22 +00:00
waozi 48ca968449 Merge branch 'master' of github.com:kryonlabs/kryon 2026-09-07 16:05:13 -03:00
waozi 25a11d5c7d Enforce premultiplied paint layer output 2026-09-07 16:05:03 -03:00
waozi 656be6175f Highlight Kry directives in text areas 2026-09-07 15:56:13 -03:00
github-actions[bot] 69b6de9d18 Update CHANGELOG for v0.1.74 2026-09-07 18:54:02 +00:00
github-actions[bot] 3296f967d4 release: bump version to v0.1.74 2026-09-07 18:51:33 +00:00
waozi cc20902756 Keep paint layer text on straight alpha 2026-09-07 15:43:16 -03:00
waozi 262af24d23 Track single profile icon atlas 2026-09-07 15:39:34 -03:00
waozi 25b75816bf Use single transparent profile picture atlas 2026-09-07 15:37:43 -03:00
waozi ac45d64dd2 Merge remote-tracking branch 'origin/master' 2026-09-07 15:36:03 -03:00
waozi 88535c82a1 Keep paint layers premultiplied 2026-09-07 15:35:48 -03:00
waozi ac6f407f9d Use rounded profile picture tiles 2026-09-07 15:29:06 -03:00
github-actions[bot] be29262efc Update CHANGELOG for v0.1.73 2026-09-07 18:25:12 +00:00
github-actions[bot] b481104d5c release: bump version to v0.1.73 2026-09-07 18:22:52 +00:00
waozi 07746879d1 Use normal alpha for paint layer compositing 2026-09-07 15:22:04 -03:00
waozi 3e131a95b2 Preserve synthetic tap activation 2026-09-07 15:11:33 -03:00
waozi a680050571 Suppress control activation after drag 2026-09-07 15:07:12 -03:00
waozi b391120310 Fix translucent paint layer compositing 2026-09-07 15:04:39 -03:00
waozi d9361cdd53 Harden modern bottom navigation tests 2026-09-07 14:48:44 -03:00
waozi 0db7e10e3c Keep disabled bottom nav icons visible 2026-09-07 14:45:18 -03:00
waozi 1455aa124c Use normal alpha for paint layer compositing 2026-09-07 14:42:01 -03:00
waozi b16462f2b6 Preserve retro style tokens 2026-09-07 14:32:07 -03:00
waozi c7a00eb361 Merge remote-tracking branch 'origin/master' 2026-09-07 14:23:26 -03:00
waozi 69c032eeb6 Remove stale locale dropdown compatibility 2026-09-07 14:23:19 -03:00
waozi 7eb440e964 Expose locale dropdown controls 2026-09-07 14:22:23 -03:00
waozi b79044e726 Modernize default nav styling 2026-09-07 14:17:50 -03:00
github-actions[bot] 186876cc2e Update CHANGELOG for v0.1.72 2026-09-07 17:11:01 +00:00
github-actions[bot] a9231918e6 release: bump version to v0.1.72 2026-09-07 17:08:56 +00:00
waozi cab6851f29 Isolate and clean dropdown state 2026-09-07 13:58:20 -03:00
waozi fef273a2c8 Merge remote-tracking branch 'origin/master' 2026-09-07 13:26:21 -03:00
waozi 0f4d54fd60 Modernize profile picture icons 2026-09-07 13:25:08 -03:00
github-actions[bot] a958c66e56 Update CHANGELOG for v0.1.71 2026-09-07 16:15:32 +00:00
github-actions[bot] f23482bc9a release: bump version to v0.1.71 2026-09-07 16:13:11 +00:00
waozi 0854d09aa4 Add text editor buffer helpers 2026-09-07 13:12:50 -03:00
waozi d80b3b6e2b Remove stale scaling compatibility alias 2026-09-07 12:52:45 -03:00
waozi c9e1874221 Keep ScaleUIPx compatibility 2026-09-07 12:48:59 -03:00
waozi c598f2b18b Merge remote-tracking branch 'origin/master' 2026-09-07 12:48:05 -03:00
waozi f2ee7fcbcd Add closeable collapsible headers 2026-09-07 12:47:58 -03:00
waozi 1dc1714f6e Ignore mod-wheel in text area scroll 2026-09-07 12:46:41 -03:00
waozi 29adf8c05a Rename UI scaler API 2026-09-07 12:29:41 -03:00
waozi 1dba574c45 Use semantic title font in title bar 2026-09-07 12:24:42 -03:00
github-actions[bot] bd0b87e11a Update CHANGELOG for v0.1.70 2026-09-07 15:22:52 +00:00
github-actions[bot] d65b6cd154 release: bump version to v0.1.70 2026-09-07 15:20:35 +00:00
waozi d017c38b42 Clamp retained text area scroll 2026-09-07 12:16:33 -03:00
waozi cda31c579e Soften title bar surface 2026-09-07 12:14:18 -03:00
waozi 89020372ce Add composed native tab scopes 2026-09-07 11:58:08 -03:00
waozi 54640e7762 Fix scroll clipping under render scale 2026-09-07 11:51:23 -03:00
github-actions[bot] 9d8ca2970f Update CHANGELOG for v0.1.69 2026-09-07 14:13:02 +00:00
github-actions[bot] 73f91c4d08 release: bump version to v0.1.69 2026-09-07 14:10:49 +00:00
waozi 9513fc2640 Fix standalone DPI test on FreeBSD 2026-09-07 11:00:10 -03:00
waozi 7877d2215e Update public API snapshot for scaling helpers 2026-09-07 10:53:14 -03:00
waozi 79298416ae Merge remote-tracking branch 'origin/master' 2026-09-07 10:52:59 -03:00
waozi 1ab621d379 Isolate native tab bar state by widget 2026-09-07 10:52:36 -03:00
waozi 981e85f28f Fix logical UI density scaling 2026-09-07 10:52:13 -03:00
waozi 46015904d4 Merge remote-tracking branch 'origin/master' 2026-09-07 10:44:37 -03:00
waozi 5ffb9be867 Fix core UI scaling and picture bounds 2026-09-07 10:37:05 -03:00
github-actions[bot] 32c723ed54 Update CHANGELOG for v0.1.68 2026-09-07 13:36:23 +00:00
github-actions[bot] b9de76253c release: bump version to v0.1.68 2026-09-07 13:33:35 +00:00
waozi b0fe891233 Reuse canonical button behavior in composite widgets 2026-09-07 10:23:03 -03:00
waozi ecee9cbafa Keep tab keyboard tests renderer-free 2026-09-07 10:21:37 -03:00
waozi 05dfbde7c9 Unify native tab bar behavior 2026-09-07 10:00:19 -03:00
github-actions[bot] 10ba3e15df Update CHANGELOG for v0.1.67 2026-09-07 05:40:54 +00:00
github-actions[bot] d3ec6b0105 release: bump version to v0.1.67 2026-09-07 05:38:37 +00:00
waozi bc3554f82c Add keyboard controls to native drag widgets 2026-09-07 02:28:37 -03:00
github-actions[bot] 7b8998f803 Update CHANGELOG for v0.1.66 2026-09-07 05:27:25 +00:00
github-actions[bot] ab88b9cf48 release: bump version to v0.1.66 2026-09-07 05:25:14 +00:00
waozi d33a7d8b90 Add native multi-select keyboard navigation 2026-09-07 02:14:44 -03:00
github-actions[bot] 0bbbc2f8d9 Update CHANGELOG for v0.1.65 2026-09-07 05:05:26 +00:00
github-actions[bot] 3adcbae67b release: bump version to v0.1.65 2026-09-07 05:03:00 +00:00
waozi de87e6165e Add native toggle keyboard navigation 2026-09-07 01:52:38 -03:00
github-actions[bot] 2c05376b7c Update CHANGELOG for v0.1.64 2026-09-07 04:37:00 +00:00
waozi cb5de81977 Unify keyboard interaction for choice widgets 2026-09-07 01:24:57 -03:00
github-actions[bot] 716ecab4c8 release: bump version to v0.1.64 2026-09-07 04:00:49 +00:00
waozi e15a17bfdb Add native slider keyboard navigation 2026-09-07 00:50:01 -03:00
github-actions[bot] 98d23502c5 Update CHANGELOG for v0.1.63 2026-09-07 03:14:05 +00:00
github-actions[bot] a20dd06925 release: bump version to v0.1.63 2026-09-07 03:09:04 +00:00
waozi 6df6e9a6c4 Defer Text painting inside retained layouts 2026-09-06 23:57:03 -03:00
waozi 29819a0fcd Keep canonical Text visible in mixed UI frames 2026-09-06 23:57:03 -03:00
github-actions[bot] 0e0bf15d5f Update CHANGELOG for v0.1.62 2026-09-07 02:46:34 +00:00
waozi 349b551927 Update theme example runtime snapshot 2026-09-06 23:25:20 -03:00
waozi 4dc2fa77e0 Expose title bar opacity as a style token 2026-09-06 21:33:38 -03:00
github-actions[bot] d9f410fc93 release: bump version to v0.1.62 2026-09-07 00:32:46 +00:00
waozi eac5e8a6c0 Add native menu keyboard navigation 2026-09-06 21:03:23 -03:00
github-actions[bot] 61b10538a6 Update CHANGELOG for v0.1.61 2026-09-06 23:28:02 +00:00
github-actions[bot] d3a1267c8c release: bump version to v0.1.61 2026-09-06 23:25:37 +00:00
waozi 5d3b13e9c1 Add native list box keyboard parity 2026-09-06 20:04:59 -03:00
waozi 8d70d20d45 Clip Text only when its bounds require it 2026-09-06 20:04:59 -03:00
waozi e292d5cafa Preserve outlined icons and live Text layering 2026-09-06 20:04:59 -03:00
waozi e539942432 Refine Material guides and warning artwork 2026-09-06 20:04:59 -03:00
github-actions[bot] 09d2c6c918 Update CHANGELOG for v0.1.60 2026-09-06 23:00:05 +00:00
waozi 822a216e3d Keep retained text ordering invariant 2026-09-06 19:47:22 -03:00
waozi d952a3a475 Preserve immediate Text rendering in retained frames 2026-09-06 19:47:22 -03:00
waozi 9888d85cc9 Add canonical MingCute warning icon 2026-09-06 19:47:22 -03:00
github-actions[bot] 612dbac881 release: bump version to v0.1.60 2026-09-06 22:46:08 +00:00
waozi 8db0c1c891 Share one canonical text painter 2026-09-06 19:35:11 -03:00
waozi 6dba1b9467 Use a clean Material return affordance 2026-09-06 19:35:11 -03:00
waozi 4cb59de5dd Preserve canonical Text paint order on native screens 2026-09-06 19:35:11 -03:00
waozi 5b4950fae6 Make Text the canonical centered label API 2026-09-06 19:35:11 -03:00
github-actions[bot] 85607a4392 Update CHANGELOG for v0.1.59 2026-09-06 22:32:51 +00:00
github-actions[bot] 71b411f3e0 release: bump version to v0.1.59 2026-09-06 22:30:32 +00:00
waozi 165a7da664 Keep canonical text retained and clipped 2026-09-06 19:19:47 -03:00
waozi aafbb30256 Add native table clipboard parity 2026-09-06 19:11:28 -03:00
waozi ff3c474060 Keep table Tab navigation within cells 2026-09-06 19:01:56 -03:00
waozi eccd78c4fa Add native table keyboard parity 2026-09-06 18:59:16 -03:00
waozi 4dd6f1ab7a Keep reorder release owned through card dispatch 2026-09-06 18:52:03 -03:00
waozi 414d61d320 Keep popup-owned widget shortcuts isolated 2026-09-06 18:44:45 -03:00
waozi ad151eb204 Route accelerators through popup ownership 2026-09-06 18:38:21 -03:00
waozi ec32adb8fa Avoid redundant clipping for intrinsic text 2026-09-06 18:38:07 -03:00
waozi c99eceb072 Preserve canonical text paint order in native screens 2026-09-06 18:35:44 -03:00
waozi b6a41789bd Enforce canonical TextProps usage 2026-09-06 18:26:36 -03:00
waozi 8d96af9ae9 Refine canonical carousel navigation controls 2026-09-06 18:24:47 -03:00
waozi f727a2aca0 Merge remote-tracking branch 'origin/master' 2026-09-06 18:09:40 -03:00
waozi eef66f8b38 Complete Sync crypto helper consolidation 2026-09-06 18:06:39 -03:00
waozi b32e3224c8 Preserve shipped sync wire compatibility 2026-09-06 18:05:37 -03:00
waozi db9f1f0285 Use clean Sync naming throughout optional sync runtime 2026-09-06 16:51:07 -03:00
github-actions[bot] 4817c021c5 Update CHANGELOG for v0.1.58 2026-09-06 19:48:48 +00:00
waozi 455dcd0f4d release: bump version to v0.1.58 2026-09-06 16:46:30 -03:00
waozi 72548efed4 Merge branch 'imgui-drag-ownership' of /mnt/storage/Projects/kryon-imgui 2026-09-06 16:28:56 -03:00
waozi 9bc4652e43 Keep active gestures owned by popup branches 2026-09-06 16:27:26 -03:00
waozi c2717be489 Merge branch 'inbe-ui-widgets'
# Conflicts:
#	docs/site/conformance-matrix.json
#	src/ui/ui_tk.c
#	src/ui/ui_tree.c
#	tests/generated_runtime_parity_test.sh
2026-09-06 16:22:24 -03:00
waozi e28170b826 Rename optional sync module to Daochi 2026-09-06 16:13:35 -03:00
github-actions[bot] 5f0613e499 Update CHANGELOG for v0.1.57 2026-09-06 16:24:45 +00:00
waozi 49ed4e680c Implement DrawTextureRec in the libdraw backend 2026-09-06 13:22:52 -03:00
github-actions[bot] 53ccd9e47f release: bump version to v0.1.57 2026-09-06 16:22:31 +00:00
waozi 956d42d629 Restore focus across popup lifecycles 2026-09-06 13:12:08 -03:00
github-actions[bot] 2b9c9d3c43 Update CHANGELOG for v0.1.56 2026-09-06 15:43:47 +00:00
github-actions[bot] b7ef2ac98d release: bump version to v0.1.56 2026-09-06 15:41:11 +00:00
waozi 9c02d2a4d4 Add canonical context popup scope 2026-09-06 12:30:41 -03:00
github-actions[bot] 7271487d75 Update CHANGELOG for v0.1.55 2026-09-06 15:06:25 +00:00
github-actions[bot] 5dd99d511a release: bump version to v0.1.55 2026-09-06 15:04:13 +00:00
waozi 198ab4d4a0 Prefer bundled UI font and stabilize widget audit 2026-09-06 11:54:18 -03:00
waozi 0970d8f783 Unify native text and composed popup widgets 2026-09-06 11:36:36 -03:00
waozi cce4b2fe77 Add spreadsheet string-literal and error-name scanners to kry_eval
eval_parse_string_literal: gnumeric-compatible lexer for quoted string
literals (doubled quotes and backslash escapes, which drop the
backslash and keep the next character verbatim).

eval_scan_error_name: recognizes the eight spreadsheet error names
(#DIV/0! .. #CYCLE!) and returns a canonical index.
2026-09-06 11:36:36 -03:00
github-actions[bot] 4382a0a56e Update CHANGELOG for v0.1.54 2026-09-05 23:29:50 +00:00
github-actions[bot] d088ba55a2 release: bump version to v0.1.54 2026-09-05 23:27:35 +00:00
209 changed files with 23757 additions and 5581 deletions

No files matched your search

+3
View File
@@ -13,3 +13,6 @@
[submodule "vendor/box2d"]
path = vendor/box2d
url = https://github.com/erincatto/box2d.git
[submodule "vendor/monocypher"]
path = vendor/monocypher
url = https://github.com/LoupVaillant/Monocypher.git
+25
View File
@@ -30,9 +30,34 @@ Do not expand it, duplicate it under another alias, or use it from generated
output. Remove compatibility code once no maintained app or fixture depends on
it.
## Canonical Widget Rule
One widget concept has one public implementation. Variations such as wrapping,
clipping, color, alignment, and disabled state belong in that widget's props;
do not create parallel helpers such as `TextWrapped`, `TextColored`, or
`TextDisabled`. Migrate maintained callers when consolidating an older split
surface, then remove the duplicate entry points and generated output.
`Text` has exactly one public signature: `Text(TextProps)`. Every maintained C
and `.kry` caller must pass one explicit `TextProps` value. Position, bounds,
wrapping, clipping, color, alignment, and disabled state belong in those props.
Do not restore the positional `Text(text, x, y, font, color)` form or hide it
behind a helper, macro, overload, generated shim, or compatibility alias.
## Test Rule
Any change to k2go, k2c, k2cpp, the Go runtime, or the C runtime surface must keep the
generated-output scanners and runtime parity tests passing. If a new widget or
semantic is added, add it to both generated runtimes and to parity coverage in
the same change.
Run `python3 scripts/check-clean-text-api.py <changed-source-roots>` when a
maintained app or fixture changes text rendering. Downstream repositories must
wire this check into their normal test target.
## Readability Rule
Write conventional, fully readable code. Do not compress multiple statements,
branches, or error checks onto one line. Handlers and protocol code must use
descriptive names, explicit control flow, and focused helpers. Run the language
formatter and inspect the resulting diff before considering a change complete.
+237
View File
@@ -1,4 +1,241 @@
# Changelog
## v0.1.76 - 2026-09-07
### Changed
- Release: bump version to v0.1.76
- Add temporary input to numeric controls
## v0.1.75 - 2026-09-07
### Changed
- Release: bump version to v0.1.75
- Enforce premultiplied paint layer output
- Highlight Kry directives in text areas
- Keep paint layer text on straight alpha
## v0.1.74 - 2026-09-07
### Changed
- Release: bump version to v0.1.74
- Track single profile icon atlas
- Use single transparent profile picture atlas
- Keep paint layers premultiplied
- Use rounded profile picture tiles
- Use normal alpha for paint layer compositing
## v0.1.73 - 2026-09-07
### Changed
- Release: bump version to v0.1.73
- Preserve synthetic tap activation
- Suppress control activation after drag
- Fix translucent paint layer compositing
- Harden modern bottom navigation tests
- Keep disabled bottom nav icons visible
- Use normal alpha for paint layer compositing
- Preserve retro style tokens
- Remove stale locale dropdown compatibility
- Expose locale dropdown controls
- Modernize default nav styling
## v0.1.72 - 2026-09-07
### Changed
- Release: bump version to v0.1.72
- Isolate and clean dropdown state
- Modernize profile picture icons
- Add text editor buffer helpers
## v0.1.71 - 2026-09-07
### Changed
- Release: bump version to v0.1.71
- Remove stale scaling compatibility alias
- Keep ScaleUIPx compatibility
- Add closeable collapsible headers
- Ignore mod-wheel in text area scroll
- Rename UI scaler API
- Use semantic title font in title bar
- Clamp retained text area scroll
- Soften title bar surface
## v0.1.70 - 2026-09-07
### Changed
- Release: bump version to v0.1.70
- Add composed native tab scopes
- Fix scroll clipping under render scale
## v0.1.69 - 2026-09-07
### Changed
- Release: bump version to v0.1.69
- Fix standalone DPI test on FreeBSD
- Update public API snapshot for scaling helpers
- Isolate native tab bar state by widget
- Fix logical UI density scaling
- Fix core UI scaling and picture bounds
## v0.1.68 - 2026-09-07
### Changed
- Release: bump version to v0.1.68
- Reuse canonical button behavior in composite widgets
- Keep tab keyboard tests renderer-free
- Unify native tab bar behavior
## v0.1.67 - 2026-09-07
### Changed
- Release: bump version to v0.1.67
- Add keyboard controls to native drag widgets
## v0.1.66 - 2026-09-07
### Changed
- Release: bump version to v0.1.66
- Add native multi-select keyboard navigation
## v0.1.65 - 2026-09-07
### Changed
- Release: bump version to v0.1.65
- Add native toggle keyboard navigation
## v0.1.64 - 2026-09-07
### Changed
- Unify keyboard interaction for choice widgets
- Release: bump version to v0.1.64
- Add native slider keyboard navigation
## v0.1.63 - 2026-09-07
### Changed
- Release: bump version to v0.1.63
- Defer Text painting inside retained layouts
- Keep canonical Text visible in mixed UI frames
## v0.1.62 - 2026-09-07
### Changed
- Update theme example runtime snapshot
- Expose title bar opacity as a style token
- Release: bump version to v0.1.62
- Add native menu keyboard navigation
## v0.1.61 - 2026-09-06
### Changed
- Release: bump version to v0.1.61
- Add native list box keyboard parity
- Clip Text only when its bounds require it
- Preserve outlined icons and live Text layering
- Refine Material guides and warning artwork
## v0.1.60 - 2026-09-06
### Changed
- Keep retained text ordering invariant
- Preserve immediate Text rendering in retained frames
- Add canonical MingCute warning icon
- Release: bump version to v0.1.60
- Share one canonical text painter
- Use a clean Material return affordance
- Preserve canonical Text paint order on native screens
- Make Text the canonical centered label API
## v0.1.59 - 2026-09-06
### Changed
- Release: bump version to v0.1.59
- Keep canonical text retained and clipped
- Add native table clipboard parity
- Keep table Tab navigation within cells
- Add native table keyboard parity
- Keep reorder release owned through card dispatch
- Keep popup-owned widget shortcuts isolated
- Route accelerators through popup ownership
- Avoid redundant clipping for intrinsic text
- Preserve canonical text paint order in native screens
- Enforce canonical TextProps usage
- Refine canonical carousel navigation controls
- Complete Sync crypto helper consolidation
- Preserve shipped sync wire compatibility
- Use clean Sync naming throughout optional sync runtime
## v0.1.58 - 2026-09-06
### Changed
- Release: bump version to v0.1.58
- Keep active gestures owned by popup branches
- Rename optional sync module to Daochi
- Enlarge canonical return title bar target
- Implement DrawTextureRec in the libdraw backend
- Render dropdown state with a chevron
- Derive material bottom nav spacing from content
- Align reorder targets with lifted items
- Make fitted text density aware
- Scale semantic font tokens with UI density
- Add spreadsheet string-literal and error-name scanners to kry_eval
- Ui: add shared carousel controls and honor secondary button style
## v0.1.57 - 2026-09-06
### Changed
- Release: bump version to v0.1.57
- Restore focus across popup lifecycles
## v0.1.56 - 2026-09-06
### Changed
- Release: bump version to v0.1.56
- Add canonical context popup scope
## v0.1.55 - 2026-09-06
### Changed
- Release: bump version to v0.1.55
- Prefer bundled UI font and stabilize widget audit
- Unify native text and composed popup widgets
- Add spreadsheet string-literal and error-name scanners to kry_eval
## v0.1.54 - 2026-09-05
### Changed
- Release: bump version to v0.1.54
- Keep dropdowns within the viewport and stabilize native CI audits
- Complete native widget catalog and runtime interaction parity
- Provide libdraw matrix compatibility for retained paint capture
- Export the pi double-double constant alongside 2pi
- Add quad log, hypot, inverse trig, and pi-accurate sinpi/cospi
- Isolate Windows header names in SDL renderer builds
- Add spreadsheet evaluation primitives: cell addressing and ulp-grace rounding
- Fix text area lines overriding multiline clipboard selection
## v0.1.53 - 2026-09-05
### Changed
+75 -60
View File
@@ -173,34 +173,35 @@ KRYON_ZLIB_LDLIB ?= -lz
RAY_SDL_INCLUDE_DIR ?= $(shell pkg-config --variable=includedir sdl2 2>/dev/null | sed 's,/SDL2$$,,')
RAY_RAYLIB_CONFIG ?= -DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=1 -DMAX_CLIPBOARD_BUFFER_LENGTH=1048576
APP_RAYLIB_CONFIG ?= $(filter-out -DSUPPORT_MODULE_RAUDIO=0 -DSUPPORT_FILEFORMAT_PNG=0 -DSUPPORT_FILEFORMAT_JPG=0 -DSUPPORT_FILEFORMAT_OGG=0 -DSUPPORT_FILEFORMAT_MP3=0,$(RAY_RAYLIB_CONFIG)) -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1 -DSUPPORT_FILEFORMAT_MP3=1
KRYON_WITH_KSYNC ?=
KRYON_WITH_DAOCHI ?= $(if $(strip $(KRYON_WITH_KSYNC)),$(KRYON_WITH_KSYNC),0)
ifeq ($(KRYON_WITH_DAOCHI),1)
KRYON_DAOCHI_CPPFLAGS = -DKRYON_WITH_DAOCHI=1 -DKRYON_WITH_KSYNC=1 -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE)
KRYON_DAOCHI_DEPS = $(KRYON_LIBOQS_A)
KRYON_DAOCHI_LDLIBS = $(KRYON_LIBOQS_A)
KRYON_DAOCHI_TESTS = $(KSYNC_ACCOUNT_TEST) $(KSYNC_SYNC_TEST) $(KSYNC_CRYPTO_TEST)
KRYON_STATIC_PACKAGE_DAOCHI_FILES ?= $(KRYON_LIBOQS_A)
KRYON_STATIC_PACKAGE_DAOCHI_LIBS ?= -loqs
KRYON_STATIC_PACKAGE_DAOCHI_CFLAGS ?= -DHAS_LIBOQS=1 -DKRYON_WITH_DAOCHI=1 -DKRYON_WITH_KSYNC=1
KRYON_STATIC_PACKAGE_DAOCHI_MANIFEST_LIBS ?= "liboqs.a",
KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_DEFS ?= ;HAS_LIBOQS=1;KRYON_WITH_DAOCHI=1;KRYON_WITH_KSYNC=1
KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_LIBS ?= "$${KRYON_PACKAGE_PREFIX}/lib/liboqs.a"
KRYON_WITH_SYNC ?= 0
ifeq ($(KRYON_WITH_SYNC),1)
KRYON_SYNC_CPPFLAGS = -DKRYON_WITH_SYNC=1 -DHAS_LIBOQS=1 \
$(KRYON_LIBOQS_INCLUDE) -Ivendor/monocypher/src \
-Ivendor/monocypher/src/optional
KRYON_SYNC_DEPS = $(KRYON_LIBOQS_A)
KRYON_SYNC_LDLIBS = $(KRYON_LIBOQS_A)
KRYON_SYNC_TESTS = $(SYNC_ACCOUNT_TEST) $(SYNC_TEST) $(SYNC_CRYPTO_TEST)
KRYON_STATIC_PACKAGE_SYNC_FILES ?= $(KRYON_LIBOQS_A)
KRYON_STATIC_PACKAGE_SYNC_LIBS ?= -loqs
KRYON_STATIC_PACKAGE_SYNC_CFLAGS ?= -DHAS_LIBOQS=1 -DKRYON_WITH_SYNC=1
KRYON_STATIC_PACKAGE_SYNC_MANIFEST_LIBS ?= "liboqs.a",
KRYON_STATIC_PACKAGE_SYNC_CMAKE_DEFS ?= ;HAS_LIBOQS=1;KRYON_WITH_SYNC=1
KRYON_STATIC_PACKAGE_SYNC_CMAKE_LIBS ?= "$${KRYON_PACKAGE_PREFIX}/lib/liboqs.a"
else
KRYON_DAOCHI_CPPFLAGS = -DKRYON_WITH_DAOCHI=0 -DKRYON_WITH_KSYNC=0
KRYON_DAOCHI_DEPS =
KRYON_DAOCHI_LDLIBS =
KRYON_DAOCHI_TESTS =
KRYON_STATIC_PACKAGE_DAOCHI_FILES ?=
KRYON_STATIC_PACKAGE_DAOCHI_LIBS ?=
KRYON_STATIC_PACKAGE_DAOCHI_CFLAGS ?= -DKRYON_WITH_DAOCHI=0 -DKRYON_WITH_KSYNC=0
KRYON_STATIC_PACKAGE_DAOCHI_MANIFEST_LIBS ?=
KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_DEFS ?= ;KRYON_WITH_DAOCHI=0;KRYON_WITH_KSYNC=0
KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_LIBS ?=
KRYON_SYNC_CPPFLAGS = -DKRYON_WITH_SYNC=0
KRYON_SYNC_DEPS =
KRYON_SYNC_LDLIBS =
KRYON_SYNC_TESTS =
KRYON_STATIC_PACKAGE_SYNC_FILES ?=
KRYON_STATIC_PACKAGE_SYNC_LIBS ?=
KRYON_STATIC_PACKAGE_SYNC_CFLAGS ?= -DKRYON_WITH_SYNC=0
KRYON_STATIC_PACKAGE_SYNC_MANIFEST_LIBS ?=
KRYON_STATIC_PACKAGE_SYNC_CMAKE_DEFS ?= ;KRYON_WITH_SYNC=0
KRYON_STATIC_PACKAGE_SYNC_CMAKE_LIBS ?=
endif
KRYON_STATIC_PACKAGE_EXTERNAL_LIBS ?= $(RAY_LDLIBS) $(KRYON_OPENSSL_SSL_LDLIB) $(KRYON_OPENSSL_CRYPTO_LDLIB) $(KRYON_ZLIB_LDLIB) -lpthread -lm
KRYON_STATIC_PACKAGE_LIBS ?= -lkryon -lraylib $(KRYON_STATIC_PACKAGE_DAOCHI_LIBS) -lcurl -lcmark-gfm-extensions -lcmark-gfm $(KRYON_STATIC_PACKAGE_EXTERNAL_LIBS)
KRYON_STATIC_PACKAGE_CFLAGS ?= -I$${includedir} $(KRYON_STATIC_PACKAGE_DAOCHI_CFLAGS) -DHAS_LIBCURL=1 -DCURL_STATICLIB -DKRYON_HAS_CMARK_GFM=1
KRYON_STATIC_PACKAGE_LIBS ?= -lkryon -lraylib $(KRYON_STATIC_PACKAGE_SYNC_LIBS) -lcurl -lcmark-gfm-extensions -lcmark-gfm $(KRYON_STATIC_PACKAGE_EXTERNAL_LIBS)
KRYON_STATIC_PACKAGE_CFLAGS ?= -I$${includedir} $(KRYON_STATIC_PACKAGE_SYNC_CFLAGS) -DHAS_LIBCURL=1 -DCURL_STATICLIB -DKRYON_HAS_CMARK_GFM=1
# Check if we're in nix-shell and use its flags
ifneq ($(NIX_CFLAGS_COMPILE),)
@@ -216,14 +217,14 @@ KRYON_VENDOR_BUILD_DIR ?= $(BUILD_DIR)/vendor
include mk/vendor.mk
include mk/raylib.mk
CPPFLAGS += $(KRYON_DAOCHI_CPPFLAGS) \
CPPFLAGS += $(KRYON_SYNC_CPPFLAGS) \
-DHAS_LIBCURL=1 $(KRYON_CURL_CFLAGS) \
$(KRYON_MARKDOWN_CFLAGS)
CPPFLAGS += $(KRYON_NOTIFICATION_CPPFLAGS) $(KRYON_NOTIFICATION_CFLAGS)
LDLIBS += $(KRYON_NOTIFICATION_LDLIBS)
SRCS := $(shell find src -type f -name '*.c' | LC_ALL=C sort)
KRYON_DAOCHI_SRCS_REL := $(wildcard src/ksync/*.c)
KRYON_SYNC_SRCS_REL := $(wildcard src/sync/*.c)
# Browser-only backend sources compile to empty translation units under native
# compilers and only link when their backend is selected; keep the find from
@@ -243,7 +244,7 @@ SRCS := $(filter-out $(KRYON_TERMI_SRCS),$(SRCS))
endif
SRCS += $(EMBED_ASSETS_C) $(KRYON_BACKEND_SRCS)
KRYON_PUBLIC_HEADERS := $(wildcard include/*.h)
KRYON_PUBLIC_HEADERS := $(wildcard include/*.h) $(wildcard include/sync/*.h)
# Drop the Box2D physics sources when physics is disabled (UI-only builds).
# Keep in sync with KRYON_PHYSICS_SRCS in mk/vendor.mk.
@@ -252,8 +253,8 @@ KRYON_PHYSICS_SRCS_REL := src/scene/physics_world.c src/scene/node_body2d.c \
ifeq ($(KRYON_WITH_PHYSICS),0)
SRCS := $(filter-out $(KRYON_PHYSICS_SRCS_REL),$(SRCS))
endif
ifneq ($(KRYON_WITH_DAOCHI),1)
SRCS := $(filter-out $(KRYON_DAOCHI_SRCS_REL),$(SRCS))
ifneq ($(KRYON_WITH_SYNC),1)
SRCS := $(filter-out $(KRYON_SYNC_SRCS_REL),$(SRCS))
endif
SYSTEM_THEME_PKG := $(shell if pkg-config --exists gtk+-3.0 2>/dev/null; then printf '%s' gtk+-3.0; fi)
@@ -265,9 +266,9 @@ endif
OBJS = $(patsubst src/%.c,$(BUILD_DIR)/%.o,$(filter src/%,$(SRCS))) \
$(patsubst $(BUILD_DIR)/%.c,$(BUILD_DIR)/%.o,$(filter $(BUILD_DIR)/%,$(SRCS)))
LIB = $(BUILD_DIR)/libkryon.a
KSYNC_ACCOUNT_TEST = $(BUILD_DIR)/tests/ksync_account_test
KSYNC_SYNC_TEST = $(BUILD_DIR)/tests/ksync_sync_test
KSYNC_CRYPTO_TEST = $(BUILD_DIR)/tests/ksync_crypto_test
SYNC_ACCOUNT_TEST = $(BUILD_DIR)/tests/sync_account_test
SYNC_TEST = $(BUILD_DIR)/tests/sync_test
SYNC_CRYPTO_TEST = $(BUILD_DIR)/tests/sync_crypto_test
TRANSITION_TEST = $(BUILD_DIR)/tests/transition_test
FILE_DIALOG_BACKEND_TEST = $(BUILD_DIR)/tests/file_dialog_backend_test
DESKTOP_TEST = $(BUILD_DIR)/tests/desktop_test
@@ -276,6 +277,7 @@ LINUX_DESKTOP_PACKAGE_TEST = $(BUILD_DIR)/tests/linux_desktop_package.ok
MARKDOWN_TEST = $(BUILD_DIR)/tests/markdown_test
ANDROID_SURFACE_TEST = $(BUILD_DIR)/tests/android_surface_test
UI_DPI_TEST = $(BUILD_DIR)/tests/ui_dpi_test
UI_DPI_DESKTOP_TEST = $(BUILD_DIR)/tests/ui_dpi_desktop_test
RAYLIB_COMPAT_TEST = $(BUILD_DIR)/tests/raylib_compat_test
TERMI_SMOKE_TEST = $(BUILD_DIR)/tests/termi_smoke_test
LIBDRAW_SMOKE_TEST = $(BUILD_DIR)/tests/libdraw_smoke_test
@@ -326,7 +328,7 @@ KRY_UPDATE_FLOW_TEST = $(BUILD_DIR)/tests/kry_update_flow_test
SFS_TEST = $(BUILD_DIR)/tests/sfs_test
RAYLIB_COMPAT_LDLIBS ?= $(KRYON_BACKEND_LDLIBS) -lpthread -lm $(if $(filter linux,$(KRYON_PLATFORM)),-ldl -lrt,)
.PHONY: all clean tools examples-run font-assets font-subsets docs-site test test-asan test-ubsan preflight spec-test perf-text-input perf-text-input-site bsd-check submodule-urls-check kryon-compat kryon-compat-check kryon-boundary-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check version release-check release-preflight dist-static check-static-package dist-tools check-tools-package install install-static k2c k2cpp k2go k2js k2js-runtime-snapshot-test canvas-test dom-test canvas-audio-test canvas2d-parity-check web-canvas-matrix-check termi-test libdraw-test libdraw-matrix-check libdraw-matrix-check-internal conformance-matrix-check renderer-matrix-check widget-matrix-check visual-comparison-matrix-check krb-web-matrix-check runtime-matrix-check downstream-matrix-check krb-web krb-sdl icons-import-mingcute icons-embed
.PHONY: all clean tools examples-run font-assets font-subsets docs-site test test-asan test-ubsan preflight spec-test perf-text-input perf-text-input-site bsd-check submodule-urls-check kryon-compat kryon-compat-check kryon-boundary-check clean-text-api-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check version release-check release-preflight dist-static check-static-package dist-tools check-tools-package install install-static k2c k2cpp k2go k2js k2js-runtime-snapshot-test canvas-test dom-test canvas-audio-test canvas2d-parity-check web-canvas-matrix-check termi-test libdraw-test libdraw-matrix-check libdraw-matrix-check-internal conformance-matrix-check renderer-matrix-check widget-matrix-check visual-comparison-matrix-check krb-web-matrix-check runtime-matrix-check downstream-matrix-check krb-web krb-sdl icons-import-mingcute icons-embed
k2c: $(K2C)
k2cpp: $(K2CPP)
@@ -395,7 +397,7 @@ raylib-matrix-check-internal: $(K2C) $(LIB) $(KRYON_BACKEND_LIBS)
--cc "$(CC)" \
--cppflags "$(CPPFLAGS)" \
--cflags "$(CFLAGS)" \
--ldinputs "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_DAOCHI_LDLIBS) $(KRYON_CURL_LDLIBS) $(KRYON_MARKDOWN_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
--ldinputs "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_SYNC_LDLIBS) $(KRYON_CURL_LDLIBS) $(KRYON_MARKDOWN_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
libdraw-matrix-check: $(K2C)
$(MAKE) --no-print-directory BUILD_DIR=$(BUILD_DIR)-libdraw KRYON_BACKEND=libdraw libdraw-matrix-check-internal
@@ -405,7 +407,7 @@ libdraw-matrix-check-internal: $(LIB)
--cc "$(CC)" \
--cppflags "$(CPPFLAGS)" \
--cflags "$(CFLAGS)" \
--ldinputs "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_BACKEND_LDLIBS) $(KRYON_DAOCHI_LDLIBS) $(KRYON_CURL_LDLIBS) $(KRYON_MARKDOWN_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)" \
--ldinputs "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_BACKEND_LDLIBS) $(KRYON_SYNC_LDLIBS) $(KRYON_CURL_LDLIBS) $(KRYON_MARKDOWN_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)" \
--plan9port-dir "$(PLAN9PORT_DIR)"
# Native web host for KRB cartridges: kry_sw rasterizer compiled to wasm,
@@ -488,19 +490,22 @@ k2js-runtime-snapshot-test: $(K2JS)
sh tests/k2js_runtime_snapshot_test.sh . $(BUILD_DIR) $(K2JS)
generated-runtime-parity-test: $(K2C) $(K2GO) $(K2JS) $(LIB) $(KRYON_BACKEND_LIBS)
sh tests/generated_runtime_parity_test.sh . $(BUILD_DIR) "$(CC)" "$(CPPFLAGS)" "$(CFLAGS)" "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_DAOCHI_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
sh tests/generated_runtime_parity_test.sh . $(BUILD_DIR) "$(CC)" "$(CPPFLAGS)" "$(CFLAGS)" "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_SYNC_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
preflight: submodule-urls-check kryon-compat-check kryon-boundary-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check runtime-parity-check feature-matrix-docs-check conformance-matrix-check k2js-runtime-snapshot-test generated-runtime-parity-test
preflight: submodule-urls-check kryon-compat-check kryon-boundary-check clean-text-api-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check runtime-parity-check feature-matrix-docs-check conformance-matrix-check k2js-runtime-snapshot-test generated-runtime-parity-test
git diff --check
test: submodule-urls-check kryon-compat-check kryon-boundary-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check runtime-parity-check feature-matrix-docs-check conformance-matrix-check dom-test $(K2C) $(K2CPP) $(K2GO) $(K2JS) $(K2KIR) $(K2B) $(KT) $(KRY_TOOLS_TEST) $(KRYON_DAOCHI_TESTS) $(TRANSITION_TEST) $(FILE_DIALOG_BACKEND_TEST) $(DESKTOP_TEST) $(INSTANCE_LOCK_TEST) $(LINUX_DESKTOP_PACKAGE_TEST) $(MARKDOWN_TEST) $(ANDROID_SURFACE_TEST) $(UI_DPI_TEST) $(RAYLIB_COMPAT_TEST) $(UI_TK_TEST) $(UI_PRIMARY_SELECTION_TEST) $(UI_PAGER_TEST) $(DROPDOWN_LAYOUT_TEST) $(DROPDOWN_THEME_SCREEN_TEST) $(BOTTOM_NAV_ICON_COLOR_TEST) $(DISMISSIBLE_OVERLAY_TEST) $(PREVIEW_TEST) $(PLATFORM_THREAD_TEST) $(OPEN_URI_TEST) $(UI_TEXT_EDIT_TEST) $(UI_TREE_API_TEST) $(UI_SWIPE_TEST) $(SPRITESHEET_TEST) $(APP_FRAMEWORK_TEST) $(APP_STORAGE_TEST) $(KRY_AUTOMATION_TEST) $(SCENE_TREE_TEST) $(SCENE_PROPERTY_TEST) $(ANIMATION_TEST) $(KIR_TEST) $(K2KIR_TEST) $(KRB_WALK_TEST) $(KRB_MOUNT_TEST) $(KRY_SW_TEST) $(KRB_LOGIC_TEST) $(KRB_ASSET_TEST) $(KRB_CAPS_TEST) $(KRB_RUN) $(TERMINAL_TEST) $(KRY_JSON_TEST) $(KRY_XML_TEST) $(KRY_GZIP_TEST) $(KRY_ZLIB_TEST) $(KRY_HTTP_TEST) $(RUNTIME_ASSETS_TEST) $(KRY_UPDATE_TEST) $(KRY_UPDATE_FLOW_TEST) $(KRY_SHA256_TEST) $(LOCALE_TEST) $(SFS_TEST) $(UI_WINDOW_TEST) $(SYSTEM_THEME_TEST) $(CURSOR_INTENT_TEST) $(TEXT_INPUT_PLATFORM_TEST) $(UI_WINDOW_SDL_CHECK)
clean-text-api-check:
python3 scripts/check-clean-text-api.py examples tests
test: submodule-urls-check kryon-compat-check kryon-boundary-check clean-text-api-check public-api-names-check public-api-snapshot-check public-headers-compile-check examples-manifest-check generated-provenance-check backend-capabilities-check runtime-parity-check feature-matrix-docs-check conformance-matrix-check dom-test $(K2C) $(K2CPP) $(K2GO) $(K2JS) $(K2KIR) $(K2B) $(KT) $(KRY_TOOLS_TEST) $(KRYON_SYNC_TESTS) $(TRANSITION_TEST) $(FILE_DIALOG_BACKEND_TEST) $(DESKTOP_TEST) $(INSTANCE_LOCK_TEST) $(LINUX_DESKTOP_PACKAGE_TEST) $(MARKDOWN_TEST) $(ANDROID_SURFACE_TEST) $(UI_DPI_TEST) $(UI_DPI_DESKTOP_TEST) $(RAYLIB_COMPAT_TEST) $(UI_TK_TEST) $(UI_PRIMARY_SELECTION_TEST) $(UI_PAGER_TEST) $(DROPDOWN_LAYOUT_TEST) $(DROPDOWN_THEME_SCREEN_TEST) $(BOTTOM_NAV_ICON_COLOR_TEST) $(DISMISSIBLE_OVERLAY_TEST) $(PREVIEW_TEST) $(PLATFORM_THREAD_TEST) $(OPEN_URI_TEST) $(UI_TEXT_EDIT_TEST) $(UI_TREE_API_TEST) $(UI_SWIPE_TEST) $(SPRITESHEET_TEST) $(APP_FRAMEWORK_TEST) $(APP_STORAGE_TEST) $(KRY_AUTOMATION_TEST) $(SCENE_TREE_TEST) $(SCENE_PROPERTY_TEST) $(ANIMATION_TEST) $(KIR_TEST) $(K2KIR_TEST) $(KRB_WALK_TEST) $(KRB_MOUNT_TEST) $(KRY_SW_TEST) $(KRB_LOGIC_TEST) $(KRB_ASSET_TEST) $(KRB_CAPS_TEST) $(KRB_RUN) $(TERMINAL_TEST) $(KRY_JSON_TEST) $(KRY_XML_TEST) $(KRY_GZIP_TEST) $(KRY_ZLIB_TEST) $(KRY_HTTP_TEST) $(RUNTIME_ASSETS_TEST) $(KRY_UPDATE_TEST) $(KRY_UPDATE_FLOW_TEST) $(KRY_SHA256_TEST) $(LOCALE_TEST) $(SFS_TEST) $(UI_WINDOW_TEST) $(SYSTEM_THEME_TEST) $(CURSOR_INTENT_TEST) $(TEXT_INPUT_PLATFORM_TEST) $(UI_WINDOW_SDL_CHECK)
sh tests/spec/spec_test.sh . $(BUILD_DIR)
sh tests/k2c_syntax_test.sh $(K2C)
sh tests/k2cpp_syntax_test.sh $(K2CPP)
sh tests/k2go_syntax_test.sh $(K2GO)
sh tests/k2js_syntax_test.sh $(K2JS)
sh tests/k2js_runtime_snapshot_test.sh . $(BUILD_DIR) $(K2JS)
sh tests/generated_runtime_parity_test.sh . $(BUILD_DIR) "$(CC)" "$(CPPFLAGS)" "$(CFLAGS)" "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_DAOCHI_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
sh tests/generated_runtime_parity_test.sh . $(BUILD_DIR) "$(CC)" "$(CPPFLAGS)" "$(CFLAGS)" "$(LIB) $(KRYON_BACKEND_LIBS) $(KRYON_SYNC_LDLIBS) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS)"
sh tests/kt_cli_test.sh $(KT)
sh tests/krb_cartridge_test.sh $(K2B) $(KRB_WALK_TEST) .
sh tests/krb_engine_test.sh $(K2B) $(KRB_RUN) .
@@ -522,10 +527,10 @@ test: submodule-urls-check kryon-compat-check kryon-boundary-check public-api-na
$(KRY_SHA256_TEST)
$(LOCALE_TEST)
$(SFS_TEST)
@if [ "$(KRYON_WITH_DAOCHI)" = "1" ]; then \
$(KSYNC_ACCOUNT_TEST); \
$(KSYNC_SYNC_TEST); \
$(KSYNC_CRYPTO_TEST); \
@if [ "$(KRYON_WITH_SYNC)" = "1" ]; then \
$(SYNC_ACCOUNT_TEST); \
$(SYNC_TEST); \
$(SYNC_CRYPTO_TEST); \
fi
$(TRANSITION_TEST)
$(FILE_DIALOG_BACKEND_TEST)
@@ -602,7 +607,7 @@ generated-provenance-check:
backend-capabilities-check:
sh tests/backend_capabilities_test.sh .
$(LIB): $(OBJS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_COMPAT_HEADER) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS) $(KRYON_PHYSICS_DEPS)
$(LIB): $(OBJS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_COMPAT_HEADER) $(KRYON_SYNC_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS) $(KRYON_PHYSICS_DEPS)
rm -f $@
$(AR) $(ARFLAGS) $@ $(OBJS)
@@ -648,7 +653,7 @@ $(KRYON_PREVIEW): cmd/kryon-preview/main.c $(LIB) $(KRYON_BACKEND_LIBS) | $(BUIL
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ cmd/kryon-preview/main.c \
-Wl,-export-dynamic \
-Wl,--whole-archive $(LIB) -Wl,--no-whole-archive \
$(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_BACKEND_LDLIBS) $(KRYON_DAOCHI_LDLIBS) \
$(KRYON_BACKEND_LIBS) $(KRYON_PHYSICS_DEPS) $(KRYON_BACKEND_LDLIBS) $(KRYON_SYNC_LDLIBS) \
$(KRYON_CURL_LDLIBS) $(KRYON_MARKDOWN_LDLIBS) \
$(CURL_CODEC_LDLIBS) $(LDLIBS) -lpthread -lm
@@ -687,11 +692,11 @@ install-static: $(STATIC_DIST_ARCHIVE)
mkdir -p $(DESTDIR)$(PREFIX)
tar -xzf $(STATIC_DIST_ARCHIVE) -C $(DESTDIR)$(PREFIX) --strip-components=1
$(STATIC_DIST_ARCHIVE): $(LIB) $(RAYLIB_A) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_A) $(KRYON_MARKDOWN_DEPS) README.md LICENSE THIRD_PARTY_NOTICES.md CHANGELOG.md docs/API.md examples/package/minimal.c examples/package/markdown.c scripts/check-static-package.sh
$(STATIC_DIST_ARCHIVE): $(LIB) $(RAYLIB_A) $(KRYON_SYNC_DEPS) $(KRYON_CURL_A) $(KRYON_MARKDOWN_DEPS) README.md LICENSE THIRD_PARTY_NOTICES.md CHANGELOG.md docs/API.md examples/package/minimal.c examples/package/markdown.c scripts/check-static-package.sh
rm -rf $(STATIC_DIST_ROOT)
mkdir -p $(STATIC_DIST_ROOT)/include $(STATIC_DIST_ROOT)/lib $(STATIC_DIST_ROOT)/lib/pkgconfig $(STATIC_DIST_ROOT)/lib/cmake/kryon $(STATIC_DIST_ROOT)/share/doc/kryon $(STATIC_DIST_ROOT)/share/licenses/kryon $(STATIC_DIST_ROOT)/examples $(DIST_DIR)
cp -R include/. $(STATIC_DIST_ROOT)/include/
cp $(LIB) $(RAYLIB_A) $(KRYON_STATIC_PACKAGE_DAOCHI_FILES) $(KRYON_CURL_A) $(KRYON_MARKDOWN_DEPS) $(STATIC_DIST_ROOT)/lib/
cp $(LIB) $(RAYLIB_A) $(KRYON_STATIC_PACKAGE_SYNC_FILES) $(KRYON_CURL_A) $(KRYON_MARKDOWN_DEPS) $(STATIC_DIST_ROOT)/lib/
cp README.md $(STATIC_DIST_ROOT)/
cp LICENSE $(STATIC_DIST_ROOT)/
cp LICENSE THIRD_PARTY_NOTICES.md $(STATIC_DIST_ROOT)/share/licenses/kryon/
@@ -705,7 +710,7 @@ $(STATIC_DIST_ARCHIVE): $(LIB) $(RAYLIB_A) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_A)
' "version": "$(VERSION)",' \
' "target": "$(KRYON_PLATFORM)-$(KRYON_ARCH)",' \
' "compiler": "$(CC)",' \
' "static_libraries": ["libkryon.a", "libraylib.a", $(KRYON_STATIC_PACKAGE_DAOCHI_MANIFEST_LIBS)"libcurl.a", "libcmark-gfm-extensions.a", "libcmark-gfm.a"],' \
' "static_libraries": ["libkryon.a", "libraylib.a", $(KRYON_STATIC_PACKAGE_SYNC_MANIFEST_LIBS)"libcurl.a", "libcmark-gfm-extensions.a", "libcmark-gfm.a"],' \
' "external_libraries": "$(KRYON_STATIC_PACKAGE_EXTERNAL_LIBS)",' \
' "pkg_config": "lib/pkgconfig/kryon.pc"' \
'}' > $(STATIC_DIST_ROOT)/manifest.json
@@ -725,10 +730,10 @@ $(STATIC_DIST_ARCHIVE): $(LIB) $(RAYLIB_A) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_A)
'include(CMakeFindDependencyMacro)' \
'get_filename_component(KRYON_PACKAGE_PREFIX "$${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)' \
'add_library(Kryon::kryon STATIC IMPORTED)' \
'set_target_properties(Kryon::kryon PROPERTIES IMPORTED_LOCATION "$${KRYON_PACKAGE_PREFIX}/lib/libkryon.a" INTERFACE_INCLUDE_DIRECTORIES "$${KRYON_PACKAGE_PREFIX}/include" INTERFACE_COMPILE_DEFINITIONS "HAS_LIBCURL=1;CURL_STATICLIB;KRYON_HAS_CMARK_GFM=1$(KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_DEFS)")' \
'set_target_properties(Kryon::kryon PROPERTIES IMPORTED_LOCATION "$${KRYON_PACKAGE_PREFIX}/lib/libkryon.a" INTERFACE_INCLUDE_DIRECTORIES "$${KRYON_PACKAGE_PREFIX}/include" INTERFACE_COMPILE_DEFINITIONS "HAS_LIBCURL=1;CURL_STATICLIB;KRYON_HAS_CMARK_GFM=1$(KRYON_STATIC_PACKAGE_SYNC_CMAKE_DEFS)")' \
'add_library(Kryon::raylib STATIC IMPORTED)' \
'set_target_properties(Kryon::raylib PROPERTIES IMPORTED_LOCATION "$${KRYON_PACKAGE_PREFIX}/lib/libraylib.a")' \
'set(Kryon_PACKAGE_LIBS $(KRYON_STATIC_PACKAGE_DAOCHI_CMAKE_LIBS)"$${KRYON_PACKAGE_PREFIX}/lib/libcurl.a" "$${KRYON_PACKAGE_PREFIX}/lib/libcmark-gfm-extensions.a" "$${KRYON_PACKAGE_PREFIX}/lib/libcmark-gfm.a")' \
'set(Kryon_PACKAGE_LIBS $(KRYON_STATIC_PACKAGE_SYNC_CMAKE_LIBS) "$${KRYON_PACKAGE_PREFIX}/lib/libcurl.a" "$${KRYON_PACKAGE_PREFIX}/lib/libcmark-gfm-extensions.a" "$${KRYON_PACKAGE_PREFIX}/lib/libcmark-gfm.a")' \
'set_target_properties(Kryon::kryon PROPERTIES INTERFACE_LINK_LIBRARIES "Kryon::raylib;$${Kryon_PACKAGE_LIBS}")' \
'set(Kryon_LIBRARIES Kryon::kryon Kryon::raylib $${Kryon_PACKAGE_LIBS})' \
> $(STATIC_DIST_ROOT)/lib/cmake/kryon/KryonConfig.cmake
@@ -752,22 +757,25 @@ $(TOOLS_DIST_ARCHIVE): tools README.md LICENSE THIRD_PARTY_NOTICES.md scripts/ch
'}' > $(TOOLS_DIST_ROOT)/manifest.json
tar -C $(BUILD_DIR)/dist -czf $@ $(notdir $(TOOLS_DIST_ROOT))
$(KSYNC_ACCOUNT_TEST): tests/ksync_account_test.c src/ksync/ksync_account.c src/ksync/ksync_crypto.c include/ksync_account.h include/ksync_crypto.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
$(SYNC_ACCOUNT_TEST): tests/sync_account_test.c src/sync/sync_account.c src/sync/sync_crypto.c src/sync/monocypher.c src/sync/monocypher_ed25519.c include/sync/account.h include/sync_crypto.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE) \
tests/ksync_account_test.c src/ksync/ksync_account.c src/ksync/ksync_crypto.c \
tests/sync_account_test.c src/sync/sync_account.c src/sync/sync_crypto.c \
src/sync/monocypher.c src/sync/monocypher_ed25519.c \
$(KRYON_LIBOQS_A) -lm -o $@
$(KSYNC_SYNC_TEST): tests/ksync_sync_test.c src/ksync/ksync_sync.c src/ksync/ksync_account.c src/ksync/ksync_crypto.c include/ksync_sync.h include/ksync_account.h include/ksync_crypto.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
$(SYNC_TEST): tests/sync_test.c src/sync/sync.c src/sync/sync_nodes.c src/sync/sync_account.c src/sync/sync_crypto.c src/sync/monocypher.c src/sync/monocypher_ed25519.c include/sync.h include/sync_nodes.h include/sync/account.h include/sync_crypto.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE) \
tests/ksync_sync_test.c src/ksync/ksync_sync.c src/ksync/ksync_account.c \
src/ksync/ksync_crypto.c \
tests/sync_test.c src/sync/sync.c src/sync/sync_nodes.c src/sync/sync_account.c \
src/sync/sync_crypto.c src/sync/monocypher.c \
src/sync/monocypher_ed25519.c \
$(KRYON_LIBOQS_A) -lm -o $@
$(KSYNC_CRYPTO_TEST): tests/ksync_crypto_test.c src/ksync/ksync_crypto.c include/ksync_crypto.h | $(BUILD_DIR)
$(SYNC_CRYPTO_TEST): tests/sync_crypto_test.c src/sync/sync_crypto.c include/sync_crypto.h src/sync/monocypher.c src/sync/monocypher_ed25519.c | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/ksync_crypto_test.c src/ksync/ksync_crypto.c -o $@
$(CC) $(CPPFLAGS) $(CFLAGS) tests/sync_crypto_test.c src/sync/sync_crypto.c \
src/sync/monocypher.c src/sync/monocypher_ed25519.c -o $@
$(TRANSITION_TEST): tests/transition_test.c src/ui/ui_transition.c include/ui_transition.h | $(BUILD_DIR)
@mkdir -p $(dir $@)
@@ -789,6 +797,11 @@ $(UI_DPI_TEST): tests/ui_dpi_test.c src/ui/ui_dpi.c include/ui_dpi.h | $(BUILD_D
$(CC) $(CPPFLAGS) $(CFLAGS) -DPLATFORM_ANDROID tests/ui_dpi_test.c \
src/ui/ui_dpi.c -o $@
$(UI_DPI_DESKTOP_TEST): tests/ui_dpi_test.c src/ui/ui_dpi.c include/ui_dpi.h | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/ui_dpi_test.c \
src/ui/ui_dpi.c -o $@
$(FILE_DIALOG_BACKEND_TEST): tests/file_dialog_backend_test.c src/file_dialog/file_dialog.c include/file_dialog.h | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/file_dialog_backend_test.c src/file_dialog/file_dialog.c $(LDLIBS) -o $@
@@ -883,6 +896,8 @@ $(BOTTOM_NAV_ICON_COLOR_TEST): tests/bottom_nav_icon_color_test.c $(LIB) $(KRYON
-Wl,--wrap=DrawTexturePro \
-Wl,--wrap=DrawRectangleRec \
-Wl,--wrap=DrawRectangleRounded \
-Wl,--wrap=DrawRectangleGradientV \
-Wl,--wrap=DrawRectangleRoundedLinesEx \
-Wl,--wrap=SetMouseCursor \
-Wl,--wrap=GetMousePosition \
-Wl,--wrap=IsMouseButtonReleased \
@@ -1149,11 +1164,11 @@ icons-import-mingcute: scripts/import-mingcute-icons.py
$(EMBED_ASSETS_C): $(EMBED_ASSET_FILES) scripts/embed-assets.sh include/embedded_assets.h | $(BUILD_DIR)
sh scripts/embed-assets.sh $@ $(EMBED_ASSETS)
$(BUILD_DIR)/%.o: src/%.c $(KRYON_PUBLIC_HEADERS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
$(BUILD_DIR)/%.o: src/%.c $(KRYON_PUBLIC_HEADERS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_SYNC_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(KRYON_PUBLIC_HEADERS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_DAOCHI_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(KRYON_PUBLIC_HEADERS) $(KRYON_BACKEND_STAMP) | $(BUILD_DIR) $(KRYON_SYNC_DEPS) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
+12 -5
View File
@@ -8,7 +8,7 @@ Kryon is a small C support library for raylib-style applications. It keeps a
raylib-compatible public surface available through `kryon.h`, then adds the
pieces shared by downstream apps: UI controls, Tk-style toolkit widgets, layout
helpers, text rendering, themes, embedded assets, locale loading, file dialogs,
desktop tray support, runtime asset downloads, and Ksync account/sync helpers.
desktop tray support, runtime asset downloads, and optional account/sync helpers.
## Layout
@@ -107,7 +107,7 @@ To integrate Kryon into your project:
3. Compile Kryon sources from `src/` and `src/ui/`, or use the `mk/` fragments
to let Kryon assemble source lists and platform flags
4. Kryon's checked-in `icons/` tree is the source of truth for the finished
MingCute Core Filled UI sheet, a separate full-color logo sheet, and the full-color platform,
MingCute Core UI sheet, a separate full-color logo sheet, and the full-color platform,
payment, language, tile, and profile sheets. `make icons-embed` refreshes the embedded C assets from
those sheets. Use `DrawIcon` or the generated `Icon` widget with a runtime
`Color`; no per-color files or per-icon textures are needed. Downstream apps
@@ -135,9 +135,9 @@ kryon package appimage
kryon preview
```
For local development against a sync backend, run a Ksync server in the
foreground. `dev-backend` locates the server source at `$KSYNC_DIR` or as a
sibling checkout (`../ksync`), isolates its data under `<project>/.kryon/`, and
For local development against a sync backend, run a Daochi node in the
foreground. `dev-backend` locates the server source at `$DAOCHI_DIR` or as a
sibling checkout (`../daochi`), isolates its data under `<project>/.kryon/`, and
prints the sync URL to point your app at. Tokens are regenerated each start,
so it is for local development only:
@@ -145,6 +145,13 @@ so it is for local development only:
kryon dev-backend # serves http://127.0.0.1:8080
```
Apps can keep startup simple with one `SyncNodePool`: add the shipped public
node as `SYNC_NODE_PUBLIC`, add LAN or remote nodes learned through explicit
pairing as `SYNC_NODE_PAIRED`, then call `RunSyncWithNodes`. The pool tries a
paired local node first, another paired node second, and the public node last.
Temporary connectivity and authentication failures fall through automatically;
credentials and clock state remain isolated per node.
App `project.kryon` files should use `target` entries that call `kryon`
rather than embedding platform-specific build commands directly. Existing app
Makefiles can remain as backend glue while repeated native, web, Android, and
+1 -1
View File
@@ -8,7 +8,7 @@ submodules listed in `SUBMODULES.txt`.
- curl/libcurl: curl license, see `vendor/curl/COPYING` in the source tree.
- cmark-gfm: BSD-style license, see `vendor/cmark-gfm/COPYING` in the source tree.
- Noto fonts: SIL Open Font License 1.1, see `fonts/noto/LICENSE.txt` in the source tree.
- MingCute Core Filled icons: Apache License 2.0, see
- MingCute Core icons: Apache License 2.0, see
`licenses/mingcute/LICENSE.txt` in the source tree. Kryon embeds only the
selected, renamed monochrome subset used by its UI in `icons/ui.png`.
Apache 2.0 does not grant rights to third-party trademarks depicted by some
+50 -35
View File
@@ -412,9 +412,9 @@ parse_coord(const char *expr, int *value, int *scaled)
}
}
}
if(strncmp(p, "ScaleUIPx(", 10) == 0) {
if(strncmp(p, "Scale(", 6) == 0) {
*scaled = 1;
p += 10;
p += 6;
}
if(*p == '-' || (*p >= '0' && *p <= '9')) {
*value = atoi(p);
@@ -596,6 +596,7 @@ static int
parse_text(KrbBuild *b, const char *call)
{
const char *args = strchr(call, '(');
const char *props = strstr(call, "TextProps");
char parts[8][KIR_TEXT_MAX];
int count;
KrbBuildNode *n;
@@ -604,6 +605,51 @@ parse_text(KrbBuild *b, const char *call)
if(args == NULL)
return 0;
if(props != NULL) {
const char *p;
snprintf(name, sizeof(name), "text%d", b->node_count);
n = add_node(b, 2, name);
if(n == NULL)
return 0;
p = strstr(props, ".text");
if(p != NULL) {
const char *value = strchr(p, '=');
value = value != NULL ? kir_skip_inline_ws(value + 1) : p;
if(*value == '"' || strstr(value, "TextFormat") != NULL)
extract_string(value, n->text, sizeof(n->text));
else {
char ident[KIR_NAME_MAX];
size_t length = 0;
while((isalnum((unsigned char)value[length]) || value[length] == '_') &&
length + 1 < sizeof(ident)) {
ident[length] = value[length];
length++;
}
ident[length] = '\0';
if(length > 0) {
snprintf(n->name, sizeof(n->name), "%s", ident);
snprintf(n->text, sizeof(n->text), "%%s");
}
}
}
p = strstr(props, ".bounds");
if(p != NULL) {
const char *brace = strchr(p, '{');
char fields[4][KIR_TEXT_MAX];
int fields_count = brace != NULL ? split_args(brace + 1, fields, 4) : 0;
if(fields_count > 0 && parse_coord(fields[0], &n->x, &scaled) && scaled) n->flags |= 1 << 2;
if(fields_count > 1 && parse_coord(fields[1], &n->y, &scaled) && scaled) n->flags |= 1 << 3;
if(fields_count > 2 && parse_coord(fields[2], &n->w, &scaled) && scaled) n->flags |= 1 << 4;
if(fields_count > 3 && parse_coord(fields[3], &n->h, &scaled) && scaled) n->flags |= 1 << 5;
}
p = strstr(props, ".font");
n->font_size = p != NULL ? font_size_of(strchr(p, '=') + 1) : 16;
p = strstr(props, ".color");
n->color = p != NULL ? parse_color(strchr(p, '=') + 1)
: (KRB_COLOR_THEME | KRY_THEME_TEXT);
return 1;
}
count = split_args(args + 1, parts, 8);
if(count < 1)
return 0;
@@ -1554,36 +1600,6 @@ parse_bevel(KrbBuild *b, const char *call)
return 1;
}
/* TextInRect(text, Rectangle, font, color) -> a TEXT node at the rect origin. */
static int
parse_textinrect(KrbBuild *b, const char *call)
{
const char *args = strchr(call, '(');
char parts[8][KIR_TEXT_MAX];
char name[32];
KrbBuildNode *n;
int count;
if(args == NULL)
return 0;
count = split_args(args + 1, parts, 8);
if(count < 2)
return 0;
snprintf(name, sizeof(name), "tir%d", b->node_count);
n = add_node(b, KRB_NODE_TEXT, name);
if(n == NULL)
return 0;
extract_string(parts[0], n->text, sizeof(n->text));
node_rect(n, parts[1]);
if(count > 2)
n->font_size = font_size_of(parts[2]);
if(count > 3)
n->color = parse_color(parts[3]);
else
n->color = KRB_COLOR_THEME | KRY_THEME_TEXT;
return 1;
}
static int
fit_of(const char *expr)
{
@@ -2923,7 +2939,7 @@ static int
is_kry_widget_call(const char *name)
{
static const char *const names[] = {
"Background", "Text", "TextInRect", "Paragraph", "TextLines",
"Background", "Text", "Paragraph", "TextLines",
"Rect", "Line", "Bevel", "Icon", "Picture", "Button",
"IconButton", "Href", "TextField", "TextArea", "Dropdown",
"Slider", "Toggle", "Checkbox", "Radio", "Progress", "Spinbox",
@@ -2959,7 +2975,6 @@ parse_widget_from_table(KrbBuild *b, const char *call)
{ "Separator", parse_separator },
{ "Line", parse_line },
{ "Bevel", parse_bevel },
{ "TextInRect", parse_textinrect },
{ "Picture", parse_picture },
{ "Checkbox", parse_checkbox },
{ "Radio", parse_radio },
@@ -3004,7 +3019,7 @@ try_widget(KrbBuild *b, const char *raw)
if(is_krb_layout_call(call))
return 1;
if(starts_ident(call, "Text") && !starts_ident(call, "TextFormat") &&
!starts_ident(call, "TextInRect") && !starts_ident(call, "TextLines") &&
!starts_ident(call, "TextLines") &&
!starts_ident(call, "TextField") &&
!starts_ident(call, "TextArea"))
return parse_text(b, call);
+57 -10
View File
@@ -59,13 +59,14 @@ is_runtime_go_type(const char *type)
{
static const char *types[] = {
"Vector2", "Rectangle", "Color", "Texture2D", "KeyID", "Side",
"Accelerator",
"MenuItemKind", "MenuItem", "Menu", "MenuBarResult", "ContextMenuProps",
"ButtonStyle", "SyntaxMode", "ThemeStyle", "ThemeSource",
"ThemeMode", "UIThemeSettingsState", "ThemeSettingsProps",
"UIThemeSettingsResult", "PictureFit", "UISemanticKind",
"TextInputStyle", "ButtonProps", "SelectableProps", "CheckboxFlagsProps",
"ImageWithBgProps", "ImageButtonProps", "IconButtonProps", "HrefProps",
"TabItemButtonProps", "Tab", "ClosableTabBarProps",
"TabItemButtonProps", "Tab", "TabBarProps", "ClosableTabBarProps",
"TextFieldProps", "TextAreaProps", "ColumnProps", "RowProps",
"FrameBox", "Grid", "ParagraphSpec", "PictureProps", "PageProps",
"CarouselControlsProps",
@@ -76,10 +77,11 @@ is_runtime_go_type(const char *type)
"DragIntRange2Props", "SliderFloatProps", "SliderIntProps",
"SliderAngleProps",
"InputFloatProps", "InputIntProps", "InputDoubleProps",
"InvisibleButtonProps", "SeparatorTextProps", "DragDropSourceProps",
"InvisibleButtonProps", "TextProps", "SeparatorTextProps", "DragDropSourceProps",
"DragDropTargetProps", "MultiSelectListProps", "ArrowButtonProps",
"ColorEditProps", "ColorButtonProps", "TooltipProps",
"SpinboxProps", "ComboboxProps", "LabelFrameProps", "ListBoxProps",
"ColorEditProps", "ColorButtonProps",
"SpinboxProps", "ComboboxProps", "ComboFlags", "ComboProps", "PopupFlags", "PopupProps",
"LabelFrameProps", "ListBoxProps",
"UITreeItem", "TreeViewProps",
"SourceViewProps", "TableRow", "TableViewProps", "NotebookProps",
"PanedViewProps", "CollapsibleProps", "MessageDialogProps",
@@ -860,7 +862,7 @@ props_field_at(const char *type, int index)
{
static const struct {
const char *type;
const char *fields[24];
const char *fields[40];
} table[] = {
{"ColumnProps", {"Bounds", "Gap", "Padding", "Key"}},
{"CarouselControlsProps", {"Bounds", "Indicators", "Count", "Selected", "Move", "Disabled", "ID"}},
@@ -883,7 +885,7 @@ props_field_at(const char *type, int index)
{"HrefProps", {"Bounds", "Text", "Href", "Font", "FocusID",
"Disabled", "Color", "HoverColor"}},
{"ParagraphSpec", {"Text", "IconType", "IconSize", "Width",
"Font", "LineGap", "Color"}},
"Font", "LineGap", "Color", "Align"}},
{"ButtonProps", {"Bounds", "Label", "Style", "Font", "ID",
"Disabled"}},
{"SelectableProps", {"Bounds", "ID", "Label", "Selected", "Disabled"}},
@@ -894,8 +896,14 @@ props_field_at(const char *type, int index)
{"TabItemButtonProps", {"Bounds", "ID", "Label", "Font", "Disabled"}},
{"Tab", {"Label", "Icon", "IconSize", "Disabled", "Accent", "Italic",
"Closeable"}},
{"TabBarProps", {"Bounds", "Tabs", "Count", "SelectedIndex", "Font",
"MinTabWidth", "MaxTabWidth", "ScrollOffset",
"FocusSelected", "ClosedIndex", "DoubleClickedIndex",
"ReorderedFromIndex", "ReorderedToIndex",
"SelectedTabBounds", "MiddleClickedIndex", "ID",
"Disabled"}},
{"ClosableTabBarProps", {"Bounds", "Tabs", "Count", "SelectedIndex",
"Font", "ClosedIndex"}},
"Font", "ClosedIndex", "ID", "Disabled"}},
{"RadioButtonProps", {"Bounds", "Label", "ID", "Checked",
"Disabled"}},
{"ProgressBarProps", {"Bounds", "Min", "Max", "Value", "Label"}},
@@ -924,6 +932,7 @@ props_field_at(const char *type, int index)
{"InputDoubleProps", {"Bounds", "ID", "Label", "Values", "ValueCount",
"Step", "StepFast", "Format", "Disabled"}},
{"InvisibleButtonProps", {"Bounds", "ID", "Disabled"}},
{"TextProps", {"Bounds", "Text", "Font", "Color", "Wrap", "Align", "VerticalAlign", "Disabled"}},
{"SeparatorTextProps", {"Bounds", "Label", "Font", "Disabled"}},
{"DragDropSourceProps", {"Bounds", "ID", "Type", "Data", "DataSize",
"Disabled"}},
@@ -936,7 +945,6 @@ props_field_at(const char *type, int index)
{"ColorEditProps", {"Bounds", "ID", "Label", "Values", "ValueCount",
"Disabled"}},
{"ColorButtonProps", {"Bounds", "ID", "Label", "Color", "Disabled"}},
{"TooltipProps", {"Trigger", "Text", "Font", "MaxWidth", "Disabled"}},
{"MenuItem", {"Kind", "Label", "Accelerator", "ID", "Disabled",
"Checked", "Submenu", "SubmenuCount"}},
{"Menu", {"Bounds", "Label", "Items", "ItemCount"}},
@@ -947,6 +955,10 @@ props_field_at(const char *type, int index)
"Disabled", "ValueText", "Wrap"}},
{"ComboboxProps", {"Bounds", "ID", "Options", "OptionCount",
"SelectedIndex", "Disabled"}},
{"ComboProps", {"Bounds", "PopupSize", "Preview", "ID", "Open",
"Flags", "Disabled"}},
{"PopupProps", {"Bounds", "ID", "Open", "Disabled", "Trigger", "Flags"}},
{"Accelerator", {"Key", "Ctrl", "Shift", "Alt", "ID"}},
{"TextFieldProps", {"Bounds", "Text", "TextSize", "CursorPosition",
"Focused", "MaxCodepoints", "Font", "FocusID",
"Style", "Filter", "FilterUserData",
@@ -972,7 +984,10 @@ props_field_at(const char *type, int index)
"RightClickedColumn", "SortColumn",
"ScrollOffset", "RowHeight", "ColumnEnabled",
"ColumnOrder", "SortDirection", "Disabled",
"Resizable", "MinColumnWidth", "FreezeRows"}},
"Resizable", "MinColumnWidth", "FreezeRows",
"HeaderHeight", "HeaderAngle", "CustomCells",
"CopyText", "PastedText", "PastedRow",
"PastedColumn"}},
{"TableRow", {"Cells", "CellCount", "TextColors",
"BackgroundColors"}},
{"Canvas", {"Bounds", "ScrollX", "ScrollY", "Zoom"}},
@@ -1153,7 +1168,8 @@ slice_prop_field(const char *type, const char *field)
return 1;
if(strcmp(type, "NotebookProps") == 0 && strcmp(field, "Tabs") == 0)
return 1;
if(strcmp(type, "ClosableTabBarProps") == 0 && strcmp(field, "Tabs") == 0)
if((strcmp(type, "TabBarProps") == 0 ||
strcmp(type, "ClosableTabBarProps") == 0) && strcmp(field, "Tabs") == 0)
return 1;
if(strcmp(type, "DragDropSourceProps") == 0 && strcmp(field, "Data") == 0)
return 1;
@@ -1467,6 +1483,12 @@ tx_compound(const KirModule *m, const char *p, char *dst, size_t *dn)
snprintf(rect, sizeof(rect), "(Rectangle)%s", kir_skip_ws(part));
tx_expr(m, rect, value, sizeof(value));
} else if(strcmp(field, "Color") == 0 &&
*kir_skip_ws(part) == '{') {
char color[K2GO_TEXT_MAX];
snprintf(color, sizeof(color), "(Color)%s", kir_skip_ws(part));
tx_expr(m, color, value, sizeof(value));
} else {
tx_expr(m, part, value, sizeof(value));
}
@@ -1484,6 +1506,12 @@ tx_compound(const KirModule *m, const char *p, char *dst, size_t *dn)
char rect[K2GO_TEXT_MAX];
snprintf(rect, sizeof(rect), "(Rectangle)%s", kir_skip_ws(eq + 1));
tx_expr(m, rect, value, sizeof(value));
} else if(strcmp(field, "Color") == 0 &&
*kir_skip_ws(eq + 1) == '{') {
char color[K2GO_TEXT_MAX];
snprintf(color, sizeof(color), "(Color)%s", kir_skip_ws(eq + 1));
tx_expr(m, color, value, sizeof(value));
} else {
tx_expr(m, kir_skip_ws(eq + 1), value, sizeof(value));
}
@@ -1891,11 +1919,30 @@ tx_expr(const KirModule *m, const char *src, char *dst, size_t dst_size)
{"Text24", "Text24"},
{"Text32", "Text32"},
{"Text48", "Text48"},
{"TextWrapAuto", "TextWrapAuto"},
{"TextWrapNone", "TextWrapNone"},
{"TextAlignStart", "TextAlignStart"},
{"TextAlignCenter", "TextAlignCenter"},
{"TextAlignEnd", "TextAlignEnd"},
{"ButtonStylePrimary", "ButtonStylePrimary"},
{"ButtonStyleSecondary", "ButtonStyleSecondary"},
{"ButtonStyleDanger", "ButtonStyleDanger"},
{"ButtonStyleTab", "ButtonStyleTab"},
{"ButtonStyleTabSelected", "ButtonStyleTabSelected"},
{"ComboFlagsNone", "ComboFlagsNone"},
{"ComboPopupAlignLeft", "ComboPopupAlignLeft"},
{"ComboHeightSmall", "ComboHeightSmall"},
{"ComboHeightRegular", "ComboHeightRegular"},
{"ComboHeightLarge", "ComboHeightLarge"},
{"ComboHeightLargest", "ComboHeightLargest"},
{"ComboNoArrowButton", "ComboNoArrowButton"},
{"ComboNoPreview", "ComboNoPreview"},
{"ComboWidthFitPreview", "ComboWidthFitPreview"},
{"PopupFlagsNone", "PopupFlagsNone"},
{"PopupTooltip", "PopupTooltip"},
{"PopupModal", "PopupModal"},
{"PopupContext", "PopupContext"},
{"KEY_C", "KeyC"},
{"MenuCommand", "MenuCommand"},
{"MenuCheck", "MenuCheck"},
{"MenuRadio", "MenuRadio"},
+10 -1
View File
@@ -660,7 +660,8 @@ condition_is_widget_call(const char *cond, char *widget, size_t widget_size,
{
static const char *const widgets[] = {
"Button", "IconButton", "Checkbox", "Dropdown", "ListBox",
"Radio", "Slider", "TableView", "TextField", "Toggle"
"Radio", "Slider", "TableView", "TextField", "Toggle",
"BeginTabBar", "BeginTabItem"
};
char name[K2JS_NAME_MAX];
@@ -901,6 +902,14 @@ lower_function(FILE *f, const KirModule *m, const KirFunction *fn,
}
break;
}
if(split_direct_call(raw, name, sizeof(name), args, sizeof(args)) &&
(strcmp(name, "EndTabItem") == 0 || strcmp(name, "EndTabBar") == 0)) {
emit_indent(f, indent);
fprintf(f, "kryon.widget(rt, ");
js_string(f, name);
fprintf(f, ", \"\", state);\n");
break;
}
if(strncmp(raw, "BeginTree", 9) == 0 ||
strncmp(raw, "EndTree", 7) == 0)
break;
+24 -4
View File
@@ -351,14 +351,13 @@ parse_widget_statement(const char *text, char *name, size_t name_size,
char *args, size_t args_size)
{
static const char *const widgets[] = {
"Background", "Text", "TextInRect", "TextColored", "TextDisabled",
"TextWrapped", "LabelText", "BulletText", "ValueBool", "ValueInt",
"Background", "Text", "LabelText", "BulletText", "ValueBool", "ValueInt",
"ValueUInt", "ValueFloat", "Paragraph", "TextLines",
"Rect", "Line", "Bevel", "Icon", "Picture", "Button", "Selectable",
"CheckboxFlags", "ImageWithBg", "ImageButton", "SmallButton",
"InvisibleButton", "ArrowButton", "Bullet", "Separator", "SeparatorText",
"ColorEdit3",
"ColorEdit4", "ColorPicker3", "ColorPicker4", "ColorButton", "Tooltip", "IconButton",
"ColorEdit4", "ColorPicker3", "ColorPicker4", "ColorButton", "IconButton",
"Href", "TextField", "TextArea", "Dropdown", "Slider", "MenuBar",
"PopupMenu", "ContextMenu",
"Toggle", "Checkbox", "Radio", "Progress", "PlotLines",
@@ -463,6 +462,12 @@ ui_block_prop_type(const char *widget)
/* A lexical scope, not a runtime props type or another widget API. */
if(strcmp(widget, "Disabled") == 0 || strcmp(widget, "Scroll") == 0)
return "";
if(strcmp(widget, "Combo") == 0)
return "ComboProps";
if(strcmp(widget, "Popup") == 0)
return "PopupProps";
if(strcmp(widget, "Text") == 0)
return "TextProps";
if(strcmp(widget, "Row") == 0)
return "RowProps";
if(strcmp(widget, "Screen") == 0 || strcmp(widget, "Column") == 0 ||
@@ -656,6 +661,19 @@ ui_block_open(KirFunction *fn, UiBlock *block, KirSourceSpan span)
block->opened = 1;
return;
}
if(strcmp(block->widget, "Combo") == 0 ||
strcmp(block->widget, "Popup") == 0) {
const char *type = strcmp(block->widget,"Combo") == 0 ?
"ComboProps" : "PopupProps";
snprintf(args, sizeof(args), "(%s){%.3800s}", type, block->props);
snprintf(call, sizeof(call), "if Begin%s(%.3900s) {",
block->widget,args);
KirFunctionAddStmt(fn, KIR_STMT_IF, call, "", span);
snprintf(call,sizeof(call),"defer End%s()",block->widget);
KirFunctionAddStmt(fn, KIR_STMT_DEFER, call, "", span);
block->opened = 1;
return;
}
prop_type = ui_block_prop_type(block->widget);
if(prop_type == NULL)
return;
@@ -2510,7 +2528,9 @@ kir_parse_file(const char *path, const char *root)
ui_block_open(fn, block, KirSpan(rel, line_no, 1));
if(strcmp(block->widget, "Disabled") == 0 ||
strcmp(block->widget, "Scroll") == 0)
strcmp(block->widget, "Scroll") == 0 ||
strcmp(block->widget, "Combo") == 0 ||
strcmp(block->widget, "Popup") == 0)
KirFunctionAddStmt(fn, KIR_STMT_BLOCK_CLOSE, "}", "",
KirSpan(rel, line_no, 1));
else if(block->emits_end)
+2 -2
View File
@@ -118,8 +118,8 @@ button is clicked; Kryon should decide whether pointer input is captured.
## Custom Modal Pattern
```c
int modal_w = ScaleUIPx(320);
int modal_h = ScaleUIPx(240);
int modal_w = Scale(320);
int modal_h = Scale(240);
int modal_x = (view_width - modal_w) / 2;
int modal_y = (view_height - modal_h) / 2;
+304 -75
View File
@@ -169,6 +169,53 @@ nested input/clipping, wheel scrolling, scrollbar dragging and parent restoratio
C++ syntax tests cover the shared lowering. This native scope is not yet
behaviorally verified in the JS runner.
### Composed combo blocks in native `.kry` code
Use a `Combo` block when the popup contains caller-defined widgets:
```kry
Combo commands: {
bounds = {20, 20, 180, 32}
popup_size = (Vector2){260, 160}
preview = "Commands"
id = 4200
open = &commands_open
flags = ComboPopupAlignLeft | ComboHeightSmall
Row actions: {
Button { label = "Run" }
TextField { text = query }
}
}
```
The block conditionally submits its children only while open. The compiler
emits `BeginCombo` and a matching `EndCombo` through the shared lexical cleanup
pass, including `return`, `break`, and `continue`, so application source cannot
forget the closing call. Call `CloseCombo()` inside the block for explicit
dismissal. The properties are the fields of `ComboProps`; generated C, C++ and
native Go target the same runtime scope.
Use a `Popup` block for arbitrary caller-owned popup contents without a combo
owner:
```kry
Popup tools: {
bounds = {170, 50, 240, 140}
id = 4201
open = &tools_open
Column content: {
Text { text = "Tools" }
Button { label = "Apply" }
}
}
```
`Popup` has the same conditional, cleanup-managed block behavior as `Combo`.
Call `ClosePopup()` inside the block for explicit dismissal. Its properties are
the fields of `PopupProps`.
### Runtime surface
Kryon owns the public app-facing API. The default backend still implements much
@@ -210,7 +257,10 @@ Settings :: (viewport: Rectangle) #ui {
gap = 12
padding = 16
Text("Account", 0, 0, Text24, GetThemeText())
Text((TextProps){
.text = "Account"
.font = Text24
})
TextField(account_field)
Button(save_button)
}
@@ -275,7 +325,7 @@ Page((PageProps){
.bounds = {0, 0, GetUIViewWidth(), GetUIViewHeight()},
.title = "Kryon",
.description = "Native-feeling apps across desktop and web.",
.gap = ScaleUIPx(16),
.gap = Scale(16),
.padding = GetUIPageSidePadding(),
.key = Key("home")
});
@@ -338,12 +388,12 @@ Get the current DPI scale factor.
float GetUIScale(void);
```
#### `ScaleUIPx`
#### `Scale`
Scale a pixel value by the DPI factor.
```c
int ScaleUIPx(int px);
int Scale(int px);
```
#### `ClampUIPx`
@@ -521,7 +571,40 @@ int TextLineHeight(int font_size);
#### Text Widgets
```c
void Text(const char *text, int x, int y, int font_size, Color color);
typedef enum { TextWrapAuto, TextWrapNone } TextWrap;
typedef enum { TextAlignStart, TextAlignCenter, TextAlignEnd } TextAlign;
typedef struct {
Rectangle bounds;
const char *text;
int font;
Color color;
TextWrap wrap;
TextAlign align;
TextAlign vertical_align;
int disabled;
} TextProps;
void Text(TextProps text);
```
`Text` is the single read-only text widget. A positive bounds width enables
word wrapping by default, and a positive height clips the result. Set
`wrap = TextWrapNone` for one line; `align` and `vertical_align` control its
placement inside the bounds.
Zero width measures the line intrinsically. Zero font and transparent color
select the current UI defaults. Color and disabled presentation are properties,
not separate widget entry points.
Native `.kry` can use the same properties without a compound literal:
```kry
Text message: {
bounds = {24, 24, 240, 64}
text = "This wraps and clips inside its bounds."
font = Text16
color = GetThemeText()
}
```
#### Vertical Centering
@@ -611,7 +694,7 @@ void DrawIconByName(const char *name, Rectangle bounds, Color tint);
Kryon's checked-in `icons/` directory is the finished spritesheet package.
Regular UI entries—including workbook controls—use the rounded MingCute Core
Filled family and are packed into the monochrome `icons/ui.png`. The manifest
family and are packed into the monochrome `icons/ui.png`. The manifest
records each upstream SVG mapping and revision. There are no prebuilt flat-color
variants; runtime drawing can tint the clean alpha artwork on demand.
Product and project marks retain their brand colors, stay out of the generic UI
@@ -630,11 +713,11 @@ indexed icon catalog with their existing `UI_ICON_TYPE_*` values. Use
`GetUIProfilePictureIconType`, and `GetUIProfilePictureIconName` to enumerate
the standard profile-picture options.
Kryon also exposes stable `UI_KSYNC_PROFILE_ICON_*` IDs and mapping helpers:
Kryon also exposes stable `UI_SYNC_PROFILE_ICON_*` IDs and mapping helpers:
```c
UIIconType GetUIProfilePictureIconTypeForKsyncID(int ksync_id);
int GetUIKsyncIDForProfilePictureIconType(UIIconType type);
UIIconType GetUIProfilePictureIconTypeForSyncID(int sync_id);
int GetUISyncIDForProfilePictureIconType(UIIconType type);
```
Use those IDs for server storage or sync payloads instead of generated
@@ -761,47 +844,47 @@ int GetCurrentLocaleIndex(void);
### Sync
Ksync Sync is Kryon's common sync protocol layer. Kryon owns URL handling, token auth,
Sync Sync is Kryon's common sync protocol layer. Kryon owns URL handling, token auth,
challenge/login, bearer requests, sync posting, account deletion, and small JSON
helpers, and default platform transport. Applications still own their local data
model and provide callbacks to build sync payloads, apply sync responses, and
store auth tokens.
#### `KsyncSyncResult`
#### `SyncResult`
```c
typedef enum KsyncSyncResult {
KSYNC_SYNC_OK = 0,
KSYNC_SYNC_INVALID_URL,
KSYNC_SYNC_NO_ACCOUNT,
KSYNC_SYNC_PAYLOAD_FAILED,
KSYNC_SYNC_CHALLENGE_FAILED,
KSYNC_SYNC_SIGN_FAILED,
KSYNC_SYNC_REQUEST_FAILED,
KSYNC_SYNC_AUTH_FAILED
} KsyncSyncResult;
typedef enum SyncResult {
SYNC_OK = 0,
SYNC_INVALID_URL,
SYNC_NO_ACCOUNT,
SYNC_PAYLOAD_FAILED,
SYNC_CHALLENGE_FAILED,
SYNC_SIGN_FAILED,
SYNC_REQUEST_FAILED,
SYNC_AUTH_FAILED
} SyncResult;
```
#### `KsyncSyncConfig`
#### `SyncConfig`
```c
typedef struct KsyncSyncConfig {
typedef struct SyncConfig {
const char *base_url;
const KsyncAccount *account;
const SyncAccount *account;
const char *client_id;
KsyncSyncHttpRequestFn http_request;
KsyncSyncGetTextFn get_text;
KsyncSyncSetTextFn set_text;
KsyncSyncBuildPayloadFn build_payload;
KsyncSyncFreePayloadFn free_payload;
KsyncSyncApplyResponseFn apply_response;
KsyncSyncVoidFn purge_synced_deleted;
KsyncSyncLogFn log_http_failure;
SyncHttpRequestFn http_request;
SyncGetTextFn get_text;
SyncSetTextFn set_text;
SyncBuildPayloadFn build_payload;
SyncFreePayloadFn free_payload;
SyncApplyResponseFn apply_response;
SyncVoidFn purge_synced_deleted;
SyncLogFn log_http_failure;
void *user;
} KsyncSyncConfig;
} SyncConfig;
```
`http_request` can be app-provided, or set to `KsyncDefaultHttpRequest` for
`http_request` can be app-provided, or set to `DefaultSyncHttpRequest` for
Kryon's built-in libcurl/JNI/fetch transport.
`get_text` and `set_text` store `sync_auth_token` and
`sync_auth_token_expires_at`.
@@ -809,11 +892,11 @@ Kryon's built-in libcurl/JNI/fetch transport.
#### URL Helpers
```c
int IsKsyncSyncURLValid(const char *url);
int NormalizeKsyncSyncURL(const char *input, char *out, size_t out_size);
int JoinKsyncSyncURL(char *out, size_t out_size,
int IsSyncURLValid(const char *url);
int NormalizeSyncURL(const char *input, char *out, size_t out_size);
int JoinSyncURL(char *out, size_t out_size,
const char *base_url, const char *path);
int JoinKsyncSyncWebSocketURL(char *out, size_t out_size,
int JoinSyncWebSocketURL(char *out, size_t out_size,
const char *base_url, const char *path);
```
@@ -823,71 +906,71 @@ Remote sync URLs must be HTTPS. HTTP is accepted only for loopback hosts such as
#### Buffer And JSON Helpers
```c
int AppendKsyncSyncBuffer(KsyncSyncBuffer *buffer,
int AppendSyncBuffer(SyncBuffer *buffer,
const void *data, size_t bytes);
int AppendKsyncSyncBufferJSONString(KsyncSyncBuffer *buffer,
int AppendSyncBufferJSONString(SyncBuffer *buffer,
const char *text);
void FreeKsyncSyncBuffer(KsyncSyncBuffer *buffer);
int FindKsyncSyncJSONString(const char *json, const char *key,
void FreeSyncBuffer(SyncBuffer *buffer);
int FindSyncJSONString(const char *json, const char *key,
char *out, size_t out_size);
long long FindKsyncSyncJSONInt64(const char *json, const char *key,
long long FindSyncJSONInt64(const char *json, const char *key,
long long fallback);
```
These are intentionally small helpers for Ksync protocol payload construction and
These are intentionally small helpers for Sync protocol payload construction and
simple response fields. Applications that already have a full JSON parser should
keep using it for domain data.
#### Auth And Sync
```c
void ClearKsyncSyncAuthToken(const KsyncSyncConfig *cfg);
KsyncSyncResult LoginKsyncSync(const KsyncSyncConfig *cfg);
KsyncSyncResult RunKsyncSync(const KsyncSyncConfig *cfg);
KsyncSyncResult RequestKsyncSyncBearer(const KsyncSyncConfig *cfg,
void ClearSyncAuthToken(const SyncConfig *cfg);
SyncResult LoginSync(const SyncConfig *cfg);
SyncResult RunSync(const SyncConfig *cfg);
SyncResult RequestSyncBearer(const SyncConfig *cfg,
const char *method,
const char *path,
const char *body,
char *out,
size_t out_size);
KsyncSyncResult DeleteKsyncSyncAccount(const KsyncSyncConfig *cfg);
const char *GetKsyncSyncResultName(KsyncSyncResult result);
SyncResult DeleteSyncAccount(const SyncConfig *cfg);
const char *GetSyncResultName(SyncResult result);
```
`RunKsyncSync` loads or refreshes an auth token, asks the app callback for
`RunSync` loads or refreshes an auth token, asks the app callback for
a local-first payload, posts it to `/api/v1/sync`, applies the response through
the callback, and purges synced tombstones on success. `RequestKsyncSyncBearer`
is for app-specific Ksync endpoints that use the same account token.
the callback, and purges synced tombstones on success. `RequestSyncBearer`
is for app-specific Sync endpoints that use the same account token.
#### Default Transport And Events
```c
int KsyncDefaultHttpRequest(const char *method, const char *url,
int DefaultSyncHttpRequest(const char *method, const char *url,
const char *body,
const char *const *headers,
int header_count,
KsyncSyncBuffer *response,
SyncBuffer *response,
long *status, void *user);
KsyncSyncResult KsyncRemoteEventWait(const KsyncSyncConfig *cfg,
SyncResult WaitForRemoteSyncEvent(const SyncConfig *cfg,
const char *path);
#if defined(__EMSCRIPTEN__)
int KsyncWebSyncStart(const KsyncSyncConfig *cfg);
int KsyncWebSyncPoll(KsyncSyncResult *result, int *changed);
int KsyncWebRemoteEventsStart(const KsyncSyncConfig *cfg, const char *path);
int KsyncWebRemoteEventsPoll(void);
int StartWebSync(const SyncConfig *cfg);
int PollWebSync(SyncResult *result, int *changed);
int StartWebRemoteEvents(const SyncConfig *cfg, const char *path);
int PollWebRemoteEvents(void);
#endif
```
`KsyncDefaultHttpRequest` provides the common platform HTTP transport. Native
`DefaultSyncHttpRequest` provides the common platform HTTP transport. Native
builds use libcurl, Android builds call `syncHttpRequest`/`syncWebSocketWait` on
the activity through JNI, and web builds use JavaScript `fetch`.
`KsyncRemoteEventWait` waits for one Ksync WebSocket sync-change event using the
stored bearer token. Web builds use the nonblocking `KsyncWebRemoteEventsStart`
and `KsyncWebRemoteEventsPoll` pair instead.
`WaitForRemoteSyncEvent` waits for one Sync WebSocket sync-change event using the
stored bearer token. Web builds use the nonblocking `StartWebRemoteEvents`
and `PollWebRemoteEvents` pair instead.
`KsyncWebSyncStart` and `KsyncWebSyncPoll` run the same login/token/sync flow as
`RunKsyncSync` without blocking the browser frame loop.
`StartWebSync` and `PollWebSync` run the same login/token/sync flow as
`RunSync` without blocking the browser frame loop.
---
@@ -1316,11 +1399,24 @@ typedef struct {
int max_tab_width;
int *scroll_offset;
int focus_selected;
} TabBar;
} TabBarProps;
int TabBar(TabBar bar);
int TabBar(TabBarProps bar);
int BeginTabBar(TabBarProps bar, int *selected_index);
int BeginTabItem(int index);
void EndTabItem(void);
void EndTabBar(void);
```
Use `TabBar` when only the header interaction result is needed. Use
`BeginTabBar` for arbitrary tab contents: pass the same canonical
`TabBarProps` plus caller-owned selection state, conditionally submit each
item's children when `BeginTabItem(index)` returns true, and balance successful
item and bar beginnings with their corresponding endings. A header selection
updates `selected_index` before the item checks in that frame. The scope does
not introduce a second renderer; it delegates the complete header behavior to
`TabBar`.
#### Dropdown
```c
@@ -1345,6 +1441,105 @@ Go uses the shared scroll container for wheel input, scrollbar dragging and
row clipping, painting only visible rows. These behaviors do not yet provide general keyboard-focus
isolation for arbitrary popup children or complete ImGui navigation semantics.
For caller-defined contents, use the native composed combo scope:
```c
typedef enum {
ComboFlagsNone = 0,
ComboPopupAlignLeft = 1 << 0,
ComboHeightSmall = 1 << 1,
ComboHeightRegular = 1 << 2,
ComboHeightLarge = 1 << 3,
ComboHeightLargest = 1 << 4,
ComboNoArrowButton = 1 << 5,
ComboNoPreview = 1 << 6,
ComboWidthFitPreview = 1 << 7
} ComboFlags;
typedef struct {
Rectangle bounds;
Vector2 popup_size;
const char *preview;
int id;
bool *open;
unsigned int flags;
int disabled;
} ComboProps;
int BeginCombo(ComboProps combo);
void EndCombo(void);
void CloseCombo(void);
```
Call `EndCombo` exactly once when `BeginCombo` returns nonzero. Between those
calls, ordinary widgets and nested `Row` or `Column` layouts are clipped,
painted, and routed as popup contents; no popup-specific widget variants are
needed. `CloseCombo` closes the current scope immediately and updates the
caller-owned `open` value. Disabling the combo, pressing Escape, releasing the
pointer outside its popup, or omitting its owner on a later frame also closes
it. Nested combo scopes are supported.
At most one height flag may be supplied. With a zero popup height, Small,
Regular/default, Large, and Largest select approximately 4, 8, 20, and 32 owner
rows. A zero width uses the owner width. Popups are constrained to the current
view and flip above the owner when necessary. The default aligns right edges;
`ComboPopupAlignLeft` aligns left edges. The remaining flags suppress the arrow
or preview and optionally expand the owner to fit its preview.
The begin/end pair marks the lexical lifetime of arbitrary child declarations;
frame ownership and paint-target management remain internal to Kryon. Generated
C, C++ and native Go use this same clean surface.
For an arbitrary popup that is not owned by a combo, use:
```c
typedef struct {
Rectangle bounds;
int id;
bool *open;
int disabled;
Rectangle trigger;
unsigned int flags;
} PopupProps;
typedef enum {
PopupFlagsNone = 0,
PopupTooltip = 1 << 0,
PopupModal = 1 << 1,
PopupContext = 1 << 2
} PopupFlags;
int BeginPopup(PopupProps popup);
void EndPopup(void);
void ClosePopup(void);
```
`BeginPopup` returns nonzero only while the caller-owned `open` value is true.
Its children use the same overlay painting, clipping, nested layout and input
capture as composed combos. Escape, a pointer release outside the popup,
disabling it, or omitting its owner on a later frame closes it. Outside releases
are consumed so the background widget underneath is not activated.
With `PopupTooltip`, `open` is optional and visibility is derived from pointer
hover over `trigger`. The tooltip uses the same arbitrary-child paint and layout
scope, but does not enter popup input capture: controls beneath it continue to
receive input. Tooltip bounds and child positions are explicit, keeping sizing
and placement in the retained layout rather than creating a second text-only
renderer. `ClosePopup` may hide the tooltip for its current frame.
With `PopupModal`, the same scope accepts arbitrary native children while
drawing a full-view dimming backdrop and owning pointer and keyboard input over
the background. Pointer releases outside the panel are blocked without closing
it; Escape, `ClosePopup`, disabling it, or omitting its owner closes it. Modal
and tooltip flags are mutually exclusive.
With `PopupContext`, a right-button release inside `trigger` sets the
caller-owned `open` value and enters the same arbitrary-child popup scope.
The caller supplies the panel position in `bounds`; this keeps placement stable
after the pointer moves. Outside left-button dismissal, Escape, explicit close,
disabled state, and missing-owner cleanup use the ordinary popup lifecycle.
Context, modal, and tooltip presentation flags are mutually exclusive.
#### Segmented Control
Responsive choice control for mutually exclusive compact options. It measures
@@ -1724,9 +1919,10 @@ before an app applies or saves them.
### Text composition
Platform adapters submit UTF-8 IME preedit and commit events through the shared
input front-end. The focused retained `TextField` or `TextArea` displays
preedit without changing the caller-owned buffer, then applies the committed
text through the control's normal codepoint filter.
input front-end. C retained `TextField` and `TextArea` consume these events;
commits use the editor's insertion rules and cannot mutate a read-only buffer.
C retained `TextField` displays preedit separately from committed text; C
TextArea preedit rendering and immediate C composition remain incomplete.
```c
SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "nihon", 5, 0);
@@ -1738,9 +1934,27 @@ while (PollTextComposition(&event)) {
}
```
`ClearTextComposition` discards pending preedit events when a host resets or
changes input ownership. Android `InputConnection` and the DOM backend feed
this API directly.
`ClearTextComposition` discards pending composition events, including commits;
it does not cancel preedit already stored in an editor. Submit a `CANCEL` event
to cancel that preedit. Android `InputConnection` and the DOM backend feed this
C API directly.
Native Go exposes the same phase names and `SubmitTextComposition`,
`PollTextComposition`, and `ClearTextComposition`, both as package functions
and Runtime methods. Its queue belongs to the runtime. Go TextField/TextArea
display preedit without changing the caller buffer, apply commits with UTF-8
cursor/length handling, and discard preedit on focus loss, removal, disabling
or popup capture. Unconsumed Go events expire at frame end. Both queues accept
up to 16 events with at most 255 text bytes per event; submission returns 1 on
success and 0 for an invalid phase or full queue. Native Go OS-window IME event
delivery and detailed preedit cursor/selection rendering remain incomplete.
Native Go `TextFieldProps.ReadOnly` and `TextAreaProps.ReadOnly` mirror C's
`read_only` property. Read-only editors remain focusable and allow selection,
navigation and copying, but reject typing, cut/paste mutations, deletion and
IME commits. Switching a Go editor to read-only cancels its preedit; its frame
operation carries `ReadOnly` so rendering suppresses the insertion caret without
removing focus styling. Re-enabling editing does not replay rejected input.
### Retained accessibility
@@ -1867,7 +2081,6 @@ int UIPaddedIconBtnNode(int id, int x, int y, int size, int padding, Texture2D i
### Text Drawing Helpers
```c
void DrawCenteredUIControlText(const char *text, int center_x, int center_y, int font, Color color);
void DrawLeftUIControlTextInRect(const char *text, Rectangle rect, int font_size, Color color);
void DrawFittedTextInRect(const char *text, Rectangle rect, int preferred_size, int min_size, Color color);
```
@@ -1995,6 +2208,19 @@ cells; labels are clipped to those cells, and sorting/resizing follow their
slanted boundaries. Go uses the corresponding
`HeaderHeight` and `HeaderAngle` fields.
A nonzero table `id`/`ID` participates in focus traversal. While focused, the
standard table body moves through visible columns with the arrow keys or
Tab/Shift+Tab,
activates the current cell with Enter or F2, clears selection with Escape, and
scrolls the selected row into view. Popup ownership and disabled state suppress
those keys.
Ctrl/Cmd+C copies the selected cell, row, or column; `copy_text`/`CopyText` can
override that value for an editable cell. Ctrl/Cmd+V reports the clipboard text
and target through `pasted_text`, `pasted_row`, and `pasted_column` (the matching
capitalized fields in Go). C exposes the pasted string from runtime-owned
clipboard storage, valid until the clipboard is changed again.
For interactive cell content, set `TableViewProps.custom_cells` (`CustomCells`
in Go), draw `TableView`, then call `BeginTableCell(table, row, column)` for each
cell and finish each scope with `EndTableCell()`. The returned rectangle is the
@@ -2017,6 +2243,9 @@ changed. Render child widgets conditionally on the open state. Set `tree` for
an unframed tree header, `depth` for 20-pixel-per-level header indentation,
`leaf` to show a non-expanding leaf marker, and `selected` for highlighting.
`disabled` prevents toggling and dims the label; `id` identifies the header.
Set optional `visible` / `Visible` state to show an ImGui-style close affordance.
When that state is false the header consumes no layout or input; closing sets it
false and returns changed without toggling `open`.
Children retain their own widget IDs and explicitly supplied bounds. Collapsing
a parent does not reset the caller's nested open state. Headers with a positive
ID participate in focus traversal: Left closes, Right opens, and Enter/Space
+129 -11
View File
@@ -14,6 +14,13 @@ sync, filesystem, desktop integration, and optional terminal primitives.
Public APIs should be named after the real domain concept. Do not add temporary
prefixes, compatibility aliases, or product-flavored names for new behavior.
The optional sync-node pool is local-first: paired LAN nodes rank ahead of
paired remote nodes, and a configured public node is the final fallback. Each
node has isolated bearer-token and clock-skew storage, so failing over cannot
send one node's credentials to another. Connectivity and authentication errors
advance to the next node; account, signing, and payload errors stop immediately.
Discovery may add candidates, but only explicit pairing grants trusted status.
## Runtime Implementation
Runtime code lives in `src/`. It owns widget behavior, rendering helpers,
@@ -23,6 +30,109 @@ downstream application demonstrably needs the behavior.
### Widget lifecycle consolidation
Captured C retained paint includes blend state through the private
`ui_blend_internal.h` snapshot. OpenGL 3.3/GLES2 backend hooks preserve both
effective GPU factors/equations and rlgl's cached mode/custom configuration,
including changes awaiting activation. The hooks are injected into the build
copy by `prepare-raylib-source.sh`, not into the raylib submodule or public API.
Each captured node restores its declaration state for painting and restores the
caller's state afterward. The snapshot itself does not own render resources.
The private `ui_paint_layers.c` context now owns temporary C render textures,
collects mixed immediate/retained layers, and composites them in opening order.
Nested layers remain above subsequent parent paint; hidden parents suppress
descendants. Capture and composition restore drawing state, and texture resource
operations preserve the active framebuffer. Native `UIWindow` hosts lazily own
their context and handle its frame, composition and destruction. The private
active-window accessor exposes that owner to future composed widgets without
adding app-level lifecycle calls. Main UI frames own a separate lazy context:
`SetUIFrame` starts it, `EndUIFrame` composites it, and `CloseWindow` releases
its resources before graphics shutdown. The private frame accessor routes to
the active UIWindow when appropriate. Presenter readback preserves the calling
framebuffer. Layer scopes suspend the retained Row/Column path, keeping popup
children in the screen tree without consuming the owner's layout slots. Scope
exit checks balanced child layouts and restores the owner's path. Disabled
scopes likewise inherit the owner's state behind a protected local depth floor,
then restore the parent's scope on exit. Input clips and scroll depth are
isolated similarly, while modal capture stays active. The private C popup input
registry supplies nested branch capture to the shared hit-test path. Each paint
host owns its registry and advances, binds, retires and destroys it automatically.
Auxiliary frames switch to their own registry and restore the parent's binding
on completion; hiding a layer closes its input branch. Retained nodes snapshot
popup ownership for deferred hit testing and button hover/press state; snapshots
are kept with the committed tree while a replacement is declared. Closed,
missing, previous-frame or destroyed owners cannot receive those hits.
Deferred pointer-focus registration uses the same ownership snapshots without
reopening scopes, preserving modal, clip, disabled and inspection capture.
Retained hit testing and button hover/press state now use that same full capture
predicate, so modal blocking also prevents deferred click events.
The public `BeginCombo` / `EndCombo` / `CloseCombo` and `BeginPopup` /
`EndPopup` / `ClosePopup` scopes bind these paint, layout and input contexts for
arbitrary native children. `PopupTooltip` reuses that paint/layout scope while
intentionally skipping input ownership. `PopupModal` uses the same scope with a
full-view input/backdrop policy, and `PopupContext` uses it with right-release
activation over a retained trigger. Presentation variants remain flags on the
one popup implementation rather than parallel widget trees.
Modal outside releases remain non-dismissing. The input registry saves focus
when a top popup first opens, focuses its first eligible child, and restores the
parent or background after nested close, root close, or missing-owner retirement.
Long-lived drag values, sliders, splitters and table resizers store the same
persistent owner identity, allowing out-of-bounds continuation only while that
branch remains topmost and cancelling on dismissal or ownership changes.
C and Go now have a pointer-independent top-popup keyboard predicate. Closed
combos use it before keyboard opening, preventing a focused parent/background
combo from opening behind a child popup. Focus registrations now retain their
popup owner: C filters and deduplicates Tab destinations at focus finalization,
before releasing the host input binding; Go filters its current/previous-frame
focus order during traversal. Native tests cover forward/reverse wraparound,
parent/background exclusion and traversal after explicit dismissal. Go also
exercises actual editor Tab events. Native lifecycle tests cover automatic
first-child focus acquisition and parent/background restoration. Complete
keyboard routing remains unfinished. Generic accelerator dispatch is isolated
to the top live popup branch in C and Go, including immediate restoration when
an explicitly closed popup is next declared.
TextField/TextArea editing now also respects top-popup keyboard ownership in
both runtimes. C's immediate keyboard-enabled check uses the active scope;
retained editor routing uses its declaration snapshot after scopes close.
Tests cover blocked parent and eligible child typing, including immediate and
retained C paths. Immediate C TextArea skips painting without a graphics window.
Ordinary Go Button now registers focus, focuses on pointer activation and
handles Enter/Space and Tab. C's activation check also consults registered popup
ownership, including deferred button events. Unclaimed Go Tab events route at
frame end so a disabled, absent or blocked focus owner cannot swallow traversal.
Generated C/Go button tests cover Enter/Space, disabled rejection and Tab skipping
a disabled control; popup tests cover parent/child keyboard activation.
Missing C popup input owners are now retired before frame-end focus filtering,
not only during paint cleanup. Matching C/Go tests omit a child and then its
parent and verify that Tab reaches the surviving parent/background that frame.
Popup keyboard capture is remembered for the C host frame. Unhandled character
input and queued text-edit commands expire at frame end after such capture,
including same-frame dismissal, instead of leaking into an underlying editor
later. Tests cover injected/platform-queued text, queued Backspace/Enter and
fresh input after dismissal. Non-popup queue behavior is unchanged.
C retained IME commits now respect read-only editors, and popup-captured
composition events expire with other blocked text input. Preedit is cancelled
on focus loss, read-only transition or popup keyboard capture. Regression tests
cover cancellation and no commit replay after dismissal. Native Go now owns a
composition queue and per-editor preedit records. TextField/TextArea display
preedit separately from committed buffers and insert UTF-8 commits; focus loss,
removal, disabling and popup capture discard preedit. A native generated
composition fixture verifies non-mutating preedit, commit and cancellation in
C and Go. Device-level Go IME routing remains unfinished.
Native Go text props now carry ReadOnly, with mutation guards separate from
focus/selection/copy handling and read-only caret metadata. C retained editing
also guards ordinary typing, cut/paste and deletion, not just composition
commits. The generated composition fixture verifies read-only TextField and
TextArea buffers and copying in both native runtimes; Go tests cover preedit
cancellation, byte-for-byte buffer preservation and re-enabling without replay.
Native Go runtime creation now resolves Kryon's Noto Sans UI face from packaged,
development-tree, or standard system locations before falling back to the
minimal bitmap renderer. This matches the C host's default-font policy while
preserving explicit `RegisterUIFontData` / `UseUIFont` overrides.
Private paint scopes share a drawing-order guard across host contexts while
keeping texture ownership host-local. Token generations survive host destruction
and allocation reuse. Invalid closes are rejected before restoring drawing state.
C dropdown identity records now have stable dynamically allocated storage,
rather than a fixed 24-control array whose overflow reused the first control.
Frame-end overlay processing retires records for owners no longer declared.
@@ -58,7 +168,10 @@ same shared lowering. Native `Scroll` blocks use the same lexical cleanup and
existing `BeginScroll`/`EndScroll` operations. An optional block name binds the
returned content rectangle without leaking it beyond the block. Native generated
scroll parity covers nested clips/input and restoration after return, break and
continue. Other begin/end APIs have not all gained block syntax.
continue. Native `Combo` and `Popup` blocks similarly lower caller-defined popup
contents to conditional begin calls plus cleanup-managed end calls, removing manual scope
bookkeeping from `.kry` sources while retaining the small runtime contract.
Other begin/end APIs have not all gained block syntax.
The C widget implementation is still being consolidated. Some constructors
submit retained paint, while others register generic nodes and draw immediately.
@@ -81,17 +194,19 @@ ordinary typed drag nodes inside a Row, plus retained Text for the label. Their
children preserve the existing input IDs and borrow the caller's endpoint
pointers; no range-specific renderer or prefixed drag draw entry point remains.
`TextInRect` uses a typed retained text node with owned text, captured font
selection, and resolved bounds. Its deferred painter preserves the existing
centering and clipping rules. Headless declaration does not invoke a graphics
backend. The pixel test compares it against the immediate text renderer,
including an overlapping later rectangle and a mutated source string.
`Text(TextProps)` uses one typed retained text node with owned text, captured
font selection, and resolved bounds. Its painter measures intrinsic lines or
wraps bounded text, clips to positive bounds, and applies alignment, color, and
disabled presentation from the same property object. Headless declaration does
not invoke a graphics backend. There are no separate public colored, disabled,
wrapped, or in-rectangle text widget implementations.
The remaining families must migrate with evidence for layout, input timing,
paint order, disabled/clip scopes, and data lifetime. Captured render textures
are currently an internal bridge for mixed painting, not a public popup API or
the completed widget architecture. Native Go keeps its own implementation and
must retain matching behavior through generated-runtime parity coverage.
remain private implementation machinery behind the public combo scope, not a
low-level public paint API or the completed widget architecture. Native Go keeps
its own implementation and must retain matching behavior through
generated-runtime parity coverage.
Numeric editor state uses collision chains keyed by numeric type, widget ID,
and component index,
@@ -139,8 +254,11 @@ and accepting a drag; an already active source retains its payload when the
pointer leaves its original bounds. Rejected targets do not consume the release
or payload. Generated C/Go tests cover clipped sources/targets and copied data
lifetime across press and release.
General keyboard focus, active-drag routing, C composed-popup integration and a public
arbitrary-content combo scope remain unfinished.
The public arbitrary-content combo scope integrates these paint and input
registries in C and Go. Generated C/Go execution and k2cpp syntax coverage use
the same clean calls. Popup focus acquisition/restoration and active scalar,
slider, splitter and table-resize ownership are covered in both native runtimes;
device-level integration remains unfinished.
## Backends
+260 -14
View File
@@ -1,7 +1,11 @@
# Composed popup implementation requirements
Status: unimplemented. This is an implementation checklist, not a completion
claim or a restriction of the native ImGui widget goal.
Status: the public native `BeginCombo` / `EndCombo` / `CloseCombo` and generic
`BeginPopup` / `EndPopup` / `ClosePopup` scopes are implemented in C and Go,
with k2c, k2cpp and k2go generated coverage. The
remaining lifecycle and backend gaps below still apply. This is an
implementation checklist, not a completion claim or a restriction of the
native ImGui widget goal.
## Contract
@@ -11,6 +15,12 @@ whose contents and selection are caller-controlled. The upstream header was
checked on 2026-09-05. It also exposes popup alignment and height choices,
arrow/preview suppression, and fitting the width to the preview. Existing
Kryon option arrays do not establish support for that scope or those flags.
The same upstream header exposes arbitrary begin/end popup and tooltip scopes;
Kryon's generic popup scope now covers caller-defined non-modal popup contents,
non-input-capturing hover tooltips through `PopupTooltip`, and arbitrary modal
contents through `PopupModal`. `PopupContext` adds right-release activation over
an explicit trigger while retaining the same arbitrary-child scope and
caller-owned open state.
The clean native scope must accept ordinary native controls and nested layouts,
not a second set of popup-specific widget aliases. C, C++ codegen over C, and
@@ -34,10 +44,13 @@ popup must not submit children.
- `SaveUIFrameState` preserves UI camera/input state, not the active graphics
render target. It is not sufficient for nested paint-target restoration.
- Go now collects deferred `FrameOp` records in runtime-owned nested paint
layers. Existing option-list dropdowns use that collector and a private
nested popup click-ownership registry. The public composed scope and full
keyboard/active-drag routing are not implemented. Go's scrollable widgets
now gate wheel input through popup ownership and the active content clip.
layers. Existing option-list dropdowns and the public combo scope use that
collector and a private nested popup click-ownership registry. Scrollable
widgets gate wheel input through popup ownership and the active content clip;
drag values, sliders, splitters and table gestures retain their starting
popup owner across frames. C and Go accelerator dispatch is routed to the
active top popup branch; complete routing for every widget shortcut is not
implemented.
- C retained nodes now snapshot input clips and disabled scopes. Those snapshots
must also be respected when retained nodes are painted into a popup layer.
@@ -47,6 +60,10 @@ popup must not submit children.
existing offscreen target and nested layers before exposing a public scope.
The capture must include immediate drawing and subsequent retained painting.
Do not assume the destination is the main framebuffer.
Transparent capture must accumulate alpha with source factor one, separately
from RGB's source-alpha factor. Composite that premultiplied result without
multiplying RGB by alpha a second time. Restore the caller's blend mode and
custom factors, including around deferred retained painting.
2. Associate retained submissions with their layer and frame generation. Keep
child props/state ownership valid through deferred painting; do not keep
pointers to by-value props or temporary generated arrays after their lifetime.
@@ -97,11 +114,234 @@ that a popup automatically owns or composites that destination.
This is not a complete paint-layer implementation. It does not restore
arbitrary custom viewports or raw framebuffer bindings, or provide per-window
popup ownership. Clip, shader, blend and input-state isolation
popup ownership. Scope-level clip, shader, blend and input-state isolation
still need explicit handling in the future popup layer. The SDL and Win32
window presenters, final OS-window pixels, and per-window popup ownership have
not been verified by this test.
## Verified C translucent compositing prerequisite
`tests/texture_scope_test.c` now checks half-transparent immediate and retained
rectangles captured over transparent black. It verifies the captured RGBA values
and compares the composite over an opaque parent against direct source-over
drawing, pixel for pixel. The GLES2 test passes with separate RGB/alpha capture
factors and premultiplied compositing. The backend's ordinary alpha mode uses
one factor pair for both RGB and alpha, so it is not sufficient for transparent
layer capture: a source alpha of one half becomes approximately one quarter.
This test sets backend blend factors explicitly through a test-only declaration;
it does not add a public low-level API or implement automatic layer ownership.
Retained target captures now also snapshot blend state and restore it for each
captured node, then restore the caller's blend state. The test ends the capture
blend scope before `EndTree`, activates a different caller blend configuration,
and configures another pending set of custom factors. It checks exact restoration
of both active GPU state and pending renderer configuration after deferred paint.
Kryon's build-preparation hook compiles private helpers inside the copied rlgl
implementation; the raylib submodule and public generated APIs are unchanged.
This implementation covers the OpenGL 3.3/GLES2 paths, with real pixel evidence
for GLES2. The future owned layer still needs scope-level blend restoration and
automatic composition, plus the remaining resource/window ownership work.
## Implemented prerequisite: private C owned paint layers
`src/ui/ui_paint_layers.c` owns render textures in an explicit host context.
Opening a layer reserves its order and captures immediate drawing plus retained
submissions into the same texture. Nested layers composite above the parent's
later drawing. The context reuses textures, replaces them when dimensions change,
and releases unused entries after the frame is composited. Hiding a parent
suppresses its descendants; a frame without an owner emits none of its old paint.
Capture establishes separate source-over alpha factors. End restores the prior
target, clip and blend state; composition uses premultiplied alpha and restores
the caller's matrices, clip and blend configuration. Resource allocation and
destruction also preserve the active framebuffer, since the backend's texture
helpers bind and unbind framebuffers internally. The host must finish retained
painting before compositing or destroying the context. Scope tokens check frame
generation and last-opened/first-closed order across all active host contexts,
before touching backend state. Generations are allocated across context lifetimes
so a destroyed host's token cannot become valid if its memory address is reused.
Unix subprocess regressions require rejection of null, stale, double-close,
destroyed-host and cross-host out-of-order tokens; valid nested scopes continue
through the real framebuffer checks.
The real framebuffer test covers translucent immediate content, retained content
above later opaque main content, child-over-parent ordering, hidden parents,
missing owners, and resumed drawing under a transformed camera and clip. This
is exposed through the public combo scope. C layer scopes suspend the
owner's retained layout path through `ui_tree_layout_suspend` and restore it on
exit. Popup nodes stay attached to the screen root in the same retained tree,
but do not consume parent Row/Column slots. Declaration-generation and balanced
child-layout checks reject ending a layer after changing its tree or leaving a
child layout open. A headless node/position regression and real pixels verify
an independent popup Column origin and the resumed parent Row's next position.
C layers also isolate disabled-scope depth while inheriting the parent's disabled
state. An internal floor prevents a child's `EndDisabled` from unwinding its
parent. Ending the layer requires balanced child disabled scopes, then restores
the parent's depth and disabled origin. Headless tests cover enabled/disabled
parents and nested scopes; the framebuffer test checks inheritance across host
contexts and rejects an unclosed disabled child scope. C layer scopes now also
suspend input clips and scroll-scope depth, leaving modal/input capture intact.
Their child scroll scopes must balance before exit restores the owner's clips.
Ordinary button regressions verify interaction outside the owner's viewport,
restored background clipping and rejection by a modal capture. Real pixels
verify mixed popup content escaping a 1x1 scrolling owner; invalid-scope tests
reject an unclosed child scroll. Complete shortcut routing and shader isolation
remain work.
The private C `ui_popup_input.c` registry now tracks persistent popup bounds,
parentage and branch ordering in explicit contexts. The shared input-capture
path consults its bound context, allowing ordinary controls to participate.
Records preserve capture before the next frame's owner declaration; closing a
parent disables descendants, and frame completion retires missing owners.
Headless button tests cover background controls before/after the owner, a child
receiving input instead of its parent, child dismissal, context rebinding,
missing owners and reordered sibling branches. Go's corresponding popup tests
remain a regression gate. C paint hosts now own their input registries: starting
a host frame advances and binds its registry, composition retires missing owners
and restores the previous binding, and destruction releases the registry.
Auxiliary windows establish their own context even before declaring a layer
when a parent context is bound. Hiding a layer closes its matching input branch.
The graphical test checks capture before redeclaration, auxiliary isolation,
parent restoration and missing-owner retirement. Retained nodes now keep private
declaration-time input snapshots, separate from paint snapshots, for deferred
hit testing and button hover/press state. Routing does not reopen lexical scopes.
The committed tree keeps its snapshots while a replacement is being declared;
registry generation/liveness checks reject old and destroyed owners. Headless
tests cover child precedence over later parent/background declarations and
dismissal restoring the parent then background. Deferred pointer-focus
registration now uses the same snapshots, retaining modal, clip, disabled and
inspection gates. A button regression clears immediate focus before the deferred
pass and verifies child focus versus modal blocking after both scopes close.
It also checks deferred click events. The test initially reproduced a click
leaking through modal capture; hit testing and hover/press state now consult the
same full capture predicate as pointer-focus registration. The public combo
scope uses this ownership registry. Persistent active-gesture ownership is
covered below.
C and Go now select the top live popup branch for keyboard eligibility without
testing pointer coordinates. Closed combos consult this check before accepting
keyboard opening. Matching native tests cover a focused combo in the parent
versus the top child, and keyboard eligibility after child and branch dismissal.
This check does not cover every shortcut path or establish complete keyboard
ownership.
TextField/TextArea editing now consults top-popup keyboard ownership in both
native runtimes. C's immediate keyboard-enabled query is scope-aware; retained
editors resolve their saved input owner and reject closed/stale owners before
editing. Matching typing tests cover blocked parent and eligible child editors,
with both immediate and deferred C variants. Immediate C TextArea skips paint
when no graphics window exists, matching TextField's headless editing support.
Complete widget-specific shortcut coverage and replay for every dismissal
ordering still require dedicated integration and tests.
The canonical `AcceleratorPressed` / `DispatchAccelerators` surface now exists
in native C and Go. It inherits disabled state and only accepts a chord in the
top live popup branch. Generated k2c/k2cpp/k2go parity queues Ctrl+C with an
open popup, verifies that only the popup command fires, closes the popup, and
verifies that background routing resumes on the next declaration. C
`BeginPopup` now retires an explicitly closed or outside-dismissed input owner
before returning, rather than leaving keyboard capture until frame cleanup.
This establishes generic accelerator ownership and explicit-close replay, not
all widget-specific shortcuts or cross-window routing.
Collapsible/tree-header directional navigation now resolves its registered
popup focus owner before handling arrows in C and Go. Native and generated
tests cover a focused background header blocked by an open popup, an eligible
header inside that popup, and restored background navigation after close.
Selectable-text copy also consults top-popup keyboard ownership in both
runtimes; Go's native regression covers blocked background and eligible popup
copy paths. C uses the same scope-aware keyboard predicate as accelerators.
Focus registrations now retain popup ownership separately from the lexical
scope. C stores frame-local registrations in the host input registry and
filters/deduplicates Tab destinations before releasing the host binding. Go
keeps ownership alongside current/previous-frame focus order and prunes removed
registrations at frame end. Matching tests cover forward/reverse wrapping,
parent/background exclusion, duplicate registrations and traversal after
explicit child/branch dismissal; Go additionally sends Tab through an editor.
Lifecycle tests in both runtimes verify that the first eligible child of a newly
opened top popup acquires focus, a nested close restores parent focus, and a
root close restores background focus. A complete cross-window keyboard lifecycle
is not established.
Ordinary Go Button now participates in focus order and handles Enter/Space and
Tab; unclaimed Tab events route at frame end after destination registration.
C's keyboard activation predicate checks the registered popup owner, so retained
button events work after lexical scopes close without activating the parent.
Matching popup tests cover Enter/Space in parent and child controls. The native
generated `buttons_layout.kry` runners additionally verify enabled/disabled
keyboard activation and Tab skipping a disabled button. Their shared JavaScript
comparison remains pointer-only for this fixture.
Missing C input owners are retired before focus finalization chooses a Tab
destination, while record/resource cleanup remains in its existing finish phase.
A regression reproduced focus being cleared when a missing child still blocked
its surviving parent. Matching native tests now omit the child and then parent
across frames and verify same-frame traversal to the parent and background.
Separate lifecycle regressions verify automatic background-focus restoration
when a popup owner disappears without a navigation event.
Text input lifetime now has dismissal regressions. C reproduced blocked text
reappearing in the underlying editor after a popup closed. The host registry
remembers keyboard capture for the frame, and EndUIFrame expires leftover native
characters and queued text-edit commands before releasing that binding. The
marker survives same-frame dismissal and resets at the next host frame; ordinary
non-popup queue behavior is unchanged. Tests cover immediate TextField/TextArea,
injected and platform-queued characters, queued Backspace/Enter for TextField,
and fresh input after dismissal. Go's frame cleanup passes the matching text
test. IME composition and Android device delivery are not established here.
C retained composition now has focused regressions. Popup-captured composition
events expire at frame end alongside other unhandled text, preventing delayed
commit after dismissal. Commits cannot mutate read-only TextField/TextArea
buffers. Preedit is cancelled when the retained editor loses focus, becomes
read-only or is blocked by popup keyboard ownership; tests check cancellation
events and no revival after re-enabling. Immediate C composition and device-level
IME delivery remain unfinished.
Native Go now has runtime-local composition queues and per-editor preedit state.
TextField/TextArea display preedit without mutating caller buffers, and commits
use UTF-8 insertion/cursor handling. Tests cover queue isolation and limits,
multi-frame preedit, commits, cancellation, removed/disabled/unfocused editors,
and popup dismissal without replay. The native generated `composition.kry`
fixture verifies non-mutating preedit, UTF-8 commit and cancellation through C
and Go; the JavaScript runner does not execute it. Go OS-window event delivery,
detailed preedit cursor/selection rendering and C TextArea preedit rendering
are still incomplete.
Read-only editing now has matching native generated coverage. The composition
fixture declares read-only TextField and TextArea in C and Go, checks copying,
and rejects ordinary text, cut/paste, deletion and IME commits. Go props carry
ReadOnly through editing and frame metadata; focused read-only controls keep
their focus styling without an insertion caret. C retained mutation paths also
honor read_only. Go tests check preedit cancellation and no rejected-input replay
when the editor becomes editable again.
The same framebuffer test interleaves two host contexts using the same owner ID,
resizes one context from 32 to 64 pixels, reuses the other context's resources,
and destroys one while the other destination is active. It verifies both hosts'
immediate/retained pixels and subsequent drawing. The real X11 `UIWindow`
presenter readback now also checks an owned layer composited over later opaque
retained content. Native `UIWindow` implementations lazily own their layer context:
begin starts its frame, end composites before presentation, and close destroys
it. Closing the active window first finishes its frame. The private accessor
returns no context outside an active window; callers no longer manage its
frame/composition/destruction. Four presenter readbacks cover consecutive frames,
an omitted owner and closing an active frame. X11 runtime and SDL compile checks
pass; Win32 runtime behavior remains unverified. This does not isolate C widget
or input state.
The main UI frame now lazily owns a separate context through the same private
frame accessor. `SetUIFrame` starts its layer frame and `EndUIFrame` composites
it; `CloseWindow` releases its textures before closing the graphics context.
UIWindow frames route to their own owner and do not end the main context. The
pixel test covers main-frame immediate/retained content, a missing owner,
interleaving an auxiliary window, and closing/reopening the graphics context.
Presenter texture readback preserves its caller's framebuffer, so interleaving
an auxiliary presentation does not redirect the main frame's later composition.
Callers of private internals still must balance layer scopes and finish retained
painting before host finalization. The public combo scope owns that balancing
for ordinary callers and rejects an unmatched `EndCombo`.
## Implemented prerequisite: native Go nested paint collection
`go/kryon/paint_layers.go` replaces the dropdown-specific paint map with an
@@ -122,10 +362,11 @@ reset, and rejection of foreign, stale and unbalanced scope tokens. The native
Go suite and generated-runtime parity fixture for the existing dropdown path
remain regression gates.
This private paint collector is not `BeginCombo`/`EndCombo` and does not
establish C/Go parity for arbitrary popup
children. C still needs ownership/compositing of captured paint destinations,
and both runtimes need the public scope, nested dismissal and generated tests.
The public Go combo scope now builds on this collector. Native tests cover
ordinary buttons, checkboxes, editable fields and nested layouts, including
nested dismissal, missing owners, layout restoration and presentation flags.
The shared `.kry` fixture is executed through generated C and Go and is also
syntax-checked through k2cpp.
`go/kryon/popup_input.go` separately generalizes click ownership. Its persistent
runtime-local registry preserves capture before the owner is declared on the
@@ -142,9 +383,13 @@ to scroll. Generated native C/Go regression coverage opens a combo over an
earlier scroll scope and checks that the latter's offset remains unchanged on
wheel input. Go drag-and-drop start/accept paths now also respect popup and clip
ownership; tests verify that rejected background targets leave the release and
copied payload available to the popup target. Scalar-slider/resize active-drag
ownership, keyboard focus and composed dismissal remain
unfinished.
copied payload available to the popup target. Drag values, sliders, splitters
and table column resizers now store persistent popup owner identity in C and Go.
Native tests verify out-of-bounds continuation for the owning branch, preemption
of a background drag by a new popup, and cancellation on owner dismissal before
a background control with matching identity can mutate. Composed dismissal
covers explicit close, Escape, outside pointer release and owner removal; popup
focus restoration covers both explicit dismissal and owner removal.
## Acceptance evidence
@@ -156,6 +401,7 @@ unfinished.
| Nested popup | One level closes without corrupting the parent's capture, layout or destination |
| Scrolling owner | Popup escapes the owner's clip while ordinary owner content remains clipped |
| Pointer ownership | Background controls declared both before and after the owner cannot steal popup input |
| Active gestures | Generated C/Go popup drag continues outside its bounds and cancels before same-ID background reuse; k2cpp compiles the same fixture |
| Editing lifecycle | Focus, typing, disabling, re-enabling and no replay of discarded input |
| Dismissal | Escape, outside press, selection-close, missing owner and destroyed window |
| Presentation choices | Alignment, size policies, preview/arrow suppression and preview-fit width |
+10 -10
View File
@@ -48,7 +48,7 @@ li{margin:.25rem 0}
<p>(<code>include/kry_backend.h</code>), selected at <b>runtime</b>. Only the KRB widget subset runs on these.</p>
<h2>Widget statement whitelist (<code>.kry</code> frontend)</h2>
<p><code>parse_widget_statement</code> (<code>cmd/kir/kir_parse.c</code>) recognizes 102 widget names. <code>k2c</code> compiles any library call regardless (plain call statement); <code>k2cpp</code> shares that lowering (C++ output, C linkage); <code>k2go</code> lowers the full whitelist onto its <code>Runtime</code> interface (except <code>Canvas</code>, below); <code>k2js</code> records whitelisted standalone widget calls as browser-loadable runtime operations; and <code>k2b</code> lowers a subset of it:</p>
<p>`Background Text TextInRect TextColored TextDisabled TextWrapped LabelText BulletText ValueBool ValueInt ValueUInt ValueFloat Paragraph TextLines Rect Line Bevel Icon Picture ImageWithBg ImageButton Button Selectable CheckboxFlags SmallButton InvisibleButton ArrowButton Bullet Separator SeparatorText ColorEdit3 ColorEdit4 ColorPicker3 ColorPicker4 ColorButton Tooltip IconButton Href TextField TextArea Dropdown Slider Toggle Checkbox Radio Progress Spinbox Combobox Screen Column Row Stack End Scroll PlotLines PlotHistogram DragFloat DragInt DragFloatRange2 DragIntRange2 SliderFloat SliderInt VSliderFloat VSliderInt SliderAngle InputFloat InputInt InputDouble Canvas BeginDisabled EndDisabled Modal ActionModal MessageDialog ConfirmDialog PromptDialog TitleBar MenuBar PopupMenu ContextMenu TabBar BottomNav TopNav Toolbar ShowToast ShowToastFor LabelFrame Notebook PanedView Collapsible ListBox TreeView SourceView TableView ColorPicker TabItemButton ClosableTabBar DragDropSource DragDropTarget MultiSelectList CanvasGrid SelectableText`</p>
<p>`Background Text LabelText BulletText ValueBool ValueInt ValueUInt ValueFloat Paragraph TextLines Rect Line Bevel Icon Picture ImageWithBg ImageButton Button Selectable CheckboxFlags SmallButton InvisibleButton ArrowButton Bullet Separator SeparatorText ColorEdit3 ColorEdit4 ColorPicker3 ColorPicker4 ColorButton Tooltip IconButton Href TextField TextArea Dropdown Slider Toggle Checkbox Radio Progress Spinbox Combobox Screen Column Row Stack End Scroll PlotLines PlotHistogram DragFloat DragInt DragFloatRange2 DragIntRange2 SliderFloat SliderInt VSliderFloat VSliderInt SliderAngle InputFloat InputInt InputDouble Canvas BeginDisabled EndDisabled Modal ActionModal MessageDialog ConfirmDialog PromptDialog TitleBar MenuBar PopupMenu ContextMenu TabBar BottomNav TopNav Toolbar ShowToast ShowToastFor LabelFrame Notebook PanedView Collapsible ListBox TreeView SourceView TableView ColorPicker TabItemButton ClosableTabBar DragDropSource DragDropTarget MultiSelectList CanvasGrid SelectableText`</p>
<p>(<code>Canvas</code> is whitelisted but no <code>Canvas(...)</code> widget exists — examples call <code>BeginCanvas</code> directly. Scroll coverage uses the C <code>BeginUIScrollContainer</code> / <code>EndUIScrollContainer</code> API.)</p>
<h2>Widget matrix</h2>
<p>The upstream widget-family crosswalk and its remaining semantic gaps are kept in [<code>IMGUI_WIDGET_COVERAGE.md</code>](IMGUI_WIDGET_COVERAGE.md).</p>
@@ -59,8 +59,8 @@ li{margin:.25rem 0}
<tr><th>Widget</th><th>C</th><th>k2c</th><th>k2cpp</th><th>k2go</th><th>Go</th><th>KRB</th></tr>
<tr><td class="">Background</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Background</code></td><td class="ok">✅ node</td></tr>
<tr><td class="">Text</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Text</code></td><td class="ok">✅ node</td></tr>
<tr><td class="">TextInRect</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>TextInRect</code></td><td class="ok">✅</td></tr>
<tr><td class="">Text helpers (colored, disabled, wrapped, label/value, bullet)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Text properties (bounds, wrap, clip, color, alignment, disabled)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Text(TextProps)</code></td><td class="ok">✅</td></tr>
<tr><td class="">Label/value and bullet text</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Value helpers (bool, int, unsigned, float)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Paragraph (rich text + inline icons)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Paragraph</code></td><td class="no">✗</td></tr>
<tr><td class="">TextLines</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>TextLines</code></td><td class="no">✗</td></tr>
@@ -83,9 +83,9 @@ li{margin:.25rem 0}
<tr><td class="">Href (TextLink / TextLinkOpenURL)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Href</code></td><td class="no">✗</td></tr>
<tr><td class="">IconLink</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td><td class="no">✗</td><td class="no">✗</td></tr>
<tr><td class="">TextField</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>kryon.TextField(kryon.TextFieldProps)</code> / <code>kryon.TextField(&quot;Name&quot;, &amp;value)</code></td><td class="ok">✅ TEXTINPUT node</td></tr>
<tr><td class="">Read-only text</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ via <code>Text</code>/<code>TextInRect</code></td><td class="ok">✅ <code>Text</code>/<code>TextInRect</code></td><td class="no">✗</td></tr>
<tr><td class="">Read-only text</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ via <code>Text</code></td><td class="ok">✅ <code>Text(TextProps)</code></td><td class="no">✗</td></tr>
<tr><td class="">TextArea (selection, syntax highlight)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>NewTextArea</code>/<code>TextArea</code></td><td class="no">✗</td></tr>
<tr><td class="">Dropdown / DropdownEx</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Dropdown</code> (Ex needs rich option arrays)</td><td class="ok">✅ <code>Dropdown(Ex)</code></td><td class="ok">✅ DROPDOWN control</td></tr>
<tr><td class="">Dropdown / DropdownOptions</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Dropdown</code> (rich option arrays are native C only)</td><td class="ok">✅ <code>Dropdown</code></td><td class="ok">✅ DROPDOWN control</td></tr>
<tr><td class="">Slider</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Slider</code>/<code>Slider</code></td><td class="ok">✅ SLIDER control</td></tr>
<tr><td class="">Vertical sliders</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>VSliderFloat</code> / <code>VSliderInt</code></td><td class="ok">✅</td><td class="ok">✅ VSLIDER control</td></tr>
<tr><td class="">Toggle (switch)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>Toggle</code></td><td class="ok">✅ node</td></tr>
@@ -124,17 +124,17 @@ li{margin:.25rem 0}
<tr><td class="">ListBox (+ disabled)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>ListBox</code></td><td class="no">✗</td></tr>
<tr><td class="">TreeView (+ disabled) / CascadingTreeView</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="part">◐ <code>TreeView</code></td><td class="part">◐ <code>TreeView</code></td><td class="no">✗</td></tr>
<tr><td class="">SourceView (code + line numbers)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>SourceView</code></td><td class="no">✗</td></tr>
<tr><td class="">TableView (resizing, frozen rows, sort direction, cell colors, column visibility/order, disabled)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>TableView</code></td><td class="no">✗</td></tr>
<tr><td class="">TableView (resizing, frozen rows, sort direction, cell colors, column visibility/order, focus/keyboard/clipboard, disabled)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>TableView</code></td><td class="no">✗</td></tr>
<tr><td class="">CanvasGrid</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>CanvasGrid</code></td><td class="no">✗</td></tr>
<tr><td class="">SelectableText</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>SelectableText</code></td><td class="no">✗</td></tr>
<tr><td class="">MultiSelectList (Ctrl/Shift range selection)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">MultiSelectList (focus, keyboard navigation, Ctrl/Shift range selection)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Nested disabled scope</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>BeginDisabled</code> / <code>EndDisabled</code></td><td class="no">✗</td></tr>
</table>
<h3>UI/Navigation</h3>
<table>
<tr><th>Widget</th><th>C</th><th>k2c</th><th>k2cpp</th><th>k2go</th><th>Go</th><th>KRB</th></tr>
<tr><td class="">MenuBar / PopupMenu / ContextMenu</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ (<code>MenuBar</code>, nested items, retained right-click context state)</td><td class="no">✗</td></tr>
<tr><td class="">Tooltip (cursor-following, wrapped, non-focusing)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Popup scope (ordinary, hover-tooltip, modal arbitrary native content)</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">TabBar</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅ <code>TabBar</code></td><td class="no">✗</td></tr>
<tr><td class="">TabItemButton / closable tab items</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
<tr><td class="">Typed drag-and-drop source / target</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="ok">✅</td><td class="no">✗</td></tr>
@@ -194,7 +194,7 @@ li{margin:.25rem 0}
<tr><td class="">Style tokens</td><td class="ok">✅ radius/border/shadow/bevel; RETRO, MATERIAL, SYSTEM styles</td><td class="ok">✅ <code>Get/SetUIStyleTokens</code></td><td class="no">✗</td></tr>
<tr><td class="">Animation</td><td class="ok">✅ transitions (smoothstep), ripple, keyframe scene anims</td><td class="no">✗</td><td class="part">◐ <code>AnimNode</code> + <code>TIME</code> opcode</td></tr>
<tr><td class="">Text/fonts</td><td class="part">◐ multi-font registry, per-codepoint fallback, italic synthesis, wrap, selectable text, Android/browser IME preedit+commit; no shaping/bidi</td><td class="ok">✅ <code>RegisterUIFont(Data)</code>, <code>Push/Pop/UseUIFont</code>, input queue</td><td class="part">◐ font8x8 default, or pre-baked KFA1 glyph atlas; no TTF rasterization</td></tr>
<tr><td class="">DPI/scaling</td><td class="ok">✅ viewport-derived scale, <code>ScaleUIPx</code></td><td class="ok">✅ <code>ScaleUIPx</code>, <code>GetWindowScaleDPI</code></td><td class="part">◐ per-mille UI scale (<code>KRB_RUN_UI_SCALE</code>)</td></tr>
<tr><td class="">DPI/scaling</td><td class="ok">✅ viewport-derived scale, <code>Scale</code></td><td class="ok">✅ <code>Scale</code>, <code>GetWindowScaleDPI</code></td><td class="part">◐ per-mille UI scale (<code>KRB_RUN_UI_SCALE</code>)</td></tr>
<tr><td class="">Clipping</td><td class="ok">✅ 16-deep scissor stack + input clip stack</td><td class="ok">✅ <code>Begin/EndScissorMode</code></td><td class="ok">✅ 16-deep <code>clip_push/pop</code> in <code>kry_sw</code></td></tr>
<tr><td class="">Z-order/popups</td><td class="ok">✅ overlay paint pass, modal capture, input-capture stack</td><td class="part">◐ dropdown popups internal to <code>Dropdown</code></td><td class="part">◐ dropdown menus handled by the engine</td></tr>
<tr><td class="">Input</td><td class="ok">✅ unified front-end, pointer gestures/ownership, keyboard focus + Tab + accelerators, clipboard, backend-neutral IME composition; no gamepad nav</td><td class="ok">✅ native host key/mouse/text queues</td><td class="part">◐ vtable: mouse, press, wheel, text-key queue</td></tr>
@@ -243,7 +243,7 @@ li{margin:.25rem 0}
<ul>
<li><code>k2go</code> targets native Go: the <code>Runtime</code> interface covers the widget</li>
</ul>
<p>whitelist plus the generated-code widget families in <code>go/kryon</code> (controls, Props widgets, dialogs, canvas, Tk layout helpers, toasts, theme control), with <code>.kry</code> array declarations lowering to Go slices at the use site. Remaining boundaries: a forward <code>goto</code> over declarations is a loud Go compile error, <code>DropdownEx</code>&#x27;s rich option arrays are not expressible from <code>.kry</code>, and C pointer/<code>Texture2D</code> values cannot be written (icons pass by <code>UIIconType</code>, option lists as joined strings or <code>[N]string</code>).</p>
<p>whitelist plus the generated-code widget families in <code>go/kryon</code> (controls, Props widgets, dialogs, canvas, Tk layout helpers, toasts, theme control), with <code>.kry</code> array declarations lowering to Go slices at the use site. Remaining boundaries: a forward <code>goto</code> over declarations is a loud Go compile error, <code>DropdownOptions</code>&#x27; rich option arrays are not expressible from <code>.kry</code>, and C pointer/<code>Texture2D</code> values cannot be written (icons pass by <code>UIIconType</code>, option lists as joined strings or <code>[N]string</code>).</p>
<ul>
<li><code>k2js</code> emits ESM for the web recorder runtime. `make</li>
</ul>
+10 -10
View File
@@ -54,7 +54,7 @@ the full whitelist onto its `Runtime` interface (except `Canvas`, below);
`k2js` records whitelisted standalone widget calls as browser-loadable runtime
operations; and `k2b` lowers a subset of it:
`Background Text TextInRect TextColored TextDisabled TextWrapped LabelText BulletText ValueBool ValueInt ValueUInt ValueFloat Paragraph TextLines Rect Line Bevel Icon
`Background Text LabelText BulletText ValueBool ValueInt ValueUInt ValueFloat Paragraph TextLines Rect Line Bevel Icon
Picture ImageWithBg ImageButton Button Selectable CheckboxFlags SmallButton InvisibleButton ArrowButton Bullet Separator SeparatorText ColorEdit3 ColorEdit4 ColorPicker3 ColorPicker4 ColorButton Tooltip IconButton Href TextField TextArea Dropdown Slider Toggle
Checkbox Radio Progress Spinbox Combobox Screen Column Row Stack End Scroll
PlotLines PlotHistogram DragFloat DragInt DragFloatRange2 DragIntRange2 SliderFloat SliderInt VSliderFloat VSliderInt SliderAngle InputFloat InputInt InputDouble
@@ -91,8 +91,8 @@ declaration pass (`src/ui/ui_tree.c`).
|---|---|---|---|---|---|---|
| Background | ✅ | ✅ | ✅ | ✅ | ✅ `Background` | ✅ node |
| Text | ✅ | ✅ | ✅ | ✅ | ✅ `Text` | ✅ node |
| TextInRect | ✅ | ✅ | ✅ | ✅ | ✅ `TextInRect` | ✅ |
| Text helpers (colored, disabled, wrapped, label/value, bullet) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Text properties (bounds, wrap, clip, color, alignment, disabled) | ✅ | ✅ | ✅ | ✅ | ✅ `Text(TextProps)` | ✅ |
| Label/value and bullet text | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Value helpers (bool, int, unsigned, float) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Paragraph (rich text + inline icons) | ✅ | ✅ | ✅ | ✅ | ✅ `Paragraph` | ✗ |
| TextLines | ✅ | ✅ | ✅ | ✅ | ✅ `TextLines` | ✗ |
@@ -116,9 +116,9 @@ declaration pass (`src/ui/ui_tree.c`).
| Href (TextLink / TextLinkOpenURL) | ✅ | ✅ | ✅ | ✅ | ✅ `Href` | ✗ |
| IconLink | ✅ | ✅ | ✅ | ✗ | ✗ | ✗ |
| TextField | ✅ | ✅ | ✅ | ✅ | ✅ `kryon.TextField(kryon.TextFieldProps)` / `kryon.TextField("Name", &value)` | ✅ TEXTINPUT node |
| Read-only text | ✅ | ✅ | ✅ | ✅ via `Text`/`TextInRect` | ✅ `Text`/`TextInRect` | ✗ |
| Read-only text | ✅ | ✅ | ✅ | ✅ via `Text` | ✅ `Text(TextProps)` | ✗ |
| TextArea (selection, syntax highlight) | ✅ | ✅ | ✅ | ✅ | ✅ `NewTextArea`/`TextArea` | ✗ |
| Dropdown / DropdownEx | ✅ | ✅ | ✅ | ✅ `Dropdown` (Ex needs rich option arrays) | ✅ `Dropdown(Ex)` | ✅ DROPDOWN control |
| Dropdown / DropdownOptions | ✅ | ✅ | ✅ | ✅ `Dropdown` (rich option arrays are native C only) | ✅ `Dropdown` | ✅ DROPDOWN control |
| Slider | ✅ | ✅ | ✅ | ✅ | ✅ `Slider`/`Slider` | ✅ SLIDER control |
| Vertical sliders | ✅ | ✅ | ✅ | ✅ `VSliderFloat` / `VSliderInt` | ✅ | ✅ VSLIDER control |
| Toggle (switch) | ✅ | ✅ | ✅ | ✅ | ✅ `Toggle` | ✅ node |
@@ -159,10 +159,10 @@ declaration pass (`src/ui/ui_tree.c`).
| ListBox (+ disabled) | ✅ | ✅ | ✅ | ✅ | ✅ `ListBox` | ✗ |
| TreeView (+ disabled) / CascadingTreeView | ✅ | ✅ | ✅ | ◐ `TreeView` | ◐ `TreeView` | ✗ |
| SourceView (code + line numbers) | ✅ | ✅ | ✅ | ✅ | ✅ `SourceView` | ✗ |
| TableView (resizing, frozen rows, sort direction, cell colors, column visibility/order, disabled) | ✅ | ✅ | ✅ | ✅ | ✅ `TableView` | ✗ |
| TableView (resizing, frozen rows, sort direction, cell colors, column visibility/order, focus/keyboard/clipboard, disabled) | ✅ | ✅ | ✅ | ✅ | ✅ `TableView` | ✗ |
| CanvasGrid | ✅ | ✅ | ✅ | ✅ | ✅ `CanvasGrid` | ✗ |
| SelectableText | ✅ | ✅ | ✅ | ✅ | ✅ `SelectableText` | ✗ |
| MultiSelectList (Ctrl/Shift range selection) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| MultiSelectList (focus, keyboard navigation, Ctrl/Shift range selection) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Nested disabled scope | ✅ | ✅ | ✅ | ✅ | ✅ `BeginDisabled` / `EndDisabled` | ✗ |
### UI/Navigation
@@ -170,7 +170,7 @@ declaration pass (`src/ui/ui_tree.c`).
| Widget | C | k2c | k2cpp | k2go | Go | KRB |
|---|---|---|---|---|---|---|
| MenuBar / PopupMenu / ContextMenu | ✅ | ✅ | ✅ | ✅ | ✅ (`MenuBar`, nested items, retained right-click context state) | ✗ |
| Tooltip (cursor-following, wrapped, non-focusing) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Popup scope (ordinary, hover-tooltip, modal arbitrary native content) | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| TabBar | ✅ | ✅ | ✅ | ✅ | ✅ `TabBar` | ✗ |
| TabItemButton / closable tab items | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
| Typed drag-and-drop source / target | ✅ | ✅ | ✅ | ✅ | ✅ | ✗ |
@@ -235,7 +235,7 @@ declaration pass (`src/ui/ui_tree.c`).
| Style tokens | ✅ radius/border/shadow/bevel; RETRO, MATERIAL, SYSTEM styles | ✅ `Get/SetUIStyleTokens` | ✗ |
| Animation | ✅ transitions (smoothstep), ripple, keyframe scene anims | ✗ | ◐ `AnimNode` + `TIME` opcode |
| Text/fonts | ◐ multi-font registry, per-codepoint fallback, italic synthesis, wrap, selectable text, Android/browser IME preedit+commit; no shaping/bidi | ✅ `RegisterUIFont(Data)`, `Push/Pop/UseUIFont`, input queue | ◐ font8x8 default, or pre-baked KFA1 glyph atlas; no TTF rasterization |
| DPI/scaling | ✅ viewport-derived scale, `ScaleUIPx` | ✅ `ScaleUIPx`, `GetWindowScaleDPI` | ◐ per-mille UI scale (`KRB_RUN_UI_SCALE`) |
| DPI/scaling | ✅ viewport-derived scale, `Scale` | ✅ `Scale`, `GetWindowScaleDPI` | ◐ per-mille UI scale (`KRB_RUN_UI_SCALE`) |
| Clipping | ✅ 16-deep scissor stack + input clip stack | ✅ `Begin/EndScissorMode` | ✅ 16-deep `clip_push/pop` in `kry_sw` |
| Z-order/popups | ✅ overlay paint pass, modal capture, input-capture stack | ◐ dropdown popups internal to `Dropdown` | ◐ dropdown menus handled by the engine |
| Input | ✅ unified front-end, pointer gestures/ownership, keyboard focus + Tab + accelerators, clipboard, backend-neutral IME composition; no gamepad nav | ✅ native host key/mouse/text queues | ◐ vtable: mouse, press, wheel, text-key queue |
@@ -297,7 +297,7 @@ declaration pass (`src/ui/ui_tree.c`).
Props widgets, dialogs, canvas, Tk layout helpers, toasts, theme control),
with `.kry` array declarations lowering to Go slices at the use site.
Remaining boundaries: a forward `goto` over declarations is a loud Go
compile error, `DropdownEx`'s rich option arrays are not expressible from
compile error, `DropdownOptions`' rich option arrays are not expressible from
`.kry`, and C pointer/`Texture2D` values cannot be written (icons pass by
`UIIconType`, option lists as joined strings or `[N]string`).
- `k2js` emits ESM for the web recorder runtime. `make
+223 -27
View File
@@ -2,8 +2,8 @@
This audit compares Kryon's clean native widget surface with Dear ImGui
`imgui.h` at commit
[`96b6eb7728d298decdc939d4c698502220190050`](https://github.com/ocornut/imgui/commit/96b6eb7728d298decdc939d4c698502220190050)
(`IMGUI_VERSION_NUM` 19295, `1.93.0 WIP`). It tracks widget behavior rather
[`334f484892a1fa881d2a927c2aff222c15458b8f`](https://github.com/ocornut/imgui/commit/334f484892a1fa881d2a927c2aff222c15458b8f)
(`IMGUI_VERSION_NUM` 19296, `1.93.0 WIP`). It tracks widget behavior rather
than copying overload names: Kryon's counted value arrays cover the ImGui
`*2`, `*3`, `*4`, `Scalar`, and `ScalarN` fronts without adding aliases.
@@ -11,28 +11,28 @@ than copying overload names: Kryon's counted value arrays cover the ImGui
not proof of every overload, flag, interaction or rendering detail. Full-goal
completion requires those semantics to be checked separately. In particular,
the [composed popup checklist](COMPOSED_POPUP_IMPLEMENTATION.md) records the
remaining combo scope, presentation choices and required rendering evidence.
implemented combo scope and its remaining lifecycle/backend gaps.
| Dear ImGui widget family | Kryon native surface | Status |
|---|---|---|
| Text and value helpers | `Text`, `TextColored`, `TextDisabled`, `TextWrapped`, `LabelText`, `BulletText`, `SeparatorText`, `Value*` | covered |
| Buttons and boolean choices | `Button`, `SmallButton`, `InvisibleButton`, `ArrowButton`, `Checkbox`, `CheckboxFlags`, `Radio`, `Bullet` | covered |
| Text and value helpers | `Text(TextProps)`, `LabelText`, `BulletText`, `SeparatorText`, `Value*` | one canonical text widget owns bounds, wrapping, clipping, color, alignment, and disabled presentation |
| Buttons and boolean choices | `Button`, `SmallButton`, `InvisibleButton`, `ArrowButton`, `Toggle`, `Checkbox`, `CheckboxFlags`, `Radio`, `Bullet` | interactive controls share pointer focus, Tab traversal, Enter/Space activation, disabled gating, popup ownership, and focus presentation; `Bullet` is presentation-only |
| Progress and links | `Progress`, `Href` | covered; `Href` represents both clickable text and open-URL links |
| Images | `Picture`, `ImageWithBg`, `ImageButton` | covered |
| Combo boxes | `Combobox`, `Dropdown`, `Selectable` | option-list helper implemented, including closure on disable or owner removal; arbitrary child composition is still missing |
| Drag values | `DragFloat`, `DragInt`, `DragFloatRange2`, `DragIntRange2` | covered, including counted N-component values |
| Sliders | `SliderFloat`, `SliderInt`, `VSliderFloat`, `VSliderInt`, `SliderAngle` | covered, including counted N-component values |
| Images | `Picture`, `ImageWithBg`, `ImageButton` | covered; `ImageButton` shares ordinary focus and keyboard activation |
| Combo boxes | `Combobox`, `Dropdown`, `Selectable`, `BeginCombo` / `EndCombo` / `CloseCombo` | option-list helper plus a native arbitrary-child scope with explicit close and presentation flags |
| Drag values | `DragFloat`, `DragInt`, `DragFloatRange2`, `DragIntRange2` | covered, including counted N-component values, component focus/Tab traversal, Left/Right adjustment, Home/End bounds, Shift/Alt step modifiers, and Ctrl-click temporary keyboard entry |
| Sliders | `SliderFloat`, `SliderInt`, `VSliderFloat`, `VSliderInt`, `SliderAngle` | counted N-component values, component focus, arrow/Home/End keyboard adjustment, slow/fast modifiers, and Ctrl-click temporary keyboard entry are covered |
| Keyboard inputs | `TextField`, `TextArea`, `InputFloat`, `InputInt`, `InputDouble` | covered, including hints and counted N-component values |
| Color editors and pickers | `ColorEdit3`, `ColorEdit4`, `ColorPicker3`, `ColorPicker4`, `ColorButton` | covered |
| Trees and collapsing headers | `TreeView`, `Collapsible` | `Collapsible` supports tree styling, depth indentation, leaves, selected/disabled state, arbitrary nested children, keyboard expansion, and directional header/parent/child focus traversal |
| Selectables and multi-selection | `Selectable`, `MultiSelectList` | covered, including Ctrl/Shift range selection |
| List boxes | `ListBox`, `BeginListBox` / `EndListBox` | string-list helper and framed scrolling scope for arbitrary native children |
| Color editors and pickers | `ColorEdit3`, `ColorEdit4`, `ColorPicker3`, `ColorPicker4`, `ColorButton` | covered; `ColorButton` shares ordinary focus and keyboard activation |
| Trees and collapsing headers | `TreeView`, `Collapsible` | `Collapsible` supports tree styling, depth indentation, leaves, selected/disabled state, optional close/visibility state, arbitrary nested children, keyboard expansion, and directional header/parent/child focus traversal |
| Selectables and multi-selection | `Selectable`, `MultiSelectList` | covered, including shared focus/Enter/Space activation, Tab traversal, arrow/Home/End navigation, and Ctrl/Shift range selection |
| List boxes | `ListBox`, `BeginListBox` / `EndListBox` | string-list helper with focus, arrow/Home/End navigation and selection-following scroll, plus a framed scrolling scope for arbitrary native children |
| Scrollable child content needed for composed lists and trees | `BeginScroll` / `EndScroll` | C/Go wheel scrolling, scrollbar dragging, and nested clipping implemented and exercised through generated native fixtures |
| Plots | `PlotLines`, `PlotHistogram` | covered |
| Menus | `MenuBar`, `PopupMenu`, `ContextMenu` | covered, including nested submenus |
| Tooltips and popups | `Tooltip`, `PopupMenu`, `ContextMenu`, modal/dialog widgets | covered through bounded native models |
| Tables | `TableView`, `BeginTableCell` / `EndTableCell` | row/cell model includes resizing, frozen rows, sorting, colors, visibility, ordering, slanted headers, and scoped native child widgets in custom-cell mode |
| Tabs | `TabBar`, `ClosableTabBar`, `TabItemButton` | covered |
| Menus | `MenuBar`, `PopupMenu`, `ContextMenu` | nested submenus plus focus, disabled/separator skipping, arrow/Home/End traversal, submenu entry/backout, activation, and Escape dismissal in native C and Go |
| Tooltips and popups | `PopupMenu`, `ContextMenu`, modal/dialog widgets, `BeginPopup` / `EndPopup` / `ClosePopup` with `PopupTooltip`, `PopupModal`, and `PopupContext` | arbitrary popup, hover-tooltip, modal, and right-click context contents are native through one scope |
| Tables | `TableView`, `BeginTableCell` / `EndTableCell` | row/cell model includes resizing, frozen rows, sorting, colors, visibility, ordering, slanted headers, focus/arrow/Tab navigation, activation, clipboard copy/paste targets, and scoped native child widgets in custom-cell mode |
| Tabs | `TabBar`, `BeginTabBar` / `BeginTabItem` / `EndTabItem` / `EndTabBar`, `ClosableTabBar`, `TabItemButton` | canonical tab sizing/scrolling, focus, disabled skipping, keyboard selection/close, popup ownership, close/middle/double-click signals, selected-tab reveal, and reorder reporting are covered; the scope submits arbitrary native children only for the selected item, and omitted scroll state is owned independently by stable tab-bar ID |
| Drag and drop | `DragDropSource`, `DragDropTarget` | covered with typed copied payloads |
| Disabled content | `BeginDisabled`, `EndDisabled`, per-widget `Disabled` fields | covered, including nested scopes |
@@ -52,8 +52,10 @@ storage. Native tests select option 130, beyond the former 128-option cap.
The C rendering test observes the real text renderer receiving a full owned
512-byte overlay label after its caller buffer has been overwritten; Go checks
the corresponding deferred text record. Visible-row painting avoids drawing
every option in a large list. These changes do not resolve process-global C
ownership or arbitrary popup composition.
every option in a large list. The option-list helper's retained state is owned
per render host; native C tests open the same numeric widget ID in independent
stores and verify that popup visibility cannot cross windows. Arbitrary popup
composition uses the separate public combo scope.
Open native C/Go dropdowns support Up/Down, Home/End and Enter, keeping the
highlight separate from committed selection. Native tests navigate a 131-option
@@ -64,9 +66,24 @@ confirmation without prematurely changing selection, opening the control with
Space through its focus ID. Native unit tests cover opening focused positive-ID
controls with Enter, keypad Enter, Space and Down, without moving or committing
the selection, and reject opening under both property and scope disabling.
Go also checks the focused paint record and focus border. General popup
keyboard-focus isolation remains a gap; these tests do not prove complete ImGui
navigation semantics.
Go also checks the focused paint record and focus border. Popup keyboard-focus
isolation is covered separately across buttons, editors, choices, drags, lists,
tables, menus, tabs, collapsibles and generic accelerators; these tests still do
not prove every ImGui navigation semantic or widget-specific shortcut.
Native C and Go sliders now register each counted component as a focus target.
Left/Right adjust horizontal sliders, Up/Down adjust vertical sliders, Home/End
select the range limits, Alt slows adjustment, and Shift accelerates it. Pointer
presses focus the exact component, disabled sliders reject keys, popup ownership
gates keyboard input, and the focused component receives the ordinary focus
presentation. Matching native tests cover component Tab traversal and the
generated `plots.kry` fixture verifies horizontal float and vertical integer
adjustment through k2c and k2go.
Ctrl-clicking a drag or slider component temporarily replaces that component
with the canonical text editor in native C and Go. Valid edits update live,
Enter returns to the numeric control, and typed values remain unclamped like
Dear ImGui's default temporary-input behavior. The generated `plots.kry`
fixture exercises float drag and integer slider entry through k2c and k2go.
Native Go now constrains and flips long dropdowns using the same placement
rules as C, reusing its ordinary scroll container for clipping, wheel input and
@@ -91,6 +108,171 @@ than the window, including capture bounds and row selection. Generated native
parity selects a popup row shifted left from a right-edge owner. These checks
do not cover multi-monitor work areas or arbitrary popup placement flags.
For composed-popup painting, the C framebuffer regression verifies translucent
immediate and retained capture and compares premultiplied composition against
direct source-over drawing. This manually configured backend test establishes
the required alpha pipeline. Captured retained nodes now preserve declaration-time
blend state and restore the caller's active and pending custom blend settings
after painting, verified by the framebuffer test. The public combo scope uses
the C paint-layer context, which owns and
composites textures with scope-level drawing-state restoration. Real pixel tests
cover mixed translucent/retained content, nested ordering, hidden parents and
missing owners over an existing target. Native `UIWindow` now owns layer frame,
composition and destruction. Main UI frames now own a separate context with
automatic frame composition and pre-graphics-shutdown cleanup.
Additional framebuffer checks interleave independent contexts with identical
owner IDs, resize one, destroy the other while a destination is active, and
verify the real X11 UIWindow presenter's owned-layer pixels. These prove paint
resource isolation. The UIWindow presenter regression additionally exercises
automatic context management across consecutive frames, a missing owner and
closing an active frame. It does not prove isolation of the still-global C
widget/input state or Win32 runtime behavior.
The main-host framebuffer regression also checks a missing owner, interleaved
auxiliary presentation and graphics-context close/reopen. Auxiliary texture
readback no longer changes the main frame's active destination.
C paint layers now isolate the retained layout path. Headless node/position
checks and real pixels verify a popup's independent Column origin and that the
surrounding Row resumes at its next slot. Unclosed child layouts are rejected.
The public combo scope uses this isolation so its child layouts do not consume
the surrounding layout cursor.
C layer disabled scopes now inherit the parent's state without allowing child
scope endings to unwind the parent. Headless nested-scope tests and the real
layer test cover restoration, with invalid-scope checks for an unclosed child.
C layers also isolate input clips and scroll depth from the owner. Ordinary
button tests verify escaped clipping without bypassing modal capture, and real
pixels verify mixed content outside a 1x1 scrolling owner. Popup-to-background
and nested-popup input ownership now have a private C registry consulted by the
shared hit-test path. Ordinary button tests cover nested ownership, background
controls, dismissal, missing owners, context isolation and branch reordering.
Paint hosts now own and advance these registries automatically. The graphical
test checks capture before redeclaration, auxiliary-window isolation, parent
binding restoration and missing-owner retirement. Retained hit testing and
button hover/press state now use declaration-time popup ownership. Tests cover
child precedence over later parent/background nodes, dismissal restoring the
parent then background, pending-tree isolation and stale/destroyed registries.
Deferred pointer-focus registration also uses those snapshots; a test isolates
the deferred pass from immediate button focus and verifies modal blocking.
The same regression checks emitted click events: a blocked popup child emits
none, while an eligible child emits one. Deferred hit testing and hover/press
state share the complete capture predicate with focus registration.
Public composed-scope integration is covered. A newly opened top popup now
saves the displaced focus and gives focus to its first eligible child. Closing
a nested popup restores its parent's focus, while closing or omitting the root
owner restores the background focus. Active drag values, sliders, splitters and
table column resizing now retain the popup branch that started the gesture.
The same composed `Popup` scope now supports `PopupTooltip`: hover over an
explicit trigger submits arbitrary native child widgets into a non-input-capturing
overlay layer without an external `open` value. Matching C and Go unit tests
verify nested layout/child painting, disappearance outside the trigger and no
popup-input ownership. The generated C/Go composed fixture also verifies hover
visibility and that an underlying button still receives its click. The former
text-only `Tooltip` helper and `TooltipProps` surface were removed after all
maintained callers migrated, leaving one tooltip implementation.
`PopupModal` extends that same scope rather than adding a modal-specific child
API. It draws a full-view backdrop, keeps outside pointer input from reaching
background controls, preserves arbitrary nested children, and closes on Escape
or explicit caller action rather than an outside release. Matching native and
generated C/Go tests cover these semantics.
`PopupContext` extends the scope with a right-release trigger instead of adding
a context-only child API. The caller retains open state and stable panel bounds;
ordinary children, explicit close, outside dismissal, disabled rejection and
missing-owner cleanup remain shared with `Popup`. Matching native C/Go tests
and a generated k2c/k2cpp/k2go fixture cover the trigger and child lifecycle.
Matching C and Go tests now cover keyboard opening of a combo inside the top
popup versus a blocked parent, with popup bounds away from the combo to prove
the check is independent of pointer position. Child/branch dismissal restores
parent/background keyboard eligibility. This is not Tab trapping or general
button/editor keyboard isolation.
TextField and TextArea now gate editing by top-popup keyboard ownership in C
and Go. Native tests verify that typing leaves a focused parent editor unchanged
and edits an eligible child. C covers both immediate and deferred tree routing;
the immediate TextArea path now avoids renderer calls in headless tests.
All shortcuts and input replay across popup dismissal are not established by
these tests.
Generic native accelerators now have matching C and Go APIs and top-popup
ownership. Generated k2c/k2cpp/k2go coverage proves Ctrl+C dispatch inside the
active popup, suppression of the same background chord, and restoration after
the popup is explicitly closed. Widget-specific shortcut paths still require
their own ownership coverage.
Collapsible/tree-header arrows now have matching native and generated popup
ownership coverage, including background restoration after close.
Selectable-text copy is likewise ownership-gated in C and Go; native Go tests
cover both blocked background and eligible popup selection copies.
Table focus, display-order arrow and Tab/Shift+Tab navigation, Enter/F2 activation, Escape
clearing, and selection-following scroll now share a native C/Go contract.
Generated k2c and k2go fixtures exercise the same movement and activation, and
native popup tests prove that a focused table cannot consume keys owned by a
higher popup branch.
Cell, full-row, full-column, and override copying plus paste target reporting
now run through that same owned key path. Native C tests cover every copy shape,
and the shared generated fixture proves cell-copy and paste parity in k2c
and k2go.
Separate native Tab tests now cover ownership-filtered focus destinations,
forward/reverse wrapping, duplicate registrations and traversal after explicit
child/branch dismissal. Go tests exercise previous-frame order and real editor
Tab events. C finalizes focus while the host registry is still bound. Separate
native lifecycle tests cover first-child acquisition and restoration after
nested close, root close and missing-owner retirement. Full keyboard routing
remains work.
Ordinary Go Button now supports focus registration, pointer focus, Enter/Space
activation and Tab traversal. C keyboard activation consults popup ownership for
both immediate returns and deferred click events. Matching native popup tests
cover blocked parent versus eligible child activation. Generated C/Go checks
extend `buttons_layout.kry` coverage with Enter/Space, disabled activation
rejection and Tab skipping the disabled button; these additional assertions are
native-only and do not claim JavaScript keyboard coverage.
The same focusable-activation contract now backs native C and Go `Toggle`, `Checkbox`,
`CheckboxFlags`, `Radio`, `Selectable`, `InvisibleButton`, `ImageButton`, and
`ColorButton`, instead of duplicating key handling in each paint routine.
Direct runtime tests cover Enter/Space, Tab, disabled scopes, focus presentation,
and top-popup ownership. The generated `basic_controls.kry` fixture exercises
the canonical checkbox and props-based choice widgets through k2c and k2go;
JavaScript remains outside these added keyboard assertions.
Native missing-owner tests additionally omit the child and then the entire
branch across frames. C now retires missing input ownership before filtering
focus, matching Go's frame-end behavior; Tab reaches the surviving parent or
background in the same frame. Popup lifecycle tests separately verify automatic
restoration without a navigation event.
Text replay tests now span dismissal: focused parent TextField/TextArea controls
reject captured text, remain unchanged on the next frame without input, and
accept fresh text later. C covers both injected and platform-queued characters,
same-frame dismissal, and queued Backspace/Enter for TextField. Popup-captured
leftovers now expire at frame end. Go's existing frame cleanup passes the matching
text test. IME composition and device-level Android delivery remain unverified.
C retained IME now has separate regressions: blocked commits do not replay,
read-only TextField/TextArea reject commits, and TextField preedit cancels on
focus loss, a read-only transition or popup capture without revival. This does
not establish immediate C editor composition, native Go composition events or
device-level IME delivery.
Native Go now implements runtime-local composition events and per-editor
preedit for TextField/TextArea. Tests cover queue isolation/limits, preedit
persistence without buffer mutation, UTF-8 commit, cancellation, editor removal,
focus loss, disabling and popup dismissal. `composition.kry` is executed through
generated C and Go to verify preedit/commit/cancel behavior; it is not executed
by the JavaScript runner. OS-window Go IME delivery and detailed preedit
cursor/selection rendering remain unfinished.
Read-only TextField/TextArea behavior is now covered by the native generated
composition fixture: selection/copy remains usable while text, cut/paste,
deletion and IME commits cannot mutate buffers. C retained mutation paths now
enforce the property; Go text props expose ReadOnly and retain focus styling
while suppressing the insertion caret. Go tests cover preedit cancellation,
buffer preservation, rejected-input expiry and fresh editing after re-enabling.
Native C and Go list boxes now register with ordinary Tab focus, expose a
visible focus presentation, and move selection with Up/Down/Home/End while
keeping the selected row visible. Disabled and higher-popup-owned lists reject
the same keys. The shared generated list fixture exercises the navigation
contract through k2c and k2go without adding backend-specific widget aliases.
Native C and Go menus share one navigation model across menu bars, standalone
popup menus, context menus, and recursive submenus. Arrow, Home, End,
Enter/Space, and Escape navigation skips separators and disabled commands,
respects the active popup owner, and does not let passive pointer hover steal
keyboard focus. The generated menu fixture exercises nested activation through
k2c and k2go. C owns a recursive snapshot of deferred overlay items, so
generated frame-local menu arrays remain valid through end-of-frame painting.
`tests/parity/drag_drop.kry` is executed through generated C and Go. A clipped
source cannot activate, and a clipped target cannot consume the release before
an eligible target. Both runners mutate the source bytes after pressing and
@@ -98,8 +280,13 @@ check that the target receives the original copied payload. This native-only
fixture is not executed by the JavaScript runner. Go runtime tests additionally
exercise drag sources and targets beneath a popup, within its input scope, and
under disabled/clip restrictions, including rejection without losing the release
or payload. Active scalar-slider/resize drags and composed popup dismissal are
not established by these drag-and-drop tests.
or payload. Separate native C/Go tests cover active drag values, sliders,
splitters and table resizing: an owned gesture follows the pointer beyond its
original bounds, a newly opened popup preempts a background gesture, and popup
dismissal cancels the gesture before a background widget can inherit it.
The composed-popup parity fixture drives that ownership lifecycle through
generated C and native Go, while k2cpp compiles the same `.kry` source against
the C runtime surface.
`tests/parity/scroll_content.kry` is driven through generated C and Go in the
parity harness. It checks wheel-driven offset changes, visible child clicks,
@@ -122,15 +309,14 @@ parent/child, including a leaf and a disabled header that navigation must skip.
The native fixture also selects a combo popup row outside the owner's scroll
viewport while a previously drawn button occupies the same bounds. Go pixel
coverage verifies that the deferred popup paints above later content, without
inheriting the owner's scroll clip. This does not yet provide arbitrary combo
children. Native generated dismissal checks cover Escape and outside clicks,
inheriting the owner's scroll clip. The separate composed-combo fixture covers
arbitrary native children. Native generated dismissal checks cover Escape and outside clicks,
unchanged selection, and restoration of underlying button interaction. Go also
tests closing when the option list becomes empty.
Generated C/Go tests also check that an earlier background scroll scope does
not change its offset on wheel input over an open combo popup. Native Go unit
tests cover the same ownership rule for scroll scopes, lists, trees, source
views and tables, including disabled and clipped content.
Arbitrary combo composition remains a separate gap as listed above.
Generated native custom-cell tests place a button and checkbox in adjacent
cells, verify independent state and no table-selection interception, and reject
@@ -154,3 +340,13 @@ slanted glyph clipping, while Go clips its software rasterization directly.
`header_angle` is in degrees, clamped to -89 through 89, with
non-finite values treated as zero. `header_height` defaults to 30 and cannot
reduce the header below that height.
Native C and Go now expose the missing composed tab contract through
`BeginTabBar`, `BeginTabItem`, `EndTabItem`, and `EndTabBar`. The bar delegates
all header interaction and painting to the canonical `TabBar`; the scope only
controls arbitrary child submission, so there is no second tab renderer.
Selection changes are written to caller state before item scopes are evaluated
in the same frame. Direct C and Go tests plus generated C, Go, and JavaScript
tests switch tabs by keyboard, activate overlapping child buttons, and verify
that only the selected item's child can receive input. Invalid bars do not open
a scope, and unbalanced item or bar endings are rejected.
+121 -109
View File
@@ -697,75 +697,6 @@ include/kryon_version.h macro KRYON_VERSION_MAJOR
include/kryon_version.h macro KRYON_VERSION_MINOR
include/kryon_version.h macro KRYON_VERSION_PATCH
include/kryon_version.h macro KRYON_VERSION_STRING
include/ksync_account.h enum KSYNC_ACCOUNT_EXPORT_ENCRYPTED_TEXT_SIZE
include/ksync_account.h enum KSYNC_ACCOUNT_EXPORT_TEXT_SIZE
include/ksync_account.h enum KSYNC_ACCOUNT_PASSPHRASE_ITERATIONS
include/ksync_account.h enum KSYNC_PRIVATE_KEY_HEX_SIZE
include/ksync_account.h enum KSYNC_PUBLIC_ID_HEX_SIZE
include/ksync_account.h enum KSYNC_PUBLIC_KEY_HEX_SIZE
include/ksync_account.h enum KSYNC_SIGNATURE_HEX_SIZE
include/ksync_account.h function CreateKsyncAccount
include/ksync_account.h function ExportKsyncAccountFile
include/ksync_account.h function ExportKsyncAccountFileEncrypted
include/ksync_account.h function ExportKsyncAccountText
include/ksync_account.h function ExportKsyncAccountTextEncrypted
include/ksync_account.h function GetKsyncAccountLastError
include/ksync_account.h function HasKsyncAccountValues
include/ksync_account.h function ImportKsyncAccountFile
include/ksync_account.h function ImportKsyncAccountFileEncrypted
include/ksync_account.h function IsKsyncAccountAvailable
include/ksync_account.h function KsyncSha256Hex
include/ksync_account.h function ParseKsyncAccountText
include/ksync_account.h function ParseKsyncAccountTextEncrypted
include/ksync_account.h function SignKsyncAccountHex
include/ksync_account.h function ValidateKsyncAccount
include/ksync_crypto.h function KsyncCryptoBytesToHex
include/ksync_crypto.h function KsyncCryptoChaCha20Poly1305Open
include/ksync_crypto.h function KsyncCryptoChaCha20Poly1305Seal
include/ksync_crypto.h function KsyncCryptoHexToBytes
include/ksync_crypto.h function KsyncCryptoHmacSha256
include/ksync_crypto.h function KsyncCryptoPbkdf2Sha256
include/ksync_crypto.h function KsyncCryptoRandom
include/ksync_crypto.h function KsyncCryptoSha256
include/ksync_sync.h enum KSYNC_SYNC_AUTH_FAILED
include/ksync_sync.h enum KSYNC_SYNC_CHALLENGE_FAILED
include/ksync_sync.h enum KSYNC_SYNC_INVALID_URL
include/ksync_sync.h enum KSYNC_SYNC_NO_ACCOUNT
include/ksync_sync.h enum KSYNC_SYNC_OK
include/ksync_sync.h enum KSYNC_SYNC_PAYLOAD_FAILED
include/ksync_sync.h enum KSYNC_SYNC_REQUEST_FAILED
include/ksync_sync.h enum KSYNC_SYNC_SIGN_FAILED
include/ksync_sync.h function AppendKsyncSyncBuffer
include/ksync_sync.h function AppendKsyncSyncBufferJSONString
include/ksync_sync.h function ClearKsyncSyncAuthToken
include/ksync_sync.h function DeleteKsyncSyncAccount
include/ksync_sync.h function FindKsyncSyncJSONInt64
include/ksync_sync.h function FindKsyncSyncJSONString
include/ksync_sync.h function FreeKsyncSyncBuffer
include/ksync_sync.h function GetKsyncSyncResultName
include/ksync_sync.h function IsKsyncSyncURLValid
include/ksync_sync.h function JoinKsyncSyncURL
include/ksync_sync.h function JoinKsyncSyncWebSocketURL
include/ksync_sync.h function KsyncDefaultHttpRequest
include/ksync_sync.h function KsyncRemoteEventWait
include/ksync_sync.h function KsyncWebRemoteEventsPoll
include/ksync_sync.h function KsyncWebRemoteEventsStart
include/ksync_sync.h function KsyncWebSyncPoll
include/ksync_sync.h function KsyncWebSyncStart
include/ksync_sync.h function LoginKsyncSync
include/ksync_sync.h function NormalizeKsyncSyncURL
include/ksync_sync.h function RequestKsyncSyncBearer
include/ksync_sync.h function RunKsyncSync
include/ksync_sync.h function UnwrapKsyncSyncPayload
include/ksync_sync.h function WrapKsyncSyncPayload
include/ksync_sync.h typedef KsyncSyncApplyResponseFn
include/ksync_sync.h typedef KsyncSyncBuildPayloadFn
include/ksync_sync.h typedef KsyncSyncFreePayloadFn
include/ksync_sync.h typedef KsyncSyncGetTextFn
include/ksync_sync.h typedef KsyncSyncHttpRequestFn
include/ksync_sync.h typedef KsyncSyncLogFn
include/ksync_sync.h typedef KsyncSyncSetTextFn
include/ksync_sync.h typedef KsyncSyncVoidFn
include/locale.h function FormatLocaleText
include/locale.h function GetCurrentLocaleCode
include/locale.h function GetCurrentLocaleIndex
@@ -944,6 +875,74 @@ include/spritesheet.h function SpriteSheetFrameCount
include/spritesheet.h function SpriteSheetFrameSource
include/spritesheet.h function SpriteSheetGrid
include/spritesheet.h function SpriteSheetNormalizeFrame
include/sync.h enum SYNC_AUTH_FAILED
include/sync.h enum SYNC_CHALLENGE_FAILED
include/sync.h enum SYNC_INVALID_URL
include/sync.h enum SYNC_NO_ACCOUNT
include/sync.h enum SYNC_OK
include/sync.h enum SYNC_PAYLOAD_FAILED
include/sync.h enum SYNC_REQUEST_FAILED
include/sync.h enum SYNC_SIGN_FAILED
include/sync.h function AppendSyncBuffer
include/sync.h function AppendSyncBufferJSONString
include/sync.h function ClearSyncAuthToken
include/sync.h function DefaultSyncHttpRequest
include/sync.h function DeleteSyncAccount
include/sync.h function FindSyncJSONInt64
include/sync.h function FindSyncJSONString
include/sync.h function FreeSyncBuffer
include/sync.h function GetSyncResultName
include/sync.h function IsSyncURLValid
include/sync.h function JoinSyncURL
include/sync.h function JoinSyncWebSocketURL
include/sync.h function LoginSync
include/sync.h function NormalizeSyncURL
include/sync.h function PollWebRemoteEvents
include/sync.h function PollWebSync
include/sync.h function RequestSyncBearer
include/sync.h function RunSync
include/sync.h function StartWebRemoteEvents
include/sync.h function StartWebSync
include/sync.h function UnwrapSyncPayload
include/sync.h function WaitForRemoteSyncEvent
include/sync.h function WrapSyncPayload
include/sync.h typedef SyncApplyResponseFn
include/sync.h typedef SyncBuildPayloadFn
include/sync.h typedef SyncFreePayloadFn
include/sync.h typedef SyncGetTextFn
include/sync.h typedef SyncHttpRequestFn
include/sync.h typedef SyncLogFn
include/sync.h typedef SyncSetTextFn
include/sync.h typedef SyncVoidFn
include/sync_crypto.h enum SYNC_ED25519_PRIVATE_KEY_SIZE
include/sync_crypto.h enum SYNC_ED25519_PUBLIC_KEY_SIZE
include/sync_crypto.h enum SYNC_ED25519_SIGNATURE_SIZE
include/sync_crypto.h enum SYNC_SHA256_HEX_SIZE
include/sync_crypto.h function SyncCryptoBytesToHex
include/sync_crypto.h function SyncCryptoChaCha20Poly1305Open
include/sync_crypto.h function SyncCryptoChaCha20Poly1305Seal
include/sync_crypto.h function SyncCryptoCreateDeviceKey
include/sync_crypto.h function SyncCryptoHexToBytes
include/sync_crypto.h function SyncCryptoHmacSha256
include/sync_crypto.h function SyncCryptoPbkdf2Sha256
include/sync_crypto.h function SyncCryptoRandom
include/sync_crypto.h function SyncCryptoSha256
include/sync_crypto.h function SyncCryptoSha256Hex
include/sync_crypto.h function SyncCryptoSignDevice
include/sync_crypto.h function SyncCryptoVerifyDevice
include/sync_nodes.h enum SYNC_NODE_ID_SIZE
include/sync_nodes.h enum SYNC_NODE_NAME_SIZE
include/sync_nodes.h enum SYNC_NODE_PAIRED
include/sync_nodes.h enum SYNC_NODE_POOL_CAPACITY
include/sync_nodes.h enum SYNC_NODE_PUBLIC
include/sync_nodes.h enum SYNC_NODE_URL_SIZE
include/sync_nodes.h function AddSyncNode
include/sync_nodes.h function BuildSyncNodeStorageKey
include/sync_nodes.h function GetActiveSyncNode
include/sync_nodes.h function InitSyncNodePool
include/sync_nodes.h function MarkSyncNodeResult
include/sync_nodes.h function RunSyncWithNodes
include/sync_nodes.h function SelectSyncNode
include/termi.h enum TERMI_ATTR_BOLD
include/termi.h enum TERMI_ATTR_DIM
include/termi.h enum TERMI_ATTR_NONE
@@ -1382,9 +1381,14 @@ include/ui_controls.h function RenderStyledButton
include/ui_controls.h function ScoreControl
include/ui_controls.h function SegmentedControl
include/ui_controls.h function SetTextAreaSelection
include/ui_controls.h function SetUIDropdownClipBottom
include/ui_controls.h function SetUIDropdownClipTop
include/ui_controls.h function SetUIStyleTokens
include/ui_controls.h function TextAreaGutter
include/ui_controls.h function TextBufferBracketMatch
include/ui_controls.h function TextBufferColumnAtCursor
include/ui_controls.h function TextBufferIndentLine
include/ui_controls.h function TextBufferLineAtCursor
include/ui_controls.h function TextBufferLineCount
include/ui_controls.h function TextBufferToggleLineComment
include/ui_controls.h macro RICH_TEXT_TOOLS_DEFAULT
include/ui_controls.h typedef TextInputFilter
include/ui_controls.h typedef UIVerticalSliderMarkCallback
@@ -1440,6 +1444,9 @@ include/ui_core.h function UIReleaseConsumed
include/ui_core.h function UITransitionCuesEnabled
include/ui_core.h typedef TextInputPlatformCallback
include/ui_dpi.h function FixUIDPIFramebufferColor
include/ui_dpi.h function GetLayoutHeight
include/ui_dpi.h function GetLayoutWidth
include/ui_dpi.h function GetRenderScale
include/ui_dpi.h function InitUIDPI
include/ui_dpi.h function InvalidateUIDPI
include/ui_dpi.h function IsUIDPIDirty
@@ -1447,7 +1454,6 @@ include/ui_dpi.h function SetUIDeviceDensity
include/ui_dpi.h function UpdateUIDPI
include/ui_dpi.h macro UI_DPI_BASE_HEIGHT
include/ui_dpi.h macro UI_DPI_BASE_WIDTH
include/ui_draw.h function DrawCenteredUIControlText
include/ui_draw.h function DrawFittedTextInRect
include/ui_draw.h function DrawLeftUIControlTextInRect
include/ui_draw.h function FitFontSize
@@ -1569,6 +1575,7 @@ include/ui_icon_types.h enum UI_ICON_TYPE_TIMELINE
include/ui_icon_types.h enum UI_ICON_TYPE_TODOS
include/ui_icon_types.h enum UI_ICON_TYPE_TRASH
include/ui_icon_types.h enum UI_ICON_TYPE_VENUS
include/ui_icon_types.h enum UI_ICON_TYPE_WARNING
include/ui_icon_types.h enum UI_ICON_TYPE_WEEKLY
include/ui_icon_types.h enum UI_ICON_TYPE_WORKBOOK_CLEAR_FORMATTING
include/ui_icon_types.h enum UI_ICON_TYPE_WORKBOOK_FILL_COLOR
@@ -1585,6 +1592,7 @@ include/ui_icons.h enum UI_ICON_SHEET_TILES
include/ui_icons.h enum UI_ICON_SHEET_UI
include/ui_icons.h function DrawIcon
include/ui_icons.h function DrawIconByName
include/ui_icons.h function DrawProfilePictureIcon
include/ui_icons.h function GetUIIconAsset
include/ui_icons.h function GetUIIconAssetByName
include/ui_icons.h function LoadAllUIIconTextures
@@ -1666,38 +1674,38 @@ include/ui_picture.h enum PICTURE_FIT_CONTAIN
include/ui_picture.h enum PICTURE_FIT_COVER
include/ui_picture.h enum PICTURE_FIT_STRETCH
include/ui_picture.h macro KRY_PICTURE_CACHE_MAX
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_BAMBUS
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_BIRD
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_BOWL
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_BUSH
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_BUTTERFLY
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_CACTUS
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_COFFEE
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_DRAGONFLY
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_FIREPLACE
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_FLOWER1
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_FLOWER2
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_FOX
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_HEART
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_INCENSE
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_LOTUS
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_MOUNTAIN
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_MUSHROOM
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_NONE
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_PALM
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_PERSON1
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_RAINBOW
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TENT
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TREE1
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TREE2
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TREE3
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TREE4
include/ui_profile.h enum UI_KSYNC_PROFILE_ICON_TREE5
include/ui_profile.h function GetUIKsyncIDForProfilePictureIconType
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_BAMBUS
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_BIRD
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_BOWL
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_BUSH
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_BUTTERFLY
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_CACTUS
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_COFFEE
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_DRAGONFLY
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_FIREPLACE
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_FLOWER1
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_FLOWER2
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_FOX
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_HEART
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_INCENSE
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_LOTUS
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_MOUNTAIN
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_MUSHROOM
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_NONE
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_PALM
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_PERSON1
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_RAINBOW
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TENT
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TREE1
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TREE2
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TREE3
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TREE4
include/ui_profile.h enum UI_SYNC_PROFILE_ICON_TREE5
include/ui_profile.h function GetUIProfilePictureIconCount
include/ui_profile.h function GetUIProfilePictureIconName
include/ui_profile.h function GetUIProfilePictureIconType
include/ui_profile.h function GetUIProfilePictureIconTypeForKsyncID
include/ui_profile.h function GetUIProfilePictureIconTypeForSyncID
include/ui_profile.h function GetUISyncIDForProfilePictureIconType
include/ui_reorder.h function UpdateUIReorderList
include/ui_rows.h function GetUIButtonRowHeight
include/ui_rows.h function GetUILabelTextFieldHeight
@@ -1725,7 +1733,7 @@ include/ui_rows.h function UIFormTextFieldEx
include/ui_rows.h function UIFormY
include/ui_scaling.h function ClampUIPx
include/ui_scaling.h function GetUIScale
include/ui_scaling.h function ScaleUIPx
include/ui_scaling.h function Scale
include/ui_scaling.h function SetUIScale
include/ui_scroll.h function BeginUIScreenScaffold
include/ui_scroll.h function BeginUIScrollContainer
@@ -1910,7 +1918,6 @@ include/ui_tree.h enum UI_WIDGET_TAB_BAR_NODE
include/ui_tree.h enum UI_WIDGET_TEXT_AREA_NODE
include/ui_tree.h enum UI_WIDGET_TEXT_FIELD_NODE
include/ui_tree.h enum UI_WIDGET_TEXT_INPUT_PAINT_NODE
include/ui_tree.h enum UI_WIDGET_TEXT_IN_RECT_NODE
include/ui_tree.h enum UI_WIDGET_TEXT_NODE
include/ui_tree.h enum UI_WIDGET_THEME_PICKER_NODE
include/ui_tree.h enum UI_WIDGET_THEME_SETTINGS_NODE
@@ -1919,9 +1926,13 @@ include/ui_tree.h enum UI_WIDGET_TOGGLE_NODE
include/ui_tree.h function ActionModal
include/ui_tree.h function ArrowButton
include/ui_tree.h function Background
include/ui_tree.h function BeginCombo
include/ui_tree.h function BeginDisabled
include/ui_tree.h function BeginListBox
include/ui_tree.h function BeginPopup
include/ui_tree.h function BeginScroll
include/ui_tree.h function BeginTabBar
include/ui_tree.h function BeginTabItem
include/ui_tree.h function BeginTableCell
include/ui_tree.h function BeginTree
include/ui_tree.h function Bevel
@@ -1939,6 +1950,8 @@ include/ui_tree.h function Checkbox
include/ui_tree.h function CheckboxFlags
include/ui_tree.h function CheckboxRow
include/ui_tree.h function ClosableTabBar
include/ui_tree.h function CloseCombo
include/ui_tree.h function ClosePopup
include/ui_tree.h function Collapsible
include/ui_tree.h function ColorButton
include/ui_tree.h function ColorEdit3
@@ -1957,11 +1970,15 @@ include/ui_tree.h function DragFloatRange2
include/ui_tree.h function DragInt
include/ui_tree.h function DragIntRange2
include/ui_tree.h function Dropdown
include/ui_tree.h function DropdownEx
include/ui_tree.h function DropdownOptions
include/ui_tree.h function End
include/ui_tree.h function EndCombo
include/ui_tree.h function EndDisabled
include/ui_tree.h function EndListBox
include/ui_tree.h function EndPopup
include/ui_tree.h function EndScroll
include/ui_tree.h function EndTabBar
include/ui_tree.h function EndTabItem
include/ui_tree.h function EndTableCell
include/ui_tree.h function EndTree
include/ui_tree.h function Focus
@@ -2066,13 +2083,9 @@ include/ui_tree.h function TabItemButton
include/ui_tree.h function TableView
include/ui_tree.h function Text
include/ui_tree.h function TextArea
include/ui_tree.h function TextColored
include/ui_tree.h function TextDisabled
include/ui_tree.h function TextField
include/ui_tree.h function TextInRect
include/ui_tree.h function TextLines
include/ui_tree.h function TextPopover
include/ui_tree.h function TextWrapped
include/ui_tree.h function ThemePicker
include/ui_tree.h function ThemeSettings
include/ui_tree.h function ThemeSwitcher
@@ -2080,7 +2093,6 @@ include/ui_tree.h function TitleBar
include/ui_tree.h function Toggle
include/ui_tree.h function Toolbar
include/ui_tree.h function ToolbarHeader
include/ui_tree.h function Tooltip
include/ui_tree.h function TopNav
include/ui_tree.h function TransitionFade
include/ui_tree.h function TreeView
+7 -6
View File
@@ -6,9 +6,11 @@ Generated by `tests/runtime_parity_test.sh`. Do not edit by hand.
|---|---|---|---|
| `ArrowButton` | `(ArrowButtonProps) (bool)` | `int ArrowButton(ArrowButtonProps button);` | ok |
| `Background` | `(Color)` | `void Background(Color color);` | ok |
| `BeginCombo` | `(ComboProps) (bool)` | `int BeginCombo(ComboProps combo);` | ok |
| `BeginDisabled` | `(bool)` | `void BeginDisabled(int disabled);` | ok |
| `BeginFrame` | `()` | `void BeginFrame(void);` | ok |
| `BeginListBox` | `(ListBoxProps) (Rectangle)` | `Rectangle BeginListBox(ListBoxProps list);` | ok |
| `BeginPopup` | `(PopupProps) (bool)` | `int BeginPopup(PopupProps popup);` | ok |
| `BeginScroll` | `(Rectangle, int32, *int32) (Rectangle)` | `Rectangle BeginScroll(Rectangle bounds, int content_height, int *scroll_offset);` | ok |
| `BeginTableCell` | `(TableViewProps, int32, int32) (Rectangle)` | `Rectangle BeginTableCell(TableViewProps table, int row, int column);` | ok |
| `Bevel` | `(x, y, w, h int32, light, dark Color)` | `void Bevel(int x, int y, int w, int h, Color light, Color dark);` | ok |
@@ -20,6 +22,8 @@ Generated by `tests/runtime_parity_test.sh`. Do not edit by hand.
| `Checkbox` | `(int32, int32, int32, string, *int32) (bool)` | `int Checkbox(int id, int x, int y, const char *label, int *value);` | ok |
| `CheckboxFlags` | `(CheckboxFlagsProps) (bool)` | `int CheckboxFlags(CheckboxFlagsProps checkbox);` | ok |
| `ClosableTabBar` | `(ClosableTabBarProps) (int32)` | `int ClosableTabBar(ClosableTabBarProps bar);` | ok |
| `CloseCombo` | `()` | `void CloseCombo(void);` | ok |
| `ClosePopup` | `()` | `void ClosePopup(void);` | ok |
| `Collapsible` | `(props CollapsibleProps) (int32)` | `int Collapsible(CollapsibleProps section);` | ok |
| `ColorButton` | `(ColorButtonProps) (bool)` | `int ColorButton(ColorButtonProps button);` | ok |
| `ColorEdit3` | `(ColorEditProps) (bool)` | `int ColorEdit3(ColorEditProps edit);` | ok |
@@ -38,9 +42,11 @@ Generated by `tests/runtime_parity_test.sh`. Do not edit by hand.
| `DragInt` | `(DragIntProps) (bool)` | `int DragInt(DragIntProps drag);` | ok |
| `DragIntRange2` | `(DragIntRange2Props) (bool)` | `int DragIntRange2(DragIntRange2Props drag);` | ok |
| `Dropdown` | `(id, x, y, w, h int32, options any, rest ...any) (bool)` | `int Dropdown(int id, int x, int y, int w, int h, const char **options, int option_count, int *selected_index);` | ok |
| `EndCombo` | `()` | `void EndCombo(void);` | ok |
| `EndDisabled` | `()` | `void EndDisabled(void);` | ok |
| `EndFrame` | `()` | `void EndFrame(void);` | ok |
| `EndListBox` | `()` | `void EndListBox(void);` | ok |
| `EndPopup` | `()` | `void EndPopup(void);` | ok |
| `EndScroll` | `()` | `void EndScroll(void);` | ok |
| `EndTableCell` | `()` | `void EndTableCell(void);` | ok |
| `Href` | `(props HrefProps) (bool)` | `int Href(HrefProps link);` | ok |
@@ -84,18 +90,13 @@ Generated by `tests/runtime_parity_test.sh`. Do not edit by hand.
| `Stack` | `(ColumnProps)` | `NodeId Stack(ColumnProps props);` | ok |
| `TabItemButton` | `(TabItemButtonProps) (bool)` | `int TabItemButton(TabItemButtonProps button);` | ok |
| `TableView` | `(props TableViewProps) (int32)` | `int TableView(TableViewProps table);` | ok |
| `Text` | `(string, int32, int32, int32, Color)` | `void Text(const char *text, int x, int y, int font_size, Color color);` | ok |
| `Text` | `(TextProps)` | `void Text(TextProps text);` | ok |
| `TextArea` | `(props TextAreaProps) (bool)` | `int TextArea(TextAreaProps area);` | ok |
| `TextColored` | `(text string, x, y, fontSize int32, color Color)` | `void TextColored(const char *text, int x, int y, int font_size, Color color);` | ok |
| `TextDisabled` | `(text string, x, y, fontSize int32)` | `void TextDisabled(const char *text, int x, int y, int font_size);` | ok |
| `TextField` | `(TextFieldProps)` | `int TextField(TextFieldProps field);` | ok |
| `TextInRect` | `(text string, rect Rectangle, fontSize int32, color Color)` | `void TextInRect(const char *text, Rectangle rect, int font_size, Color color);` | ok |
| `TextLines` | `(lines any, count int32, x int32, y *int32, font, lineH int32, color Color)` | `void TextLines(const char **lines, int count, int x, int *y, int font, int line_h, Color color);` | ok |
| `TextWrapped` | `(text string, bounds Rectangle, fontSize int32, color Color)` | `void TextWrapped(const char *text, Rectangle bounds, int font_size, Color color);` | ok |
| `TitleBar` | `(title string, height int32)` | `void TitleBar(const char *title, int height);` | ok |
| `Toggle` | `(id, x, y, w, h int32, value *int32, offLabel, onLabel string) (bool)` | `int Toggle(int id, int x, int y, int w, int h, int *value, const char *off_label, const char *on_label);` | ok |
| `Toolbar` | `(props ToolbarProps) (ToolbarResult)` | `ToolbarResult Toolbar(ToolbarProps toolbar);` | ok |
| `Tooltip` | `(TooltipProps) (bool)` | `int Tooltip(TooltipProps tooltip);` | ok |
| `TopNav` | `(props TopNavProps)` | `TopNavResult TopNav(TopNavProps nav);` | ok |
| `TreeView` | `(props TreeViewProps) (int32)` | `int TreeView(TreeViewProps tree);` | ok |
| `VSliderFloat` | `(SliderFloatProps) (bool)` | `int VSliderFloat(SliderFloatProps slider);` | ok |
+304 -67
View File
@@ -2659,7 +2659,6 @@
"Text",
"TextArea",
"TextField",
"TextInRect",
"TextLines",
"TitleBar",
"Toast",
@@ -2766,6 +2765,7 @@
"widgets": [
"Checkbox",
"Dropdown",
"Radio",
"Screen",
"Slider",
"Toggle"
@@ -2969,6 +2969,211 @@
},
"widgets": []
},
{
"id": "tests-parity-composed_combo",
"label": "Native Composed Combo Parity",
"path": "tests/parity/composed_combo.kry",
"pipelines": {
"k2b": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2c": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2cpp": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2go": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2js": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2kir": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
}
},
"renderer_matrix": {
"desktop_libdraw_c": {
"evidence": "make libdraw-matrix-check",
"scope": "Per-source generated-C libdraw capture; cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"desktop_raylib": {
"evidence": "make raylib-matrix-check",
"scope": "Per-source generated-C raylib capture; cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"krb_native_sw": {
"evidence": "RGB exact; SDL readback alpha differs from headless kry_sw",
"scope": "Per-source native kry_sw output compared with SDL readback.",
"status": "RGB exact",
"status_class": "part"
},
"krb_web_canvas": {
"evidence": "make krb-web-matrix-check",
"scope": "Per-source wasm Canvas2D capture byte-compared against native kry_sw.",
"status": "byte exact",
"status_class": "ok"
},
"web_canvas_wasm": {
"evidence": "make web-canvas-matrix-check",
"scope": "Per-source generated-C wasm Canvas2D capture in Node; browser screenshot and cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"web_raylib_wasm": {
"evidence": "docs-site Web IDE build",
"scope": "Wasm/WebGL build coverage; per-source browser screenshot capture pending.",
"status": "build gated",
"status_class": "part"
}
},
"semantic_evidence": "tests/generated_runtime_parity_test.sh",
"semantic_parity": true,
"type": "parity fixture",
"visuals": {
"krb_alpha": {
"evidence": "RGB exact; SDL readback alpha differs from headless kry_sw",
"status": "alpha differs",
"status_class": "part"
},
"krb_rgb": {
"evidence": "conformance-matrix-check",
"status": "RGB exact",
"status_class": "ok"
},
"libdraw_c": {
"evidence": "make libdraw-matrix-check",
"status": "captured",
"status_class": "ok"
}
},
"widgets": [
"Button",
"Checkbox",
"Collapsible",
"Column",
"Row",
"Screen",
"Text",
"TextField"
]
},
{
"id": "tests-parity-composition",
"label": "Native Composition Parity",
"path": "tests/parity/composition.kry",
"pipelines": {
"k2b": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2c": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2cpp": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2go": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2js": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
},
"k2kir": {
"evidence": "conformance-matrix-check",
"status": "gated",
"status_class": "ok"
}
},
"renderer_matrix": {
"desktop_libdraw_c": {
"evidence": "make libdraw-matrix-check",
"scope": "Per-source generated-C libdraw capture; cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"desktop_raylib": {
"evidence": "make raylib-matrix-check",
"scope": "Per-source generated-C raylib capture; cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"krb_native_sw": {
"evidence": "RGB exact; SDL readback alpha differs from headless kry_sw",
"scope": "Per-source native kry_sw output compared with SDL readback.",
"status": "RGB exact",
"status_class": "part"
},
"krb_web_canvas": {
"evidence": "make krb-web-matrix-check",
"scope": "Per-source wasm Canvas2D capture byte-compared against native kry_sw.",
"status": "byte exact",
"status_class": "ok"
},
"web_canvas_wasm": {
"evidence": "make web-canvas-matrix-check",
"scope": "Per-source generated-C wasm Canvas2D capture in Node; browser screenshot and cross-renderer pixel diff pending.",
"status": "captured",
"status_class": "ok"
},
"web_raylib_wasm": {
"evidence": "docs-site Web IDE build",
"scope": "Wasm/WebGL build coverage; per-source browser screenshot capture pending.",
"status": "build gated",
"status_class": "part"
}
},
"semantic_evidence": "tests/generated_runtime_parity_test.sh",
"semantic_parity": true,
"type": "parity fixture",
"visuals": {
"krb_alpha": {
"evidence": "RGB exact; SDL readback alpha differs from headless kry_sw",
"status": "alpha differs",
"status_class": "part"
},
"krb_rgb": {
"evidence": "conformance-matrix-check",
"status": "RGB exact",
"status_class": "ok"
},
"libdraw_c": {
"evidence": "make libdraw-matrix-check",
"status": "captured",
"status_class": "ok"
}
},
"widgets": [
"Screen",
"TextArea",
"TextField"
]
},
{
"id": "tests-parity-drag_drop",
"label": "drag drop",
@@ -3363,7 +3568,6 @@
"Column",
"Row",
"Screen",
"Text",
"TextArea",
"TextField"
]
@@ -3665,7 +3869,8 @@
"widgets": [
"MenuBar",
"Progress",
"Screen"
"Screen",
"Text"
]
},
{
@@ -3763,7 +3968,8 @@
}
},
"widgets": [
"Screen"
"Screen",
"Text"
]
},
{
@@ -4065,7 +4271,9 @@
}
},
"widgets": [
"Screen"
"Button",
"Screen",
"TabItem"
]
},
{
@@ -4404,7 +4612,6 @@
"Text",
"TextArea",
"TextField",
"TextInRect",
"TextLines",
"TitleBar",
"Toast",
@@ -4658,22 +4865,22 @@
"summary": {
"examples": 26,
"krb_alpha_byte_exact_cases": 21,
"krb_rgb_visual_cases": 43,
"libdraw_c_visual_cases": 30,
"krb_rgb_visual_cases": 45,
"libdraw_c_visual_cases": 32,
"libdraw_c_visual_gaps": 13,
"parity_fixtures": 17,
"pipeline_cells": 258,
"raylib_c_visual_cases": 28,
"parity_fixtures": 19,
"pipeline_cells": 270,
"raylib_c_visual_cases": 30,
"raylib_c_visual_gaps": 15,
"renderer_source_cells": 258,
"renderer_source_ok_cells": 148,
"renderer_source_partial_cells": 110,
"semantic_parity_cases": 16,
"source_cases": 43,
"renderer_source_cells": 270,
"renderer_source_ok_cells": 156,
"renderer_source_partial_cells": 114,
"semantic_parity_cases": 18,
"source_cases": 45,
"visual_comparison_exact_rows": 2,
"visual_comparison_pending_rows": 4,
"visual_comparison_rows": 6,
"web_canvas_c_visual_cases": 26,
"web_canvas_c_visual_cases": 28,
"web_canvas_c_visual_gaps": 17,
"widgets_declared": 54,
"widgets_detected": 54,
@@ -4681,23 +4888,23 @@
},
"visual_comparisons": [
{
"compared": 43,
"compared": 45,
"evidence": [
"make conformance-matrix-check",
"tests/krb_exact_test.sh"
],
"gap_cases": 22,
"gap_cases": 24,
"gap_label": "alpha-only gaps",
"id": "krb-native-vs-sdl",
"label": "KRB native software vs SDL host",
"mode": "RGB pixel comparison",
"scope": "Every listed .kry source is rendered through kry_sw headless and the SDL host; RGB pixels must match. Alpha-only gaps are listed separately.",
"source_cases": 43,
"source_cases": 45,
"status": "RGB exact",
"status_class": "ok"
},
{
"compared": 43,
"compared": 45,
"evidence": [
"make krb-web-matrix-check",
"cmd/krb-web/node-capture.js"
@@ -4708,12 +4915,12 @@
"label": "KRB native software vs KRB web Canvas",
"mode": "RGBA byte comparison",
"scope": "Every listed .kry source is rendered by native kry_sw and the wasm Canvas2D KRB host; RGBA bytes must match.",
"source_cases": 43,
"source_cases": 45,
"status": "byte exact",
"status_class": "ok"
},
{
"compared": 28,
"compared": 30,
"evidence": [
"make raylib-matrix-check"
],
@@ -4723,12 +4930,12 @@
"label": "Generated C raylib vs KRB native software",
"mode": "capture only",
"scope": "Generated C raylib captures are gated for nonblank output on sources without known generated-C gaps; pixel comparison against KRB is not yet enforced.",
"source_cases": 43,
"source_cases": 45,
"status": "pixel diff pending",
"status_class": "part"
},
{
"compared": 30,
"compared": 32,
"evidence": [
"make libdraw-matrix-check"
],
@@ -4738,12 +4945,12 @@
"label": "Generated C libdraw vs KRB native software",
"mode": "capture only",
"scope": "Generated C libdraw captures are gated for nonblank output on sources without known generated-C gaps; pixel comparison against KRB is not yet enforced.",
"source_cases": 43,
"source_cases": 45,
"status": "pixel diff pending",
"status_class": "part"
},
{
"compared": 26,
"compared": 28,
"evidence": [
"make web-canvas-matrix-check"
],
@@ -4753,7 +4960,7 @@
"label": "Generated C web Canvas vs KRB native software",
"mode": "capture only",
"scope": "Generated C wasm Canvas2D captures are gated for nonblank output in Node on sources without known generated-C gaps; browser screenshot and pixel comparison against KRB are not yet enforced.",
"source_cases": 43,
"source_cases": 45,
"status": "pixel diff pending",
"status_class": "part"
},
@@ -4768,7 +4975,7 @@
"label": "Web raylib wasm vs desktop raylib",
"mode": "build only",
"scope": "The web raylib path builds with the website/Web IDE, but per-source browser screenshots and pixel comparison against desktop raylib are still missing.",
"source_cases": 43,
"source_cases": 45,
"status": "browser screenshot pending",
"status_class": "part"
}
@@ -4778,13 +4985,13 @@
"Background": 21,
"Bevel": 2,
"BottomNav": 2,
"Button": 13,
"Button": 15,
"Canvas": 3,
"CanvasGrid": 3,
"Checkbox": 5,
"Collapsible": 4,
"Checkbox": 6,
"Collapsible": 5,
"ColorPicker": 3,
"Column": 6,
"Column": 7,
"Combobox": 4,
"ConfirmDialog": 3,
"Dropdown": 4,
@@ -4805,10 +5012,10 @@
"Picture": 3,
"Progress": 5,
"PromptDialog": 3,
"Radio": 3,
"Radio": 4,
"Rect": 8,
"Row": 5,
"Screen": 35,
"Row": 6,
"Screen": 37,
"Scroll": 2,
"SelectableText": 1,
"Slider": 5,
@@ -4816,11 +5023,11 @@
"Spinbox": 3,
"Stack": 3,
"TabBar": 2,
"TabItem": 1,
"TableView": 5,
"Text": 23,
"TextArea": 6,
"TextField": 8,
"TextInRect": 2,
"Text": 25,
"TextArea": 7,
"TextField": 10,
"TextLines": 2,
"TitleBar": 2,
"Toast": 2,
@@ -4898,10 +5105,12 @@
"id": "Button",
"semantic_sources": [
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/scroll_content.kry"
"tests/parity/scroll_content.kry",
"tests/parity/selection_images.kry"
],
"source_count": 13,
"source_count": 15,
"sources": [
"examples/01_file_dialog.kry",
"examples/02_buttons.kry",
@@ -4913,8 +5122,10 @@
"examples/18_accessibility.kry",
"examples/26_widget_catalog.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/scroll_content.kry",
"tests/parity/selection_images.kry",
"tests/parity/widget_catalog.kry"
],
"status": "covered",
@@ -4947,14 +5158,16 @@
{
"id": "Checkbox",
"semantic_sources": [
"tests/parity/basic_controls.kry"
"tests/parity/basic_controls.kry",
"tests/parity/composed_combo.kry"
],
"source_count": 5,
"source_count": 6,
"sources": [
"examples/03_theme.kry",
"examples/18_accessibility.kry",
"examples/26_widget_catalog.kry",
"tests/parity/basic_controls.kry",
"tests/parity/composed_combo.kry",
"tests/parity/widget_catalog.kry"
],
"status": "covered",
@@ -4963,12 +5176,14 @@
{
"id": "Collapsible",
"semantic_sources": [
"tests/parity/composed_combo.kry",
"tests/parity/scroll_content.kry"
],
"source_count": 4,
"source_count": 5,
"sources": [
"examples/15_containers.kry",
"examples/26_widget_catalog.kry",
"tests/parity/composed_combo.kry",
"tests/parity/scroll_content.kry",
"tests/parity/widget_catalog.kry"
],
@@ -4991,14 +5206,16 @@
"id": "Column",
"semantic_sources": [
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/long_text.kry",
"tests/parity/scroll_content.kry"
],
"source_count": 6,
"source_count": 7,
"sources": [
"examples/26_widget_catalog.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/long_text.kry",
"tests/parity/scroll_content.kry",
@@ -5254,11 +5471,14 @@
},
{
"id": "Radio",
"semantic_sources": [],
"source_count": 3,
"semantic_sources": [
"tests/parity/basic_controls.kry"
],
"source_count": 4,
"sources": [
"examples/11_basic_controls.kry",
"examples/26_widget_catalog.kry",
"tests/parity/basic_controls.kry",
"tests/parity/widget_catalog.kry"
],
"status": "covered",
@@ -5287,13 +5507,15 @@
"id": "Row",
"semantic_sources": [
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/scroll_content.kry"
],
"source_count": 5,
"source_count": 6,
"sources": [
"examples/26_widget_catalog.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/generated_form.kry",
"tests/parity/scroll_content.kry",
"tests/parity/widget_catalog.kry"
@@ -5306,6 +5528,8 @@
"semantic_sources": [
"tests/parity/basic_controls.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/focus.kry",
"tests/parity/generated_form.kry",
@@ -5318,7 +5542,7 @@
"tests/parity/table_view.kry",
"tests/parity/tree_view.kry"
],
"source_count": 35,
"source_count": 37,
"sources": [
"examples/01_file_dialog.kry",
"examples/02_buttons.kry",
@@ -5343,6 +5567,8 @@
"examples/26_widget_catalog.kry",
"tests/parity/basic_controls.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/composed_combo.kry",
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/focus.kry",
"tests/parity/generated_form.kry",
@@ -5442,6 +5668,18 @@
"status": "covered",
"status_class": "ok"
},
{
"id": "TabItem",
"semantic_sources": [
"tests/parity/selection_images.kry"
],
"source_count": 1,
"sources": [
"tests/parity/selection_images.kry"
],
"status": "covered",
"status_class": "ok"
},
{
"id": "TableView",
"semantic_sources": [
@@ -5463,10 +5701,12 @@
"id": "Text",
"semantic_sources": [
"tests/parity/buttons_layout.kry",
"tests/parity/generated_form.kry",
"tests/parity/long_text.kry"
"tests/parity/composed_combo.kry",
"tests/parity/long_text.kry",
"tests/parity/menus.kry",
"tests/parity/plots.kry"
],
"source_count": 23,
"source_count": 25,
"sources": [
"examples/01_file_dialog.kry",
"examples/02_buttons.kry",
@@ -5488,8 +5728,10 @@
"examples/25_text_area_slider.kry",
"examples/26_widget_catalog.kry",
"tests/parity/buttons_layout.kry",
"tests/parity/generated_form.kry",
"tests/parity/composed_combo.kry",
"tests/parity/long_text.kry",
"tests/parity/menus.kry",
"tests/parity/plots.kry",
"tests/parity/widget_catalog.kry"
],
"status": "covered",
@@ -5498,14 +5740,16 @@
{
"id": "TextArea",
"semantic_sources": [
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/generated_form.kry"
],
"source_count": 6,
"source_count": 7,
"sources": [
"examples/13_text_editor.kry",
"examples/25_text_area_slider.kry",
"examples/26_widget_catalog.kry",
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/generated_form.kry",
"tests/parity/widget_catalog.kry"
@@ -5516,16 +5760,20 @@
{
"id": "TextField",
"semantic_sources": [
"tests/parity/composed_combo.kry",
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/focus.kry",
"tests/parity/generated_form.kry",
"tests/parity/long_text.kry",
"tests/parity/scroll_content.kry"
],
"source_count": 8,
"source_count": 10,
"sources": [
"examples/03_theme.kry",
"examples/26_widget_catalog.kry",
"tests/parity/composed_combo.kry",
"tests/parity/composition.kry",
"tests/parity/fields.kry",
"tests/parity/focus.kry",
"tests/parity/generated_form.kry",
@@ -5536,17 +5784,6 @@
"status": "covered",
"status_class": "ok"
},
{
"id": "TextInRect",
"semantic_sources": [],
"source_count": 2,
"sources": [
"examples/26_widget_catalog.kry",
"tests/parity/widget_catalog.kry"
],
"status": "covered",
"status_class": "ok"
},
{
"id": "TextLines",
"semantic_sources": [],
+3 -3
View File
@@ -67,10 +67,10 @@ App :: () #ui {
Screen root: {
Background((Color){249, 246, 235, 255})
Rect(48, 42, 704, 390, (Color){255, 254, 249, 255})
Text("Hello from .kry", 76, 86, Text24, (Color){31, 83, 102, 255})
Text("This page runs k2kir and k2b as WebAssembly, then renders the KRB cartridge.", 76, 134, Text16, (Color){42, 59, 64, 255})
Text((TextProps){.bounds={76,86,0,0}, .text="Hello from .kry", .font=Text24, .color=(Color){31,83,102,255}, .wrap=TextWrapNone})
Text((TextProps){.bounds={76,134,0,0}, .text="This page runs k2kir and k2b as WebAssembly, then renders the KRB cartridge.", .font=Text16, .color=(Color){42,59,64,255}, .wrap=TextWrapNone})
Rect(76, 188, 292, 80, (Color){35, 101, 125, 255})
Text("Portable preview", 104, 219, Text20, WHITE)
Text((TextProps){.bounds={104,219,0,0}, .text="Portable preview", .font=Text20, .color=WHITE, .wrap=TextWrapNone})
Button((ButtonProps){.bounds = {76, 308, 184, 44}, .label = "Get started"})
}
}</textarea>
+1 -1
View File
@@ -84,7 +84,7 @@ Counter :: (viewport: Rectangle, app: App*) #ui {
Column body: {
gap = 8
Text("Count", 0, 0, Text16, GetThemeText())
Text((TextProps){.text="Count", .font=Text16})
if Button((ButtonProps){.label = "Increment"}) {
app->click_count += 1
}
+1 -1
View File
@@ -174,7 +174,7 @@
<table class="matrix-table">
<thead><tr><th>Widget</th><th>C</th><th>k2c</th><th>k2go</th><th>Go</th><th>KRB</th></tr></thead>
<tbody>
<tr><td>Background, Text, TextInRect</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Nodes</td></tr>
<tr><td>Background, Text</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Nodes</td></tr>
<tr><td>Paragraph, TextLines</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="no">Not lowered</td></tr>
<tr><td>Rect, Line, Bevel</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Yes</td><td class="ok">Nodes</td></tr>
<tr><td>Icon</td><td class="ok">1 style + 5 tint sheets + 5 full-color sheets</td><td class="ok">Yes</td><td class="ok">By icon type</td><td class="ok">Yes</td><td class="ok">Lowered</td></tr>
+1 -1
View File
@@ -136,7 +136,7 @@
name: "Daochi",
summary: "Mesh-native sync network for app-owned data, signed identity, encrypted records, and remote events.",
author: {name: "kryonlabs", url: "https://kryonlabs.com"},
repository: "https://github.com/kryonlabs/ksync",
repository: "https://github.com/kryonlabs/daochi",
homepage: "https://daochi.net",
banner: "project-shots/daochi.png",
bannerAlt: "Daochi website screenshot",
+8 -8
View File
@@ -23,17 +23,17 @@ FileDialogExample :: (viewport: Rectangle) #ui {
InitFileDialog(&dlg)
dlg_ready = 1
}
Text("Kryon File Dialog", ScaleUIPx(32), ScaleUIPx(28), Text24, GetThemeText())
Text("Dialog backend and result state", ScaleUIPx(32), ScaleUIPx(66), Text16, GetThemeIcon())
if Button((ButtonProps){.bounds = {ScaleUIPx(32), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42)}, .label = "Open File", .style = ButtonStylePrimary, .font = Text16, .id = 101}) {
Text((TextProps){.bounds={Scale(32), Scale(28), 0, 0}, .text="Kryon File Dialog", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(32), Scale(66), 0, 0}, .text="Dialog backend and result state", .font=Text16, .color=GetThemeIcon(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {Scale(32), Scale(116), Scale(180), Scale(42)}, .label = "Open File", .style = ButtonStylePrimary, .font = Text16, .id = 101}) {
BeginLoadFileDialog(&dlg,"Open File")
snprintf(status,sizeof(status),"Open file requested.")
}
if Button((ButtonProps){.bounds = {ScaleUIPx(226), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42)}, .label = "Save File", .style = ButtonStyleSecondary, .font = Text16, .id = 102}) {
if Button((ButtonProps){.bounds = {Scale(226), Scale(116), Scale(180), Scale(42)}, .label = "Save File", .style = ButtonStyleSecondary, .font = Text16, .id = 102}) {
BeginSaveFileDialog(&dlg,"Save File","untitled.kry")
snprintf(status,sizeof(status),"Save file requested.")
}
if Button((ButtonProps){.bounds = {ScaleUIPx(420), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42)}, .label = "Select Folder", .style = ButtonStyleSecondary, .font = Text16, .id = 103}) {
if Button((ButtonProps){.bounds = {Scale(420), Scale(116), Scale(180), Scale(42)}, .label = "Select Folder", .style = ButtonStyleSecondary, .font = Text16, .id = 103}) {
BeginSelectFileDialogFolder(&dlg,"Select Folder")
snprintf(status,sizeof(status),"Folder selection requested.")
}
@@ -45,8 +45,8 @@ FileDialogExample :: (viewport: Rectangle) #ui {
if dialog_result < 0 {
snprintf(status,sizeof(status),"Dialog cancelled.")
}
Text("Status", ScaleUIPx(32), ScaleUIPx(210), 18, GetThemeText())
Text(status, ScaleUIPx(32), ScaleUIPx(242), Text16, GetThemeText())
Text(last_path, ScaleUIPx(32), ScaleUIPx(274), Text16, GetThemeIcon())
Text((TextProps){.bounds={Scale(32), Scale(210), 0, 0}, .text="Status", .font=18, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(32), Scale(242), 0, 0}, .text=status, .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(32), Scale(274), 0, 0}, .text=last_path, .font=Text16, .color=GetThemeIcon(), .wrap=TextWrapNone})
}
}
+9 -9
View File
@@ -15,10 +15,10 @@ ButtonsExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text("UI Buttons Example", ScaleUIPx(20), ScaleUIPx(20), Text24, GetThemeText())
Text("Click the buttons below to test interactions", ScaleUIPx(20), ScaleUIPx(54), Text16, GetThemeText())
Text((TextProps){.bounds={Scale(20), Scale(20), 0, 0}, .text="UI Buttons Example", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(20), Scale(54), 0, 0}, .text="Click the buttons below to test interactions", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if Button((ButtonProps){
.bounds = {ScaleUIPx(20), ScaleUIPx(100), ScaleUIPx(200), ScaleUIPx(40)},
.bounds = {Scale(20), Scale(100), Scale(200), Scale(40)},
.label = "Primary Button",
.style = ButtonStylePrimary,
.id = 101,
@@ -27,7 +27,7 @@ ButtonsExample :: (viewport: Rectangle) #ui {
snprintf(last_action,sizeof(last_action),"Primary Button clicked.")
}
if Button((ButtonProps){
.bounds = {ScaleUIPx(20), ScaleUIPx(150), ScaleUIPx(200), ScaleUIPx(40)},
.bounds = {Scale(20), Scale(150), Scale(200), Scale(40)},
.label = "Secondary Button",
.style = ButtonStyleSecondary,
.id = 102,
@@ -36,7 +36,7 @@ ButtonsExample :: (viewport: Rectangle) #ui {
snprintf(last_action,sizeof(last_action),"Secondary Button clicked.")
}
if Button((ButtonProps){
.bounds = {ScaleUIPx(20), ScaleUIPx(200), ScaleUIPx(200), ScaleUIPx(40)},
.bounds = {Scale(20), Scale(200), Scale(200), Scale(40)},
.label = "Danger Button",
.style = ButtonStyleDanger,
.id = 103,
@@ -44,9 +44,9 @@ ButtonsExample :: (viewport: Rectangle) #ui {
click_count++
snprintf(last_action,sizeof(last_action),"Danger Button clicked.")
}
Text(TextFormat("Clicks:%d",click_count), ScaleUIPx(20), ScaleUIPx(260), Text16, GetThemeText())
Text(last_action, ScaleUIPx(20), ScaleUIPx(290), Text16, GetThemeText())
Text("Button Styles", ScaleUIPx(300), ScaleUIPx(100), 18, GetThemeText())
Text("Primary,secondary,and danger styles use the active theme.", ScaleUIPx(300), ScaleUIPx(130), 14, GetThemeIcon())
Text((TextProps){.bounds={Scale(20), Scale(260), 0, 0}, .text=TextFormat("Clicks:%d",click_count), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(20), Scale(290), 0, 0}, .text=last_action, .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(300), Scale(100), 0, 0}, .text="Button Styles", .font=18, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(300), Scale(130), 0, 0}, .text="Primary,secondary,and danger styles use the active theme.", .font=14, .color=GetThemeIcon(), .wrap=TextWrapNone})
}
}
+33 -30
View File
@@ -53,7 +53,7 @@ ApplyThemeState :: () {
}
TokenValue :: (label: const char *, value: int, x: int, y: int) {
Text(TextFormat("%s %d", label, value), x, y, Text12, GetThemeIcon())
Text((TextProps){.bounds={x, y, 0, 0}, .text=TextFormat("%s %d", label, value), .font=Text12, .color=GetThemeIcon(), .wrap=TextWrapNone})
}
ControlDemo :: (x: int, y: int, w: int) {
@@ -65,36 +65,36 @@ ControlDemo :: (x: int, y: int, w: int) {
GetThemeText(),
GetThemeText(),
0.08f,
ScaleUIPx(12),
ScaleUIPx(8)
Scale(12),
Scale(8)
}
Text("Live controls", x, y, Text24, GetThemeText())
y += ScaleUIPx(46)
Text((TextProps){.bounds={x, y, 0, 0}, .text="Live controls", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
y += Scale(46)
Button((ButtonProps){
.bounds = {x, y, ScaleUIPx(190), ScaleUIPx(44)},
.bounds = {x, y, Scale(190), Scale(44)},
.label = "Primary",
.style = ButtonStylePrimary,
.id = 301,
})
Button((ButtonProps){
.bounds = {x + ScaleUIPx(210), y, ScaleUIPx(190), ScaleUIPx(44)},
.bounds = {x + Scale(210), y, Scale(190), Scale(44)},
.label = "Secondary",
.style = ButtonStyleSecondary,
.id = 302,
})
y += ScaleUIPx(70)
y += Scale(70)
TextField((TextFieldProps){{x, y, w, ScaleUIPx(44)}, text_value, sizeof(text_value),
TextField((TextFieldProps){{x, y, w, Scale(44)}, text_value, sizeof(text_value),
&text_cursor, &text_focused, 80, Text16, 303,
field_style, NULL, NULL, NULL})
y += ScaleUIPx(70)
Dropdown(304, x, y, w, ScaleUIPx(44), options, 3, &combo_index)
y += ScaleUIPx(72)
y += Scale(70)
Dropdown(304, x, y, w, Scale(44), options, 3, &combo_index)
y += Scale(72)
Slider(305, x, y, w, "Slider", 0, 100, &slider_value, "", nil)
y += ScaleUIPx(72)
Toggle(306, x, y, ScaleUIPx(180), ScaleUIPx(48), &toggle_value, "Off", "On")
Checkbox(307, x + ScaleUIPx(230), y + ScaleUIPx(12), "Checkbox", &check_value)
y += Scale(72)
Toggle(306, x, y, Scale(180), Scale(48), &toggle_value, "Off", "On")
Checkbox(307, x + Scale(230), y + Scale(12), "Checkbox", &check_value)
}
ThemeExample :: (viewport: Rectangle) #ui {
@@ -103,13 +103,13 @@ ThemeExample :: (viewport: Rectangle) #ui {
ApplyThemeState()
Background(GetThemeBackground())
margin: int = ScaleUIPx(26)
panel_w: int = ScaleUIPx(310)
right_x: int = margin + panel_w + ScaleUIPx(42)
margin: int = Scale(26)
panel_w: int = Scale(310)
right_x: int = margin + panel_w + Scale(42)
settings := (ThemeSettingsProps){
.id_base = 101,
.x = margin,
.y = ScaleUIPx(64),
.y = Scale(64),
.w = panel_w,
.theme_source = &theme_source,
.theme_mode = &theme_mode,
@@ -123,25 +123,28 @@ ThemeExample :: (viewport: Rectangle) #ui {
.style_system_label = "System style"
}
Text("Kryon Native Theme State", margin, ScaleUIPx(24), Text24, GetThemeText())
Text("Switch style and palette here; every control on the right uses Kryon live.", right_x, ScaleUIPx(30), Text16, GetThemeIcon())
Text((TextProps){.bounds={margin, Scale(24), 0, 0}, .text="Kryon Native Theme State", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={right_x, Scale(30), 0, 0}, .text="Switch style and palette here; every control on the right uses Kryon live.", .font=Text16, .color=GetThemeIcon(), .wrap=TextWrapNone})
result: UIThemeSettingsResult = {0}
ThemeSettings(settings, &menu_state, &result)
ControlDemo(right_x, ScaleUIPx(88), ScaleUIPx(420))
ControlDemo(right_x, Scale(88), Scale(420))
tokens := GetUIStyleTokens()
token_y: int = ScaleUIPx(520)
Text("Active style tokens", right_x, token_y, Text16, GetThemeText())
token_y += ScaleUIPx(30)
token_y: int = Scale(520)
Text((TextProps){.bounds={right_x, token_y, 0, 0}, .text="Active style tokens", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
token_y += Scale(30)
TokenValue("control alpha", tokens.control_alpha, right_x, token_y)
TokenValue("panel alpha", tokens.panel_alpha, right_x + ScaleUIPx(150), token_y)
token_y += ScaleUIPx(24)
TokenValue("panel alpha", tokens.panel_alpha, right_x + Scale(150), token_y)
token_y += Scale(28)
TokenValue("title bar alpha", tokens.title_bar_alpha,
right_x + Scale(150), token_y)
token_y += Scale(24)
TokenValue("border alpha", tokens.border_alpha, right_x, token_y)
TokenValue("shadow alpha", tokens.shadow_alpha, right_x + ScaleUIPx(150), token_y)
token_y += ScaleUIPx(24)
TokenValue("shadow alpha", tokens.shadow_alpha, right_x + Scale(150), token_y)
token_y += Scale(24)
TokenValue("touch target", tokens.touch_target_min, right_x, token_y)
TokenValue("shadow y", tokens.shadow_offset_y, right_x + ScaleUIPx(150), token_y)
TokenValue("shadow y", tokens.shadow_offset_y, right_x + Scale(150), token_y)
if result.changed {
ApplyThemeState()
+4 -4
View File
@@ -16,13 +16,13 @@ ModalExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text("Modal capture example", 32, 32, Text24, GetThemeText())
Text("Open the modal and background clicks are blocked.", 32, 72, Text16, GetThemeIcon())
Text((TextProps){.bounds={32, 32, 0, 0}, .text="Modal capture example", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={32, 72, 0, 0}, .text="Open the modal and background clicks are blocked.", .font=Text16, .color=GetThemeIcon(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {32, 120, 220, 42}, .label = "Background Button", .style = ButtonStyleSecondary, .font = Text16, .id = 101}) {
background_clicks++
}
Text(TextFormat("Background clicks:%d",background_clicks), 32, 176, Text16, GetThemeText())
Text(TextFormat("Last modal result:%s",last_label), 32, 204, Text16, GetThemeText())
Text((TextProps){.bounds={32, 176, 0, 0}, .text=TextFormat("Background clicks:%d",background_clicks), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={32, 204, 0, 0}, .text=TextFormat("Last modal result:%s",last_label), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {32, 240, 220, 42}, .label = "Open Modal", .style = ButtonStylePrimary, .font = Text16, .id = 102}) {
modal_open = 1
}
+6 -6
View File
@@ -18,18 +18,18 @@ ColorExample :: (viewport: Rectangle) #ui {
base: Color = colors[color_index]
light: Color = LightenUIColor(base,40)
dark: Color = DarkenUIColor(base,40)
Text("Color Utilities", 50, 20, Text24, GetThemeText())
Text((TextProps){.bounds={50, 20, 0, 0}, .text="Color Utilities", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(50, 70, 70, 70, base, BLANK)
Rect(50, 70, 70, 70, BLANK, GetThemeText())
Text("Original", 50+70+ScaleUIPx(10), 70+ScaleUIPx(10), Text16, GetThemeText())
Text((TextProps){.bounds={50+70+Scale(10), 70+Scale(10), 0, 0}, .text="Original", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(50, 160, 70, 70, light, BLANK)
Rect(50, 160, 70, 70, BLANK, GetThemeText())
Text("Lightened", 50+70+ScaleUIPx(10), 160+ScaleUIPx(10), Text16, GetThemeText())
Text((TextProps){.bounds={50+70+Scale(10), 160+Scale(10), 0, 0}, .text="Lightened", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(50, 250, 70, 70, dark, BLANK)
Rect(50, 250, 70, 70, BLANK, GetThemeText())
Text("Darkened", 50+70+ScaleUIPx(10), 250+ScaleUIPx(10), Text16, GetThemeText())
Text(TextFormat("Color %d/5 - SPACE cycles",color_index+1), 320, 82, 18, GetThemeText())
Text(TextFormat("RGB:%d,%d,%d",base.r,base.g,base.b), 320, 116, Text16, GetThemeText())
Text((TextProps){.bounds={50+70+Scale(10), 250+Scale(10), 0, 0}, .text="Darkened", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={320, 82, 0, 0}, .text=TextFormat("Color %d/5 - SPACE cycles",color_index+1), .font=18, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={320, 116, 0, 0}, .text=TextFormat("RGB:%d,%d,%d",base.r,base.g,base.b), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if (IsKeyPressed(KEY_SPACE)) {
color_index = (color_index + 1) % 5
}
+5 -5
View File
@@ -18,12 +18,12 @@ ScalingExample :: (viewport: Rectangle) #ui {
bounds = viewport
SetUIScale(scales[scale_index])
Background(GetThemeBackground())
box_size: int = ScaleUIPx(100)
Text(TextFormat("DPI Scale:%.1f",scales[scale_index]), 50, 20, 20, GetThemeText())
box_size: int = Scale(100)
Text((TextProps){.bounds={50, 20, 0, 0}, .text=TextFormat("DPI Scale:%.1f",scales[scale_index]), .font=20, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(box_x, box_y, box_size, box_size, GetThemeButton(), GetThemeIcon())
Text("Scaled Box", box_x + 10, box_y + 10, Text16, GetThemeText())
Text(TextFormat("Base:100px Scaled:%dpx",box_size), 50, 60, Text16, GetThemeText())
Text("SPACE cycles DPI,arrows move box", 50, 90, Text16, GetThemeIcon())
Text((TextProps){.bounds={box_x + 10, box_y + 10, 0, 0}, .text="Scaled Box", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={50, 60, 0, 0}, .text=TextFormat("Base:100px Scaled:%dpx",box_size), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={50, 90, 0, 0}, .text="SPACE cycles DPI,arrows move box", .font=Text16, .color=GetThemeIcon(), .wrap=TextWrapNone})
if (IsKeyDown(KEY_RIGHT)) {
box_x += 3
}
+20 -20
View File
@@ -12,7 +12,7 @@ state {
LayoutInfo :: (label: const char *, value: int, x: int, y: int) {
info: const char * = TextFormat("%s:%d",label,value)
Text(info, x, y, Text16, GetThemeText())
Text((TextProps){.bounds={x, y, 0, 0}, .text=info, .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
}
WidthButton :: (label: const char *, x: int, y: int, value: int) -> int {
@@ -20,11 +20,11 @@ WidthButton :: (label: const char *, x: int, y: int, value: int) -> int {
if max_width == value {
style = ButtonStylePrimary
}
return Button((ButtonProps){.bounds = {x,y,ScaleUIPx(110),ScaleUIPx(34)}, .label = label, .style = style, .font = Text16, .id = 1000 + x + y})
return Button((ButtonProps){.bounds = {x,y,Scale(110),Scale(34)}, .label = label, .style = style, .font = Text16, .id = 1000 + x + y})
}
LayoutNote :: (label: const char *, x: int, y: int, color: Color) {
Text(label, x, y, Text16, color)
Text((TextProps){.bounds={x, y, 0, 0}, .text=label, .font=Text16, .color=color, .wrap=TextWrapNone})
}
LayoutExample :: (viewport: Rectangle) #ui {
@@ -36,26 +36,26 @@ LayoutExample :: (viewport: Rectangle) #ui {
page_w: int = GetUIViewWidth() - side_padding * 2
column_x: int = 0
column_w: int = 0
y: int = ScaleUIPx(42)
guide_h: int = ScaleUIPx(450)
column_y: int = y + ScaleUIPx(30)
btn_y: int = y + ScaleUIPx(170)
y: int = Scale(42)
guide_h: int = Scale(450)
column_y: int = y + Scale(30)
btn_y: int = y + Scale(170)
right_edge: int = GetUIViewWidth() - side_padding
btn0_x: int = column_x + ScaleUIPx(16)
btn1_x: int = column_x + ScaleUIPx(138)
btn2_x: int = column_x + ScaleUIPx(260)
btn0_x: int = column_x + Scale(16)
btn1_x: int = column_x + Scale(138)
btn2_x: int = column_x + Scale(260)
GetUICenteredColumn(max_width,side_padding,&column_x,&column_w)
btn0_x = column_x + ScaleUIPx(16)
btn1_x = column_x + ScaleUIPx(138)
btn2_x = column_x + ScaleUIPx(260)
Text("Responsive layout", page_x, ScaleUIPx(16), Text24, GetThemeText())
btn0_x = column_x + Scale(16)
btn1_x = column_x + Scale(138)
btn2_x = column_x + Scale(260)
Text((TextProps){.bounds={page_x, Scale(16), 0, 0}, .text="Responsive layout", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(page_x, y, page_w, guide_h, GetThemeSurface(), GetThemeIcon())
Line(side_padding, y, side_padding, y+guide_h, GetThemeLink())
Line(right_edge, y, right_edge, y+guide_h, GetThemeLink())
Rect(column_x, column_y, column_w, ScaleUIPx(360), GetThemeBackground(), GetThemeButton())
LayoutInfo("View width", GetUIViewWidth(), column_x+16, y+ScaleUIPx(54))
LayoutInfo("Side padding", side_padding, column_x+16, y+ScaleUIPx(84))
LayoutInfo("Column max", max_width, column_x+16, y+ScaleUIPx(114))
Rect(column_x, column_y, column_w, Scale(360), GetThemeBackground(), GetThemeButton())
LayoutInfo("View width", GetUIViewWidth(), column_x+16, y+Scale(54))
LayoutInfo("Side padding", side_padding, column_x+16, y+Scale(84))
LayoutInfo("Column max", max_width, column_x+16, y+Scale(114))
if WidthButton("Narrow", btn0_x, btn_y, 360) {
max_width = 360
}
@@ -65,7 +65,7 @@ LayoutExample :: (viewport: Rectangle) #ui {
if WidthButton("Wide", btn2_x, btn_y, 720) {
max_width = 720
}
LayoutNote("Resize the preview/window or choose a width.", column_x+16, y+ScaleUIPx(240), GetThemeText())
LayoutNote("The column stays centered and clamped.", column_x+16, y+ScaleUIPx(272), GetThemeIcon())
LayoutNote("Resize the preview/window or choose a width.", column_x+16, y+Scale(240), GetThemeText())
LayoutNote("The column stays centered and clamped.", column_x+16, y+Scale(272), GetThemeIcon())
}
}
+9 -9
View File
@@ -24,14 +24,14 @@ GeometryExample :: (viewport: Rectangle) #ui {
card3: Rectangle = GridCell(grid,1,1,1,2)
badge: Rectangle = Place(card1,14,42,92,28)
action: Rectangle = Place(footer,16,7,150,32)
Text("Geometry helpers", 40, 14, Text24, GetThemeText())
Text((TextProps){.bounds={40, 14, 0, 0}, .text="Geometry helpers", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
DrawRectangleRec(shell,GetThemeSurface())
DrawRectangleLinesEx(shell,1,GetThemeIcon())
DrawRectangleRec(header,GetThemeButton())
DrawRectangleRec(rail,DarkenUIColor(GetThemeSurface(),8))
Separator((Rectangle){rail.x+rail.width+6,rail.y,1,rail.height},1)
Text("Packed header", header.x+16, header.y+16, Text16, GetThemeText())
Text("Left rail", rail.x+16, rail.y+16, Text16, GetThemeText())
Text((TextProps){.bounds={header.x+16, header.y+16, 0, 0}, .text="Packed header", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={rail.x+16, rail.y+16, 0, 0}, .text="Left rail", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DrawRectangleRec(card0,DarkenUIColor(GetThemeSurface(),12))
DrawRectangleLinesEx(card0,1,GetThemeButton())
DrawRectangleRec(card1,DarkenUIColor(GetThemeSurface(),16))
@@ -40,14 +40,14 @@ GeometryExample :: (viewport: Rectangle) #ui {
DrawRectangleLinesEx(card2,1,GetThemeButton())
DrawRectangleRec(card3,DarkenUIColor(GetThemeSurface(),22))
DrawRectangleLinesEx(card3,1,GetThemeButton())
Text("GridCell 2-column span", card0.x+14, card0.y+18, Text16, GetThemeText())
Text("Place badge", card1.x+14, card1.y+18, Text16, GetThemeText())
Text((TextProps){.bounds={card0.x+14, card0.y+18, 0, 0}, .text="GridCell 2-column span", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={card1.x+14, card1.y+18, 0, 0}, .text="Place badge", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DrawRectangleRec(badge,GetThemeButtonHover())
Text("badge", badge.x+18, badge.y+7, Text12, GetThemeText())
Text("cell 1,0", card2.x+14, card2.y+18, Text16, GetThemeText())
Text("wide footer cell", card3.x+14, card3.y+18, Text16, GetThemeText())
Text((TextProps){.bounds={badge.x+18, badge.y+7, 0, 0}, .text="badge", .font=Text12, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={card2.x+14, card2.y+18, 0, 0}, .text="cell 1,0", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={card3.x+14, card3.y+18, 0, 0}, .text="wide footer cell", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Separator((Rectangle){footer.x,footer.y-7,footer.width,1},0)
DrawRectangleRec(action,GetThemeButton())
Text("placed action", action.x+14, action.y+9, Text12, GetThemeText())
Text((TextProps){.bounds={action.x+14, action.y+9, 0, 0}, .text="placed action", .font=Text12, .color=GetThemeText(), .wrap=TextWrapNone})
}
}
+1 -1
View File
@@ -22,6 +22,6 @@ MenusExample :: (viewport: Rectangle) #ui {
if result.activated_id != 0 {
snprintf(status,sizeof(status),"Command %d",result.activated_id)
}
Text(status, 40, 80, 20, GetThemeText())
Text((TextProps){.bounds={40, 80, 0, 0}, .text=status, .font=20, .color=GetThemeText(), .wrap=TextWrapNone})
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ BasicControlsExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text("Basic controls", 40, 40, Text24, GetThemeText())
Text((TextProps){.bounds={40, 40, 0, 0}, .text="Basic controls", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
picked: int = Radio((RadioButtonProps){{40,90,160,28},"Choice A",1,radio==1,0})
if picked {
radio = picked
@@ -27,7 +27,7 @@ BasicControlsExample :: (viewport: Rectangle) #ui {
if picked {
radio = picked
}
Text(TextFormat("Selected: Choice %s", radio == 1 ? "A" : "B"), 40, 166, Text16, GetThemeText())
Text((TextProps){.bounds={40, 166, 0, 0}, .text=TextFormat("Selected: Choice %s", radio == 1 ? "A" : "B"), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Spinbox((SpinboxProps){{240,90,140,34},201,0,10,1,&spin,0})
Combobox((ComboboxProps){{240,140,180,34},202,choices,3,&combo,0})
Progress((ProgressBarProps){{40,210,380,28},0,100,progress,"Progress"})
+1 -1
View File
@@ -29,6 +29,6 @@ CollectionsExample :: (viewport: Rectangle) #ui {
ListBox((ListBoxProps){{40,60,180,180},301,items,4,&list_sel,&list_scroll,30})
TreeView((TreeViewProps){{260,60,220,180},302,tree,4,&tree_sel,&tree_scroll,28})
TableView((TableViewProps){{520,60,320,180},303,cols,2,rows,2,NULL,&row_sel,NULL,NULL,NULL,NULL,NULL,&sort_col,&table_scroll,28})
Text("Collections: list,tree,and table", 40, 280, 18, GetThemeText())
Text((TextProps){.bounds={40, 280, 0, 0}, .text="Collections: list,tree,and table", .font=18, .color=GetThemeText(), .wrap=TextWrapNone})
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ TextEditorExample :: (viewport: Rectangle) #ui {
bounds = viewport
Background(GetThemeBackground())
TextArea((TextAreaProps){{40,70,520,180},text_value,sizeof(text_value),&cursor,&focused,&scroll,500,Text16,6,401,"Write here",SyntaxNone,{0},NULL,NULL})
Text("Ctrl/Cmd+C, X, and V work in the text area.", 40, 260, Text16, GetThemeText())
Text((TextProps){.bounds={40, 260, 0, 0}, .text="Ctrl/Cmd+C, X, and V work in the text area.", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {40, 300, 110, 34}, .label = "Copy", .style = ButtonStyleSecondary, .font = Text16, .id = 101}) {
SetUIClipboardTextValue(text_value)
}
+2 -2
View File
@@ -17,11 +17,11 @@ ContainersExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
TabBar((TabBarProps){{40,50,680,0},tabs,3,tab,0,0,0,NULL,1,NULL})
TabBar((TabBarProps){.bounds={40,50,680,0},.tabs=tabs,.count=3,.selected_index=tab,.focus_selected=1,.id=1501})
PanedView((PanedViewProps){{40,100,680,280},501,1,&split,120,160})
Collapsible((CollapsibleProps){{60,410,320,120},"Details",&open})
if open {
Text("Collapsible content", 80, 455, Text16, GetThemeText())
Text((TextProps){.bounds={80, 455, 0, 0}, .text="Collapsible content", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
}
}
}
+3 -3
View File
@@ -15,15 +15,15 @@ KeyboardPlatformExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text("Keyboard and clipboard", 40, 40, Text24, GetThemeText())
Text(message, 40, 90, Text16, GetThemeText())
Text((TextProps){.bounds={40, 40, 0, 0}, .text="Keyboard and clipboard", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={40, 90, 0, 0}, .text=message, .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if AcceleratorPressed((Accelerator){KEY_C,1,0,0,1}) {
SetUIClipboardTextValue("Copied from Kryon")
snprintf(message,sizeof(message),"Copied to clipboard")
copied = 1
}
if copied {
Text("Clipboard updated.", 40, 130, Text16, GetThemeLink())
Text((TextProps){.bounds={40, 130, 0, 0}, .text="Clipboard updated.", .font=Text16, .color=GetThemeLink(), .wrap=TextWrapNone})
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ AccessibilityExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text("Accessibility overlay", 40, 40, Text24, GetThemeText())
Text((TextProps){.bounds={40, 40, 0, 0}, .text="Accessibility overlay", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Checkbox(1801,40,90,"Show focus/debug overlay",&enabled)
if Button((ButtonProps){.bounds = {40, 140, 200, 40}, .label = "Focusable Button", .style = ButtonStylePrimary, .font = Text16, .id = 101}) {
enabled = !enabled
+6 -8
View File
@@ -11,23 +11,21 @@ app "Kryon Pictures" {
App :: () #ui {
Screen root: {
Background(GetThemeBackground())
Text("Pictures are image nodes", ScaleUIPx(32), ScaleUIPx(30),
Text24, GetThemeText())
Text((TextProps){.bounds={Scale(32), Scale(30), 0, 0}, .text="Pictures are image nodes", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Stack picture_card: {
bounds = {ScaleUIPx(32), ScaleUIPx(82), ScaleUIPx(260), ScaleUIPx(210)}
bounds = {Scale(32), Scale(82), Scale(260), Scale(210)}
key = Key("picture-card")
Rect(ScaleUIPx(32), ScaleUIPx(82), ScaleUIPx(260), ScaleUIPx(210),
Rect(Scale(32), Scale(82), Scale(260), Scale(210),
GetThemeSurface(), GetThemeButton())
Picture((PictureProps){.asset_path = "tiles/tile.png",
.bounds = {ScaleUIPx(52), ScaleUIPx(104), ScaleUIPx(96), ScaleUIPx(96)},
.bounds = {Scale(52), Scale(104), Scale(96), Scale(96)},
.source = {0, 0, 0, 0}, .origin = {0, 0}, .rotation = 0.0f,
.tint = WHITE, .fit = PICTURE_FIT_CONTAIN})
Picture((PictureProps){.asset_path = "pfp/lotus.png",
.bounds = {ScaleUIPx(168), ScaleUIPx(104), ScaleUIPx(96), ScaleUIPx(96)},
.bounds = {Scale(168), Scale(104), Scale(96), Scale(96)},
.source = {0, 0, 0, 0}, .origin = {0, 0}, .rotation = 0.0f,
.tint = WHITE, .fit = PICTURE_FIT_CONTAIN})
Text("Pictures keep their node bounds for editing",
ScaleUIPx(52), ScaleUIPx(226), Text12, GetThemeIcon())
Text((TextProps){.bounds={Scale(52), Scale(226), 0, 0}, .text="Pictures keep their node bounds for editing", .font=Text12, .color=GetThemeIcon(), .wrap=TextWrapNone})
}
}
}
+8 -8
View File
@@ -13,15 +13,15 @@ ScrollExample :: () #ui {
Screen root: {
ClearBackground(GetThemeBackground())
Background(GetThemeSurface())
Text("Scroll", ScaleUIPx(40), ScaleUIPx(28), Text24, GetThemeText())
area: UIScrollArea = {{ScaleUIPx(40), ScaleUIPx(76), ScaleUIPx(360), ScaleUIPx(220)}, ScaleUIPx(520), ScaleUIPx(40), ScaleUIPx(360), &scroll_off, 0, 0}
Text((TextProps){.bounds={Scale(40), Scale(28), 0, 0}, .text="Scroll", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
area: UIScrollArea = {{Scale(40), Scale(76), Scale(360), Scale(220)}, Scale(520), Scale(40), Scale(360), &scroll_off, 0, 0}
view: UIScrollView = BeginUIScrollContainer(area)
Text("First row", view.content_x, view.content_y + ScaleUIPx(12), Text16, GetThemeText())
Text("Second row", view.content_x, view.content_y + ScaleUIPx(82), Text16, GetThemeText())
Text("Third row", view.content_x, view.content_y + ScaleUIPx(152), Text16, GetThemeText())
Text("Fourth row", view.content_x, view.content_y + ScaleUIPx(222), Text16, GetThemeText())
Text("Fifth row", view.content_x, view.content_y + ScaleUIPx(292), Text16, GetThemeText())
Text("Sixth row", view.content_x, view.content_y + ScaleUIPx(362), Text16, GetThemeText())
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(12), 0, 0}, .text="First row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(82), 0, 0}, .text="Second row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(152), 0, 0}, .text="Third row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(222), 0, 0}, .text="Fourth row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(292), 0, 0}, .text="Fifth row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={view.content_x, view.content_y + Scale(362), 0, 0}, .text="Sixth row", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
EndUIScrollContainer(area, view)
}
}
+2 -2
View File
@@ -37,8 +37,8 @@ TextAreaSliderExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(bg)
Text("Text area and slider", 48, 36, Text32, (Color){24,32,44,255})
Text("A small, responsive note editor.", 48, 78, Text16, (Color){82,96,116,255})
Text((TextProps){.bounds={48, 36, 0, 0}, .text="Text area and slider", .font=Text32, .color=(Color){24,32,44,255}, .wrap=TextWrapNone})
Text((TextProps){.bounds={48, 78, 0, 0}, .text="A small, responsive note editor.", .font=Text16, .color=(Color){82,96,116,255}, .wrap=TextWrapNone})
TextArea((TextAreaProps){ta_bounds, note, sizeof(note), &note_cursor, &note_focused, &note_scroll, 4000, Text16, 6, 200, "Type something here...", SyntaxNone, ta_style, 0, 0, 0, 0, 1})
Rect((int)panel.x, (int)panel.y, (int)panel.width, (int)panel.height, (Color){248,250,252,255}, (Color){190,200,215,255})
Slider(100, (int)panel.x + 18, (int)panel.y + 13, (int)panel.width - 36, "Background hue", 0, 360, &hue, "", 0)
+194 -188
View File
@@ -131,16 +131,16 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
Screen preview: {
bounds = viewport
ClearBackground(GetThemeBackground())
TitleBar("TitleBar / BottomNav preview", ScaleUIPx(54))
if Button((ButtonProps){.bounds = {ScaleUIPx(20),ScaleUIPx(72),ScaleUIPx(180),ScaleUIPx(36)}, .label = "Back to catalog", .id = 950}) {
TitleBar("TitleBar / BottomNav preview", Scale(54))
if Button((ButtonProps){.bounds = {Scale(20),Scale(72),Scale(180),Scale(36)}, .label = "Back to catalog", .id = 950}) {
page_preview = 0
}
Text(TextFormat("Selected route: %d", page_route), ScaleUIPx(230), ScaleUIPx(80), Text20, GetThemeText())
Text((TextProps){.bounds={Scale(230), Scale(80), 0, 0}, .text=TextFormat("Selected route: %d", page_route), .font=Text20, .color=GetThemeText(), .wrap=TextWrapNone})
nav_index: int = 0
for nav_index = 0; nav_index < 3; nav_index++ {
nav_items[nav_index].active = page_route == nav_index
}
nav_result: BottomNavResult = BottomNav((BottomNavProps){.view_width = (int)viewport.width,.view_height = (int)viewport.height,.count = 3,.items = nav_items,.height = ScaleUIPx(64)})
nav_result: BottomNavResult = BottomNav((BottomNavProps){.view_width = (int)viewport.width,.view_height = (int)viewport.height,.count = 3,.items = nav_items,.height = Scale(64)})
if nav_result.clicked_index >= 0 {
page_route = nav_result.clicked_route
}
@@ -150,192 +150,198 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
ClearBackground(GetThemeBackground())
Text("Widget catalog", ScaleUIPx(20), ScaleUIPx(22), Text24, GetThemeText())
Text("Standard Kryon controls. Select a category and try them.", ScaleUIPx(246), ScaleUIPx(28), Text16, GetThemeText())
Line(ScaleUIPx(220), ScaleUIPx(76), ScaleUIPx(220), (int)viewport.height - ScaleUIPx(24), GetThemeButton())
Text((TextProps){.bounds={Scale(20), Scale(22), 0, 0}, .text="Widget catalog", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(246), Scale(28), 0, 0}, .text="Standard Kryon controls. Select a category and try them.", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Line(Scale(220), Scale(76), Scale(220), (int)viewport.height - Scale(24), GetThemeButton())
i: int = 0
for i = 0; i < 10; i++ {
if Button((ButtonProps){.bounds = {ScaleUIPx(16),ScaleUIPx(86 + i * 46),ScaleUIPx(190),ScaleUIPx(38)}, .label = category_names[i], .font = Text14, .id = 900 + i, .style = category == i ? ButtonStylePrimary : ButtonStyleSecondary}) {
if Button((ButtonProps){.bounds = {Scale(16),Scale(86 + i * 46),Scale(190),Scale(38)}, .label = category_names[i], .font = Text14, .id = 900 + i, .style = category == i ? ButtonStylePrimary : ButtonStyleSecondary}) {
category = i
scroll_off = 0
open_menu = -1
context_open = 0
}
}
Text("Wheel to scroll", ScaleUIPx(20), (int)viewport.height - ScaleUIPx(52), Text14, GetThemeIcon())
Text(TextFormat("Clicks: %d", action_count), ScaleUIPx(20), (int)viewport.height - ScaleUIPx(30), Text14, GetThemeIcon())
Text((TextProps){.bounds={Scale(20), (int)viewport.height - Scale(52), 0, 0}, .text="Wheel to scroll", .font=Text14, .color=GetThemeIcon(), .wrap=TextWrapNone})
Text((TextProps){.bounds={Scale(20), (int)viewport.height - Scale(30), 0, 0}, .text=TextFormat("Clicks: %d", action_count), .font=Text14, .color=GetThemeIcon(), .wrap=TextWrapNone})
area: UIScrollArea = {{ScaleUIPx(236), ScaleUIPx(82), (int)viewport.width - ScaleUIPx(252), (int)viewport.height - ScaleUIPx(100)}, ScaleUIPx(category_heights[category]), ScaleUIPx(252), (int)viewport.width - ScaleUIPx(292), &scroll_off, ScaleUIPx(42), 0}
area: UIScrollArea = {{Scale(236), Scale(82), (int)viewport.width - Scale(252), (int)viewport.height - Scale(100)}, Scale(category_heights[category]), Scale(252), (int)viewport.width - Scale(292), &scroll_off, Scale(42), 0}
view: UIScrollView = BeginUIScrollContainer(area)
x: int = view.content_x
right: int = x + ScaleUIPx(410)
right: int = x + Scale(410)
y: int = view.content_y
if category == 0 {
Text("DISPLAY AND MEDIA", x, y, Text20, GetThemeLink())
Text("Text", x, y + ScaleUIPx(38), Text16, GetThemeText())
TextInRect("Text in a rectangle wraps naturally.", (Rectangle){x, y + ScaleUIPx(70), ScaleUIPx(300), ScaleUIPx(52)}, Text16, GetThemeText())
lines_y: int = y + ScaleUIPx(132)
TextLines(display_lines, 2, x, &lines_y, Text14, ScaleUIPx(18), GetThemeIcon())
paragraph_y: int = y + ScaleUIPx(176)
Paragraph((ParagraphSpec){.text = "A short paragraph with an icon.", .icon_type = 1, .icon_size = ScaleUIPx(16), .width = ScaleUIPx(300), .font = Text16, .line_gap = ScaleUIPx(4), .color = GetThemeText()}, x, &paragraph_y)
Rect(right, y + ScaleUIPx(38), ScaleUIPx(120), ScaleUIPx(54), GetThemeSurface(), GetThemeButton())
Line(right, y + ScaleUIPx(110), right + ScaleUIPx(120), y + ScaleUIPx(110), GetThemeLink())
Bevel(right, y + ScaleUIPx(132), ScaleUIPx(120), ScaleUIPx(34), GetThemeSurface(), GetThemeButton())
Icon(100, right + ScaleUIPx(150), y + ScaleUIPx(46), ScaleUIPx(28), 1, GetThemeIcon())
LabelFrame((LabelFrameProps){.bounds = {right + ScaleUIPx(200), y + ScaleUIPx(36), ScaleUIPx(150), ScaleUIPx(58)}, .title = "Label frame"})
ImageBox((ImageBoxProps){.bounds = {right + ScaleUIPx(200), y + ScaleUIPx(112), ScaleUIPx(58), ScaleUIPx(58)}, .texture = demo_texture, .tint = WHITE})
Picture((PictureProps){.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right + ScaleUIPx(278), y + ScaleUIPx(112), ScaleUIPx(72), ScaleUIPx(58)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN})
Text((TextProps){.bounds={x, y, 0, 0}, .text="DISPLAY AND MEDIA", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(38), 0, 0}, .text="Text", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds=(Rectangle){x, y + Scale(70), Scale(300), Scale(52)}, .text="Text is bounded, wrapped, and clipped by default.", .font=Text16, .color=GetThemeText(), .align=TextAlignCenter, .vertical_align=TextAlignCenter})
lines_y: int = y + Scale(132)
TextLines(display_lines, 2, x, &lines_y, Text14, Scale(18), GetThemeIcon())
paragraph_y: int = y + Scale(176)
Paragraph((ParagraphSpec){.text = "A short paragraph with an icon.", .icon_type = 1, .icon_size = Scale(16), .width = Scale(300), .font = Text16, .line_gap = Scale(4), .color = GetThemeText()}, x, &paragraph_y)
Rect(right, y + Scale(38), Scale(120), Scale(54), GetThemeSurface(), GetThemeButton())
Line(right, y + Scale(110), right + Scale(120), y + Scale(110), GetThemeLink())
Bevel(right, y + Scale(132), Scale(120), Scale(34), GetThemeSurface(), GetThemeButton())
Icon(100, right + Scale(150), y + Scale(46), Scale(28), 1, GetThemeIcon())
LabelFrame((LabelFrameProps){.bounds = {right + Scale(200), y + Scale(36), Scale(150), Scale(58)}, .title = "Label frame"})
ImageBox((ImageBoxProps){.bounds = {right + Scale(200), y + Scale(112), Scale(58), Scale(58)}, .texture = demo_texture, .tint = WHITE})
Picture((PictureProps){.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right + Scale(278), y + Scale(112), Scale(72), Scale(58)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN})
TextColored("TextColored", x, y + ScaleUIPx(260), Text16, GetThemeLink())
TextDisabled("TextDisabled", x, y + ScaleUIPx(300), Text16)
TextWrapped("TextWrapped: a longer line wraps inside its standard text bounds.", (Rectangle){x,y + ScaleUIPx(340),ScaleUIPx(320),ScaleUIPx(60)}, Text16, GetThemeText())
LabelText("LabelText", "Value", (Rectangle){x,y + ScaleUIPx(418),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
BulletText("BulletText", (Rectangle){x,y + ScaleUIPx(460),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
Text((TextProps){.bounds={x, y + Scale(260), 0, 0}, .text="Custom color", .font=Text16, .color=GetThemeLink(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(300), 0, 0}, .text="Disabled text", .font=Text16, .wrap=TextWrapNone, .disabled=1})
Text((TextProps){.bounds=(Rectangle){x,y + Scale(340),Scale(320),Scale(60)}, .text="Bounded text wraps and clips inside its standard bounds.", .font=Text16, .color=GetThemeText()})
LabelText("LabelText", "Value", (Rectangle){x,y + Scale(418),Scale(300),Scale(28)}, Text16, GetThemeText())
BulletText("BulletText", (Rectangle){x,y + Scale(460),Scale(300),Scale(28)}, Text16, GetThemeText())
selectable_token: int = PushTextSelectable(1)
Text("Select and copy this text.", x, y + ScaleUIPx(510), Text16, GetThemeText())
Text((TextProps){.bounds={x, y + Scale(510), 0, 0}, .text="Select and copy this text.", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
PopTextSelectable(selectable_token)
ValueBool("ValueBool", true, (Rectangle){right,y + ScaleUIPx(260),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
ValueInt("ValueInt", 42, (Rectangle){right,y + ScaleUIPx(300),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
ValueUInt("ValueUInt", 42, (Rectangle){right,y + ScaleUIPx(340),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
ValueFloat("ValueFloat", 0.5f, "%.2f", (Rectangle){right,y + ScaleUIPx(380),ScaleUIPx(300),ScaleUIPx(28)}, Text16, GetThemeText())
ImageWithBg((ImageWithBgProps){.picture = {.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right,y + ScaleUIPx(500),ScaleUIPx(80),ScaleUIPx(80)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN}, .background = GetThemeSurface()})
if ImageButton((ImageButtonProps){.picture = {.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right + ScaleUIPx(110),y + ScaleUIPx(500),ScaleUIPx(80),ScaleUIPx(80)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN}, .background = GetThemeSurface(), .id = 210}) {
ValueBool("ValueBool", true, (Rectangle){right,y + Scale(260),Scale(300),Scale(28)}, Text16, GetThemeText())
ValueInt("ValueInt", 42, (Rectangle){right,y + Scale(300),Scale(300),Scale(28)}, Text16, GetThemeText())
ValueUInt("ValueUInt", 42, (Rectangle){right,y + Scale(340),Scale(300),Scale(28)}, Text16, GetThemeText())
ValueFloat("ValueFloat", 0.5f, "%.2f", (Rectangle){right,y + Scale(380),Scale(300),Scale(28)}, Text16, GetThemeText())
ImageWithBg((ImageWithBgProps){.picture = {.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right,y + Scale(500),Scale(80),Scale(80)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN}, .background = GetThemeSurface()})
if ImageButton((ImageButtonProps){.picture = {.asset_path = image_path, .source = {0,0,64,64}, .bounds = {right + Scale(110),y + Scale(500),Scale(80),Scale(80)}, .tint = WHITE, .fit = PICTURE_FIT_CONTAIN}, .background = GetThemeSurface(), .id = 210}) {
action_count += 1
ShowToast("ImageButton clicked")
}
Text("ImageWithBg / ImageButton", right, y + ScaleUIPx(606), Text14, GetThemeText())
SeparatorText((SeparatorTextProps){.bounds = {x,y + ScaleUIPx(570),ScaleUIPx(350),ScaleUIPx(30)}, .label = "SeparatorText"})
Bullet((Rectangle){right,y + ScaleUIPx(460),ScaleUIPx(24),ScaleUIPx(24)})
Text((TextProps){.bounds={right, y + Scale(606), 0, 0}, .text="ImageWithBg / ImageButton", .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
SeparatorText((SeparatorTextProps){.bounds = {x,y + Scale(570),Scale(350),Scale(30)}, .label = "SeparatorText"})
Bullet((Rectangle){right,y + Scale(460),Scale(24),Scale(24)})
}
if category == 1 {
Text("ACTIONS AND INPUT", x, y, Text20, GetThemeLink())
if Button((ButtonProps){.bounds = {x, y + ScaleUIPx(38), ScaleUIPx(140), ScaleUIPx(34)}, .label = "Button", .font = Text16, .id = 101}) {
Text((TextProps){.bounds={x, y, 0, 0}, .text="ACTIONS AND INPUT", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {x, y + Scale(38), Scale(140), Scale(34)}, .label = "Button", .font = Text16, .id = 101}) {
action_count += 1
}
if IconButton((IconButtonProps){.bounds = {x + ScaleUIPx(154), y + ScaleUIPx(38), ScaleUIPx(34), ScaleUIPx(34)}, .icon_type = 1, .focus_id = 102}) {
if IconButton((IconButtonProps){.bounds = {x + Scale(154), y + Scale(38), Scale(34), Scale(34)}, .icon_type = 1, .focus_id = 102}) {
action_count += 1
}
Href((HrefProps){.bounds = {x + ScaleUIPx(204), y + ScaleUIPx(40), ScaleUIPx(100), ScaleUIPx(30)}, .text = "Kryon Labs", .href = "https://kryonlabs.com", .font = Text16, .focus_id = 103, .color = GetThemeLink(), .hover_color = GetThemeLink()})
TextField((TextFieldProps){.bounds = {right, y + ScaleUIPx(38), ScaleUIPx(260), ScaleUIPx(34)}, .text = text_value, .text_size = sizeof(text_value), .cursor_position = &text_cursor, .focused = &text_focused, .max_codepoints = 63, .font = Text16, .focus_id = 104})
TextArea((TextAreaProps){.bounds = {right, y + ScaleUIPx(86), ScaleUIPx(300), ScaleUIPx(76)}, .text = area_value, .text_size = sizeof(area_value), .cursor_position = &area_cursor, .focused = &area_focused, .scroll_y = &area_scroll, .max_codepoints = 127, .font = Text16, .line_gap = ScaleUIPx(4), .focus_id = 105, .placeholder = "Notes", .syntax = SyntaxNone})
Href((HrefProps){.bounds = {x + Scale(204), y + Scale(40), Scale(100), Scale(30)}, .text = "Kryon Labs", .href = "https://kryonlabs.com", .font = Text16, .focus_id = 103, .color = GetThemeLink(), .hover_color = GetThemeLink()})
TextField((TextFieldProps){.bounds = {right, y + Scale(38), Scale(260), Scale(34)}, .text = text_value, .text_size = sizeof(text_value), .cursor_position = &text_cursor, .focused = &text_focused, .max_codepoints = 63, .font = Text16, .focus_id = 104})
TextArea((TextAreaProps){.bounds = {right, y + Scale(86), Scale(300), Scale(76)}, .text = area_value, .text_size = sizeof(area_value), .cursor_position = &area_cursor, .focused = &area_focused, .scroll_y = &area_scroll, .max_codepoints = 127, .font = Text16, .line_gap = Scale(4), .focus_id = 105, .placeholder = "Notes", .syntax = SyntaxNone})
y += ScaleUIPx(190)
Dropdown(106, x, y, ScaleUIPx(180), ScaleUIPx(32), choices, 3, &picked)
Slider(107, x, y + ScaleUIPx(46), ScaleUIPx(250), "Slider", 0, 100, &slider_value, "%", nil)
Toggle(108, x, y + ScaleUIPx(92), ScaleUIPx(130), ScaleUIPx(30), &toggle_value, "Off", "On")
Checkbox(109, x, y + ScaleUIPx(140), "Checkbox", &checkbox_value)
if Radio((RadioButtonProps){{right, y, ScaleUIPx(130), ScaleUIPx(28)}, "Radio", 129, picked == 1, 0}) {
y += Scale(190)
Dropdown(106, x, y, Scale(180), Scale(32), choices, 3, &picked)
Slider(107, x, y + Scale(46), Scale(250), "Slider", 0, 100, &slider_value, "%", nil)
Toggle(108, x, y + Scale(92), Scale(130), Scale(30), &toggle_value, "Off", "On")
Checkbox(109, x, y + Scale(140), "Checkbox", &checkbox_value)
if Radio((RadioButtonProps){{right, y, Scale(130), Scale(28)}, "Radio", 129, picked == 1, 0}) {
picked = 1
}
Spinbox((SpinboxProps){.bounds = {right, y + ScaleUIPx(44), ScaleUIPx(140), ScaleUIPx(32)}, .id = 110, .min = 0, .max = 100, .step = 1, .value = &slider_value, .value_text = nil, .wrap = 0})
Combobox((ComboboxProps){{right, y + ScaleUIPx(92), ScaleUIPx(180), ScaleUIPx(32)}, 111, choices, 3, &picked, 0})
Progress((ProgressBarProps){{right, y + ScaleUIPx(140), ScaleUIPx(220), ScaleUIPx(24)}, 0, 100, slider_value, "Progress"})
ColorPicker((Rectangle){right + ScaleUIPx(240), y, ScaleUIPx(120), ScaleUIPx(120)}, &color_value)
Spinbox((SpinboxProps){.bounds = {right, y + Scale(44), Scale(140), Scale(32)}, .id = 110, .min = 0, .max = 100, .step = 1, .value = &slider_value, .value_text = nil, .wrap = 0})
Combobox((ComboboxProps){{right, y + Scale(92), Scale(180), Scale(32)}, 111, choices, 3, &picked, 0})
Progress((ProgressBarProps){{right, y + Scale(140), Scale(220), Scale(24)}, 0, 100, slider_value, "Progress"})
ColorPicker((Rectangle){right + Scale(240), y, Scale(120), Scale(120)}, &color_value)
if SmallButton((ButtonProps){.bounds = {x,y + ScaleUIPx(204),ScaleUIPx(120),ScaleUIPx(28)}, .label = "SmallButton", .id = 200}) {
if SmallButton((ButtonProps){.bounds = {x,y + Scale(204),Scale(120),Scale(28)}, .label = "SmallButton", .id = 200}) {
action_count += 1
}
if ArrowButton((ArrowButtonProps){.bounds = {x + ScaleUIPx(140),y + ScaleUIPx(204),ScaleUIPx(32),ScaleUIPx(28)}, .id = 201, .direction = ARROW_RIGHT}) {
if ArrowButton((ArrowButtonProps){.bounds = {x + Scale(140),y + Scale(204),Scale(32),Scale(28)}, .id = 201, .direction = ARROW_RIGHT}) {
action_count += 1
}
Selectable((SelectableProps){.bounds = {x,y + ScaleUIPx(250),ScaleUIPx(300),ScaleUIPx(32)}, .id = 202, .label = "Selectable", .selected = &selected})
CheckboxFlags((CheckboxFlagsProps){.bounds = {right,y + ScaleUIPx(204),ScaleUIPx(300),ScaleUIPx(32)}, .id = 203, .label = "CheckboxFlags", .flags = &flags, .flags_value = 1})
Text("InvisibleButton (click this area)", right, y + ScaleUIPx(258), Text14, GetThemeText())
if InvisibleButton((InvisibleButtonProps){.bounds = {right,y + ScaleUIPx(250),ScaleUIPx(300),ScaleUIPx(32)}, .id = 204}) {
Selectable((SelectableProps){.bounds = {x,y + Scale(250),Scale(300),Scale(32)}, .id = 202, .label = "Selectable", .selected = &selected})
CheckboxFlags((CheckboxFlagsProps){.bounds = {right,y + Scale(204),Scale(300),Scale(32)}, .id = 203, .label = "CheckboxFlags", .flags = &flags, .flags_value = 1})
Text((TextProps){.bounds={right, y + Scale(258), 0, 0}, .text="InvisibleButton (click this area)", .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
if InvisibleButton((InvisibleButtonProps){.bounds = {right,y + Scale(250),Scale(300),Scale(32)}, .id = 204}) {
action_count += 1
ShowToast("InvisibleButton clicked")
}
BeginDisabled(1)
if Button((ButtonProps){.bounds = {x,y + ScaleUIPx(310),ScaleUIPx(180),ScaleUIPx(34)}, .label = "Disabled button", .id = 205}) {
if Button((ButtonProps){.bounds = {x,y + Scale(310),Scale(180),Scale(34)}, .label = "Disabled button", .id = 205}) {
action_count += 1
}
EndDisabled()
Tooltip((TooltipProps){.trigger = {x,y + ScaleUIPx(310),ScaleUIPx(180),ScaleUIPx(34)}, .text = "A standard tooltip", .font = Text14, .max_width = ScaleUIPx(240)})
Popup disabled_help: {
bounds = {x + Scale(188),y + Scale(304),Scale(256),Scale(48)}
id = 206
trigger = {x,y + Scale(310),Scale(180),Scale(34)}
flags = PopupTooltip
Text((TextProps){.bounds={x + Scale(196),y + Scale(316),Scale(240),Scale(22)},.text="A standard tooltip",.font=Text14,.color=GetThemeText(),.wrap=TextWrapNone})
}
}
if category == 2 {
Text("LAYOUT AND CONTAINERS", x, y, Text20, GetThemeLink())
Text((TextProps){.bounds={x, y, 0, 0}, .text="LAYOUT AND CONTAINERS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
Column demo_column: {
bounds = {x, y + ScaleUIPx(38), ScaleUIPx(190), ScaleUIPx(92)}
gap = ScaleUIPx(6)
padding = ScaleUIPx(8)
Text("Column", 0, 0, Text16, GetThemeText())
bounds = {x, y + Scale(38), Scale(190), Scale(92)}
gap = Scale(6)
padding = Scale(8)
Text((TextProps){.bounds={0, 0, 0, 0}, .text="Column", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Row demo_row: {
bounds = {0, 0, ScaleUIPx(170), ScaleUIPx(34)}
gap = ScaleUIPx(6)
if Button((ButtonProps){.bounds = {0,0,ScaleUIPx(72),ScaleUIPx(30)}, .label = "Row A", .id = 112}) {
bounds = {0, 0, Scale(170), Scale(34)}
gap = Scale(6)
if Button((ButtonProps){.bounds = {0,0,Scale(72),Scale(30)}, .label = "Row A", .id = 112}) {
action_count += 1
}
if Button((ButtonProps){.bounds = {0,0,ScaleUIPx(72),ScaleUIPx(30)}, .label = "Row B", .id = 113}) {
if Button((ButtonProps){.bounds = {0,0,Scale(72),Scale(30)}, .label = "Row B", .id = 113}) {
action_count += 1
}
}
}
Stack demo_stack: {
bounds = {x + ScaleUIPx(214), y + ScaleUIPx(38), ScaleUIPx(160), ScaleUIPx(92)}
bounds = {x + Scale(214), y + Scale(38), Scale(160), Scale(92)}
key = Key("catalog-stack")
Rect(x + ScaleUIPx(214), y + ScaleUIPx(38), ScaleUIPx(160), ScaleUIPx(92), GetThemeSurface(), GetThemeButton())
Text("Stack", x + ScaleUIPx(258), y + ScaleUIPx(70), Text16, GetThemeText())
Rect(x + Scale(214), y + Scale(38), Scale(160), Scale(92), GetThemeSurface(), GetThemeButton())
Text((TextProps){.bounds={x + Scale(258), y + Scale(70), 0, 0}, .text="Stack", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
}
GridLayout((GridLayoutProps){.bounds = {x, y + ScaleUIPx(148), ScaleUIPx(374), ScaleUIPx(48)}, .columns = 2, .gap = ScaleUIPx(6)})
if Button((ButtonProps){.bounds = {0,0,ScaleUIPx(150),ScaleUIPx(32)}, .label = "Grid A", .id = 124}) {
GridLayout((GridLayoutProps){.bounds = {x, y + Scale(148), Scale(374), Scale(48)}, .columns = 2, .gap = Scale(6)})
if Button((ButtonProps){.bounds = {0,0,Scale(150),Scale(32)}, .label = "Grid A", .id = 124}) {
action_count += 1
}
if Button((ButtonProps){.bounds = {0,0,ScaleUIPx(150),ScaleUIPx(32)}, .label = "Grid B", .id = 125}) {
if Button((ButtonProps){.bounds = {0,0,Scale(150),Scale(32)}, .label = "Grid B", .id = 125}) {
action_count += 1
}
End()
Notebook((NotebookProps){.bounds = {right, y + ScaleUIPx(38), ScaleUIPx(180), ScaleUIPx(54)}, .tabs = choices, .tab_count = 3, .selected_index = &picked})
PanedView((PanedViewProps){{right + ScaleUIPx(198), y + ScaleUIPx(38), ScaleUIPx(180), ScaleUIPx(54)}, 114, 1, &split, 60, 80})
Text("Drag the divider", right + ScaleUIPx(198), y + ScaleUIPx(8), Text14, GetThemeIcon())
Collapsible((CollapsibleProps){.bounds = {right, y + ScaleUIPx(108), ScaleUIPx(260), ScaleUIPx(54)}, .label = "Collapsible", .open = &open})
Notebook((NotebookProps){.bounds = {right, y + Scale(38), Scale(180), Scale(54)}, .tabs = choices, .tab_count = 3, .selected_index = &picked})
PanedView((PanedViewProps){{right + Scale(198), y + Scale(38), Scale(180), Scale(54)}, 114, 1, &split, 60, 80})
Text((TextProps){.bounds={right + Scale(198), y + Scale(8), 0, 0}, .text="Drag the divider", .font=Text14, .color=GetThemeIcon(), .wrap=TextWrapNone})
Collapsible((CollapsibleProps){.bounds = {right, y + Scale(108), Scale(260), Scale(54)}, .label = "Collapsible", .open = &open})
if open {
Text("This content collapses with its header.", right, y + ScaleUIPx(174), Text14, GetThemeText())
Text((TextProps){.bounds={right, y + Scale(174), 0, 0}, .text="This content collapses with its header.", .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
}
}
if category == 3 {
Text("COLLECTIONS AND EDITORS", x, y, Text20, GetThemeLink())
ListBox((ListBoxProps){.bounds = {x, y + ScaleUIPx(38), ScaleUIPx(180), ScaleUIPx(90)}, .id = 115, .items = choices, .item_count = 3, .selected_index = &picked, .scroll_offset = &list_scroll, .row_height = ScaleUIPx(26)})
TreeView((TreeViewProps){.bounds = {x + ScaleUIPx(198), y + ScaleUIPx(38), ScaleUIPx(180), ScaleUIPx(90)}, .id = 116, .items = tree_items, .item_count = 2, .selected_id = &tree_selected, .scroll_offset = &list_scroll, .row_height = ScaleUIPx(26)})
SourceView((SourceViewProps){.bounds = {right, y + ScaleUIPx(38), ScaleUIPx(360), ScaleUIPx(90)}, .text = "Text(\"Hello\")", .scroll_x = &canvas_scroll_x, .scroll_y = &canvas_scroll_y, .font_size = Text14, .line_height = ScaleUIPx(18), .show_line_numbers = 1})
TableView((TableViewProps){.bounds = {x, y + ScaleUIPx(148), ScaleUIPx(378), ScaleUIPx(100)}, .id = 117, .columns = columns, .column_count = 2, .rows = rows, .row_count = 2, .column_widths = widths, .selected_row = &table_selected_row, .selected_column = &table_selected_column, .activated_row = &table_activated_row, .activated_column = &table_activated_column, .right_clicked_row = &table_right_row, .right_clicked_column = &table_right_column})
Text((TextProps){.bounds={x, y, 0, 0}, .text="COLLECTIONS AND EDITORS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
ListBox((ListBoxProps){.bounds = {x, y + Scale(38), Scale(180), Scale(90)}, .id = 115, .items = choices, .item_count = 3, .selected_index = &picked, .scroll_offset = &list_scroll, .row_height = Scale(26)})
TreeView((TreeViewProps){.bounds = {x + Scale(198), y + Scale(38), Scale(180), Scale(90)}, .id = 116, .items = tree_items, .item_count = 2, .selected_id = &tree_selected, .scroll_offset = &list_scroll, .row_height = Scale(26)})
SourceView((SourceViewProps){.bounds = {right, y + Scale(38), Scale(360), Scale(90)}, .text = "Text(\"Hello\")", .scroll_x = &canvas_scroll_x, .scroll_y = &canvas_scroll_y, .font_size = Text14, .line_height = Scale(18), .show_line_numbers = 1})
TableView((TableViewProps){.bounds = {x, y + Scale(148), Scale(378), Scale(100)}, .id = 117, .columns = columns, .column_count = 2, .rows = rows, .row_count = 2, .column_widths = widths, .selected_row = &table_selected_row, .selected_column = &table_selected_column, .activated_row = &table_activated_row, .activated_column = &table_activated_column, .right_clicked_row = &table_right_row, .right_clicked_column = &table_right_column})
Text("MultiSelectList (Ctrl / Shift to select)", x, y + ScaleUIPx(290), Text16, GetThemeText())
MultiSelectList((MultiSelectListProps){.bounds = {x,y + ScaleUIPx(330),ScaleUIPx(350),ScaleUIPx(110)}, .id = 206, .items = choices, .item_count = 3, .selected = multi_selected, .selected_count = &multi_count, .anchor = &multi_anchor, .row_height = ScaleUIPx(30)})
Text("Drag text from the left into the right box", x, y + ScaleUIPx(480), Text16, GetThemeText())
Rect(x,y + ScaleUIPx(522),ScaleUIPx(300),ScaleUIPx(48),GetThemeSurface(),GetThemeButton())
Text("DragDropSource",x + ScaleUIPx(12),y + ScaleUIPx(538),Text16,GetThemeText())
DragDropSource((DragDropSourceProps){.bounds = {x,y + ScaleUIPx(522),ScaleUIPx(300),ScaleUIPx(48)}, .id = 207, .type = "TEXT", .data = text_value, .data_size = sizeof(text_value)})
Rect(right,y + ScaleUIPx(522),ScaleUIPx(300),ScaleUIPx(48),GetThemeSurface(),GetThemeButton())
Text("DragDropTarget",right + ScaleUIPx(12),y + ScaleUIPx(538),Text16,GetThemeText())
DragDropTarget((DragDropTargetProps){.bounds = {right,y + ScaleUIPx(522),ScaleUIPx(300),ScaleUIPx(48)}, .id = 208, .type = "TEXT", .output = area_value, .output_size = sizeof(area_value), .accepted_size = &accepted_size})
Text(area_value, right, y + ScaleUIPx(590), Text14, GetThemeText())
Text((TextProps){.bounds={x, y + Scale(290), 0, 0}, .text="MultiSelectList (Ctrl / Shift to select)", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
MultiSelectList((MultiSelectListProps){.bounds = {x,y + Scale(330),Scale(350),Scale(110)}, .id = 206, .items = choices, .item_count = 3, .selected = multi_selected, .selected_count = &multi_count, .anchor = &multi_anchor, .row_height = Scale(30)})
Text((TextProps){.bounds={x, y + Scale(480), 0, 0}, .text="Drag text from the left into the right box", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Rect(x,y + Scale(522),Scale(300),Scale(48),GetThemeSurface(),GetThemeButton())
Text((TextProps){.bounds={x + Scale(12), y + Scale(538), 0, 0}, .text="DragDropSource", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragDropSource((DragDropSourceProps){.bounds = {x,y + Scale(522),Scale(300),Scale(48)}, .id = 207, .type = "TEXT", .data = text_value, .data_size = sizeof(text_value)})
Rect(right,y + Scale(522),Scale(300),Scale(48),GetThemeSurface(),GetThemeButton())
Text((TextProps){.bounds={right + Scale(12), y + Scale(538), 0, 0}, .text="DragDropTarget", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragDropTarget((DragDropTargetProps){.bounds = {right,y + Scale(522),Scale(300),Scale(48)}, .id = 208, .type = "TEXT", .output = area_value, .output_size = sizeof(area_value), .accepted_size = &accepted_size})
Text((TextProps){.bounds={right, y + Scale(590), 0, 0}, .text=area_value, .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
}
if category == 4 {
Text("NAVIGATION", x, y, Text20, GetThemeLink())
Text("Menus, tabs and navigation", x, y + ScaleUIPx(22), Text14, GetThemeText())
TopNav((TopNavProps){.id = 118, .x = x, .y = y + ScaleUIPx(44), .width = ScaleUIPx(300), .height = ScaleUIPx(36), .title = "Top navigation", .options = choices, .option_count = 3, .selected_index = &picked})
Toolbar((ToolbarProps){.id = 119, .x = right, .y = y + ScaleUIPx(44), .width = ScaleUIPx(300), .height = ScaleUIPx(36), .draw_menu = 1, .options = choices, .option_count = 3, .selected_index = &picked})
tab_result: int = TabBar((TabBarProps){.bounds = {x, y + ScaleUIPx(100), ScaleUIPx(360), ScaleUIPx(34)}, .tabs = tabs, .count = 2, .selected_index = picked, .focus_selected = 1})
Text((TextProps){.bounds={x, y, 0, 0}, .text="NAVIGATION", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(22), 0, 0}, .text="Menus, tabs and navigation", .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
TopNav((TopNavProps){.id = 118, .x = x, .y = y + Scale(44), .width = Scale(300), .height = Scale(36), .title = "Top navigation", .options = choices, .option_count = 3, .selected_index = &picked})
Toolbar((ToolbarProps){.id = 119, .x = right, .y = y + Scale(44), .width = Scale(300), .height = Scale(36), .draw_menu = 1, .options = choices, .option_count = 3, .selected_index = &picked})
tab_result: int = TabBar((TabBarProps){.bounds = {x, y + Scale(100), Scale(360), Scale(34)}, .tabs = tabs, .count = 2, .selected_index = picked, .focus_selected = 1, .id = 2603})
if tab_result >= 0 {
picked = tab_result
}
menu_result: MenuBarResult = MenuBar(126, (Rectangle){x, y + ScaleUIPx(148), ScaleUIPx(360), ScaleUIPx(34)}, menus, 1, &open_menu)
context_result: int = ContextMenu((ContextMenuProps){127, {right, y + ScaleUIPx(132), ScaleUIPx(280), ScaleUIPx(50)}, menu_items, 2, &context_open, &context_x, &context_y})
menu_result: MenuBarResult = MenuBar(126, (Rectangle){x, y + Scale(148), Scale(360), Scale(34)}, menus, 1, &open_menu)
context_result: int = ContextMenu((ContextMenuProps){127, {right, y + Scale(132), Scale(280), Scale(50)}, menu_items, 2, &context_open, &context_x, &context_y})
if menu_result.activated_id > 0 {
menu_command = menu_result.activated_id
}
if context_result > 0 {
menu_command = context_result
}
Text("Right-click here for a context menu", right + ScaleUIPx(12), y + ScaleUIPx(148), Text14, GetThemeText())
Text("ClosableTabBar", x, y + ScaleUIPx(216), Text16, GetThemeText())
ClosableTabBar((ClosableTabBarProps){.bounds = {x,y + ScaleUIPx(252),ScaleUIPx(760),ScaleUIPx(36)}, .tabs = open_tabs, .count = tab_count, .selected_index = &tab_selected, .font = Text16, .closed_index = &closed_tab})
Text((TextProps){.bounds={right + Scale(12), y + Scale(148), 0, 0}, .text="Right-click here for a context menu", .font=Text14, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(216), 0, 0}, .text="ClosableTabBar", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
ClosableTabBar((ClosableTabBarProps){.bounds = {x,y + Scale(252),Scale(760),Scale(36)}, .tabs = open_tabs, .count = tab_count, .selected_index = &tab_selected, .font = Text16, .closed_index = &closed_tab, .id = 2604})
if closed_tab >= 0 {
if closed_tab < tab_count {
tab_index: int = closed_tab
@@ -352,7 +358,7 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
}
closed_tab = -1
}
if TabItemButton((TabItemButtonProps){.bounds = {right,y + ScaleUIPx(308),ScaleUIPx(130),ScaleUIPx(36)}, .id = 209, .label = "New tab", .font = Text16, .disabled = tab_count >= 8}) {
if TabItemButton((TabItemButtonProps){.bounds = {right,y + Scale(308),Scale(130),Scale(36)}, .id = 209, .label = "New tab", .font = Text16, .disabled = tab_count >= 8}) {
open_tabs[tab_count] = (Tab){.label = tab_labels[tab_count], .closeable = 1}
tab_selected = tab_count
tab_count += 1
@@ -361,61 +367,61 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
}
if category == 4 {
Text(TextFormat("Open tabs: %d / Menu command: %d", tab_count, menu_command), x, y + ScaleUIPx(308), Text16, GetThemeText())
Text("SubtabBar", x, y + ScaleUIPx(350), Text16, GetThemeText())
subtab_result: int = SubtabBar((SubtabBarProps){.bounds = {x,y + ScaleUIPx(384),ScaleUIPx(350),ScaleUIPx(36)},.tabs = subtabs,.count = 3,.selected_index = subtab_selected,.font = Text16})
Text((TextProps){.bounds={x, y + Scale(308), 0, 0}, .text=TextFormat("Open tabs: %d / Menu command: %d", tab_count, menu_command), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(350), 0, 0}, .text="SubtabBar", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
subtab_result: int = SubtabBar((SubtabBarProps){.bounds = {x,y + Scale(384),Scale(350),Scale(36)},.tabs = subtabs,.count = 3,.selected_index = subtab_selected,.font = Text16})
if subtab_result >= 0 {
subtab_selected = subtab_result
}
Text("PaneTabs", right, y + ScaleUIPx(350), Text16, GetThemeText())
pane_result: PaneTabBarResult = PaneTabs((PaneTabBar){.bounds = {right,y + ScaleUIPx(384),ScaleUIPx(350),ScaleUIPx(36)},.tabs = tabs,.count = 2,.selected_index = pane_selected,.font = Text16,.dragged_index = &pane_dragged})
Text((TextProps){.bounds={right, y + Scale(350), 0, 0}, .text="PaneTabs", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
pane_result: PaneTabBarResult = PaneTabs((PaneTabBar){.bounds = {right,y + Scale(384),Scale(350),Scale(36)},.tabs = tabs,.count = 2,.selected_index = pane_selected,.font = Text16,.dragged_index = &pane_dragged})
if pane_result.clicked_index >= 0 {
pane_selected = pane_result.clicked_index
}
}
if category == 5 {
Text("FEEDBACK AND DIALOGS", x, y, Text20, GetThemeLink())
if Button((ButtonProps){.bounds = {x, y + ScaleUIPx(40), ScaleUIPx(150), ScaleUIPx(34)}, .label = "Show toast", .id = 120}) {
Text((TextProps){.bounds={x, y, 0, 0}, .text="FEEDBACK AND DIALOGS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {x, y + Scale(40), Scale(150), Scale(34)}, .label = "Show toast", .id = 120}) {
ShowToast("Hello from Kryon")
}
if Button((ButtonProps){.bounds = {x + ScaleUIPx(166), y + ScaleUIPx(40), ScaleUIPx(150), ScaleUIPx(34)}, .label = "Message dialog", .id = 121}) {
if Button((ButtonProps){.bounds = {x + Scale(166), y + Scale(40), Scale(150), Scale(34)}, .label = "Message dialog", .id = 121}) {
dialog = 1
}
if Button((ButtonProps){.bounds = {right, y + ScaleUIPx(40), ScaleUIPx(150), ScaleUIPx(34)}, .label = "Confirm dialog", .id = 122}) {
if Button((ButtonProps){.bounds = {right, y + Scale(40), Scale(150), Scale(34)}, .label = "Confirm dialog", .id = 122}) {
dialog = 2
}
if Button((ButtonProps){.bounds = {right + ScaleUIPx(166), y + ScaleUIPx(40), ScaleUIPx(150), ScaleUIPx(34)}, .label = "Prompt dialog", .id = 123}) {
if Button((ButtonProps){.bounds = {right + Scale(166), y + Scale(40), Scale(150), Scale(34)}, .label = "Prompt dialog", .id = 123}) {
dialog = 3
}
if ThemeSwitcher(x, y + ScaleUIPx(94), ScaleUIPx(220), "Theme", "Light", "Dark", &theme_id, &dark_mode) {
if ThemeSwitcher(x, y + Scale(94), Scale(220), "Theme", "Light", "Dark", &theme_id, &dark_mode) {
theme_source = THEME_SOURCE_APP
theme_mode = dark_mode ? THEME_MODE_DARK : THEME_MODE_LIGHT
SetThemeSource((ThemeSource)theme_source)
SetThemeMode((ThemeMode)theme_mode)
SetCurrentTheme(theme_id, dark_mode)
}
if ThemePicker(right, y + ScaleUIPx(94), ScaleUIPx(260), dark_mode, &theme_id) {
if ThemePicker(right, y + Scale(94), Scale(260), dark_mode, &theme_id) {
theme_source = THEME_SOURCE_APP
theme_mode = dark_mode ? THEME_MODE_DARK : THEME_MODE_LIGHT
SetThemeSource((ThemeSource)theme_source)
SetThemeMode((ThemeMode)theme_mode)
SetCurrentTheme(theme_id, dark_mode)
}
if Button((ButtonProps){.bounds = {right + ScaleUIPx(276), y + ScaleUIPx(94), ScaleUIPx(120), ScaleUIPx(34)}, .label = "Action modal", .id = 128}) {
if Button((ButtonProps){.bounds = {right + Scale(276), y + Scale(94), Scale(120), Scale(34)}, .label = "Action modal", .id = 128}) {
dialog = 4
}
}
if category == 5 {
if Button((ButtonProps){.bounds = {x,y + ScaleUIPx(430),ScaleUIPx(180),ScaleUIPx(36)},.label = "PickerDialog",.id = 960}) { dialog = 5 }
if Button((ButtonProps){.bounds = {x + ScaleUIPx(200),y + ScaleUIPx(430),ScaleUIPx(180),ScaleUIPx(36)},.label = "ModalFrame",.id = 961}) { dialog = 6 }
if Button((ButtonProps){.bounds = {right,y + ScaleUIPx(430),ScaleUIPx(180),ScaleUIPx(36)},.label = "TextPopover",.id = 962}) { dialog = 7; text_focused = 0 }
Text(TextFormat("Picker: %d / Dialog result: %d", picker_choice, dialog_result), x, y + ScaleUIPx(486), Text16, GetThemeText())
if Button((ButtonProps){.bounds = {x,y + Scale(430),Scale(180),Scale(36)},.label = "PickerDialog",.id = 960}) { dialog = 5 }
if Button((ButtonProps){.bounds = {x + Scale(200),y + Scale(430),Scale(180),Scale(36)},.label = "ModalFrame",.id = 961}) { dialog = 6 }
if Button((ButtonProps){.bounds = {right,y + Scale(430),Scale(180),Scale(36)},.label = "TextPopover",.id = 962}) { dialog = 7; text_focused = 0 }
Text((TextProps){.bounds={x, y + Scale(486), 0, 0}, .text=TextFormat("Picker: %d / Dialog result: %d", picker_choice, dialog_result), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
}
if category == 6 {
Text("CANVAS", x, y, Text20, GetThemeLink())
canvas_bounds: Rectangle = {x,y + ScaleUIPx(38),ScaleUIPx(360),ScaleUIPx(120)}
Text((TextProps){.bounds={x, y, 0, 0}, .text="CANVAS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
canvas_bounds: Rectangle = {x,y + Scale(38),Scale(360),Scale(120)}
mouse: Vector2 = GetMousePosition()
if CheckCollisionPointRec(mouse, canvas_bounds) && !UIInputCapturesClick(mouse) {
wheel: float = GetMouseWheelMove()
@@ -433,82 +439,82 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
canvas_last = mouse
if IsMouseButtonReleased(MOUSE_BUTTON_LEFT) { canvas_dragging = 0 }
}
canvas_result: CanvasResult = BeginCanvas((Canvas){{x, y + ScaleUIPx(38), ScaleUIPx(360), ScaleUIPx(120)}, &canvas_scroll_x, &canvas_scroll_y, &canvas_zoom})
CanvasGrid((Rectangle){x, y + ScaleUIPx(38), ScaleUIPx(360), ScaleUIPx(120)}, 12, GetThemeIcon())
DrawCircle(x + ScaleUIPx(180), y + ScaleUIPx(98), ScaleUIPx(16), GetThemeLink())
canvas_result: CanvasResult = BeginCanvas((Canvas){{x, y + Scale(38), Scale(360), Scale(120)}, &canvas_scroll_x, &canvas_scroll_y, &canvas_zoom})
CanvasGrid((Rectangle){x, y + Scale(38), Scale(360), Scale(120)}, 12, GetThemeIcon())
DrawCircle(x + Scale(180), y + Scale(98), Scale(16), GetThemeLink())
unused canvas_result
EndCanvas((Canvas){{x, y + ScaleUIPx(38), ScaleUIPx(360), ScaleUIPx(120)}, &canvas_scroll_x, &canvas_scroll_y, &canvas_zoom})
Text("Wheel to zoom; drag the canvas to pan.", right, y + ScaleUIPx(56), Text16, GetThemeText())
EndCanvas((Canvas){{x, y + Scale(38), Scale(360), Scale(120)}, &canvas_scroll_x, &canvas_scroll_y, &canvas_zoom})
Text((TextProps){.bounds={right, y + Scale(56), 0, 0}, .text="Wheel to zoom; drag the canvas to pan.", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
}
if category == 6 {
Text(TextFormat("Pan: %d, %d / Zoom: %.2f", canvas_scroll_x,canvas_scroll_y,canvas_zoom), x, y + ScaleUIPx(190), Text16, GetThemeText())
if Button((ButtonProps){.bounds = {right,y + ScaleUIPx(100),ScaleUIPx(140),ScaleUIPx(34)},.label = "Reset canvas",.id = 963}) {
Text((TextProps){.bounds={x, y + Scale(190), 0, 0}, .text=TextFormat("Pan: %d, %d / Zoom: %.2f", canvas_scroll_x,canvas_scroll_y,canvas_zoom), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {right,y + Scale(100),Scale(140),Scale(34)},.label = "Reset canvas",.id = 963}) {
canvas_scroll_x = 0
canvas_scroll_y = 0
canvas_zoom = 1.0f
}
}
if category == 7 {
Text("NUMBERS AND PLOTS", x, y, Text20, GetThemeLink())
Text("DragFloat", x, y + ScaleUIPx(54), Text16, GetThemeText())
DragFloat((DragFloatProps){.bounds = {x,y + ScaleUIPx(86),ScaleUIPx(350),ScaleUIPx(36)}, .id = 300, .values = numbers, .value_count = 3, .speed = 0.01f, .min = 0.0f, .max = 1.0f})
Text("DragInt", right, y + ScaleUIPx(54), Text16, GetThemeText())
DragInt((DragIntProps){.bounds = {right,y + ScaleUIPx(86),ScaleUIPx(350),ScaleUIPx(36)}, .id = 301, .values = integers, .value_count = 3, .speed = 1.0f, .min = 0, .max = 10})
Text("DragFloatRange2", x, y + ScaleUIPx(166), Text16, GetThemeText())
DragFloatRange2((DragFloatRange2Props){.bounds = {x,y + ScaleUIPx(198),ScaleUIPx(350),ScaleUIPx(36)}, .id = 302, .current_min = &range_min, .current_max = &range_max, .speed = 0.1f, .min = 0.0f, .max = 10.0f})
Text("DragIntRange2", right, y + ScaleUIPx(166), Text16, GetThemeText())
DragIntRange2((DragIntRange2Props){.bounds = {right,y + ScaleUIPx(198),ScaleUIPx(350),ScaleUIPx(36)}, .id = 303, .current_min = &int_min, .current_max = &int_max, .speed = 1.0f, .min = 0, .max = 10})
Text("SliderFloat", x, y + ScaleUIPx(278), Text16, GetThemeText())
SliderFloat((SliderFloatProps){.bounds = {x,y + ScaleUIPx(310),ScaleUIPx(350),ScaleUIPx(36)}, .id = 304, .values = numbers, .value_count = 3, .min = 0.0f, .max = 1.0f})
Text("SliderInt", right, y + ScaleUIPx(278), Text16, GetThemeText())
SliderInt((SliderIntProps){.bounds = {right,y + ScaleUIPx(310),ScaleUIPx(350),ScaleUIPx(36)}, .id = 305, .values = integers, .value_count = 3, .min = 0, .max = 10})
Text("SliderAngle", x, y + ScaleUIPx(390), Text16, GetThemeText())
SliderAngle((SliderAngleProps){.bounds = {x,y + ScaleUIPx(422),ScaleUIPx(350),ScaleUIPx(36)}, .id = 306, .value = &angle, .min_degrees = -180.0f, .max_degrees = 180.0f})
Text("InputFloat", right, y + ScaleUIPx(390), Text16, GetThemeText())
InputFloat((InputFloatProps){.bounds = {right,y + ScaleUIPx(422),ScaleUIPx(350),ScaleUIPx(36)}, .id = 307, .values = numbers, .value_count = 3, .step = 0.1f, .step_fast = 1.0f})
Text("InputInt", x, y + ScaleUIPx(502), Text16, GetThemeText())
InputInt((InputIntProps){.bounds = {x,y + ScaleUIPx(534),ScaleUIPx(350),ScaleUIPx(36)}, .id = 308, .values = integers, .value_count = 3, .step = 1, .step_fast = 10})
Text("InputDouble", right, y + ScaleUIPx(502), Text16, GetThemeText())
InputDouble((InputDoubleProps){.bounds = {right,y + ScaleUIPx(534),ScaleUIPx(350),ScaleUIPx(36)}, .id = 309, .values = doubles, .value_count = 2, .step = 0.01, .step_fast = 1.0})
Text("VSliderFloat / VSliderInt", x, y + ScaleUIPx(628), Text16, GetThemeText())
VSliderFloat((SliderFloatProps){.bounds = {x,y + ScaleUIPx(666),ScaleUIPx(48),ScaleUIPx(150)}, .id = 310, .values = numbers, .value_count = 1, .min = 0.0f, .max = 1.0f})
VSliderInt((SliderIntProps){.bounds = {x + ScaleUIPx(72),y + ScaleUIPx(666),ScaleUIPx(48),ScaleUIPx(150)}, .id = 311, .values = integers, .value_count = 1, .min = 0, .max = 10})
Text("PlotLines", right, y + ScaleUIPx(628), Text16, GetThemeText())
PlotLines((PlotProps){.bounds = {right,y + ScaleUIPx(666),ScaleUIPx(350),ScaleUIPx(150)}, .values = plot, .value_count = 8, .scale_min = 0.0f, .scale_max = 1.0f})
Text("PlotHistogram", x, y + ScaleUIPx(870), Text16, GetThemeText())
PlotHistogram((PlotProps){.bounds = {x,y + ScaleUIPx(908),ScaleUIPx(350),ScaleUIPx(110)}, .values = plot, .value_count = 8, .scale_min = 0.0f, .scale_max = 1.0f})
Text((TextProps){.bounds={x, y, 0, 0}, .text="NUMBERS AND PLOTS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(54), 0, 0}, .text="DragFloat", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragFloat((DragFloatProps){.bounds = {x,y + Scale(86),Scale(350),Scale(36)}, .id = 300, .values = numbers, .value_count = 3, .speed = 0.01f, .min = 0.0f, .max = 1.0f})
Text((TextProps){.bounds={right, y + Scale(54), 0, 0}, .text="DragInt", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragInt((DragIntProps){.bounds = {right,y + Scale(86),Scale(350),Scale(36)}, .id = 301, .values = integers, .value_count = 3, .speed = 1.0f, .min = 0, .max = 10})
Text((TextProps){.bounds={x, y + Scale(166), 0, 0}, .text="DragFloatRange2", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragFloatRange2((DragFloatRange2Props){.bounds = {x,y + Scale(198),Scale(350),Scale(36)}, .id = 302, .current_min = &range_min, .current_max = &range_max, .speed = 0.1f, .min = 0.0f, .max = 10.0f})
Text((TextProps){.bounds={right, y + Scale(166), 0, 0}, .text="DragIntRange2", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
DragIntRange2((DragIntRange2Props){.bounds = {right,y + Scale(198),Scale(350),Scale(36)}, .id = 303, .current_min = &int_min, .current_max = &int_max, .speed = 1.0f, .min = 0, .max = 10})
Text((TextProps){.bounds={x, y + Scale(278), 0, 0}, .text="SliderFloat", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
SliderFloat((SliderFloatProps){.bounds = {x,y + Scale(310),Scale(350),Scale(36)}, .id = 304, .values = numbers, .value_count = 3, .min = 0.0f, .max = 1.0f})
Text((TextProps){.bounds={right, y + Scale(278), 0, 0}, .text="SliderInt", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
SliderInt((SliderIntProps){.bounds = {right,y + Scale(310),Scale(350),Scale(36)}, .id = 305, .values = integers, .value_count = 3, .min = 0, .max = 10})
Text((TextProps){.bounds={x, y + Scale(390), 0, 0}, .text="SliderAngle", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
SliderAngle((SliderAngleProps){.bounds = {x,y + Scale(422),Scale(350),Scale(36)}, .id = 306, .value = &angle, .min_degrees = -180.0f, .max_degrees = 180.0f})
Text((TextProps){.bounds={right, y + Scale(390), 0, 0}, .text="InputFloat", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
InputFloat((InputFloatProps){.bounds = {right,y + Scale(422),Scale(350),Scale(36)}, .id = 307, .values = numbers, .value_count = 3, .step = 0.1f, .step_fast = 1.0f})
Text((TextProps){.bounds={x, y + Scale(502), 0, 0}, .text="InputInt", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
InputInt((InputIntProps){.bounds = {x,y + Scale(534),Scale(350),Scale(36)}, .id = 308, .values = integers, .value_count = 3, .step = 1, .step_fast = 10})
Text((TextProps){.bounds={right, y + Scale(502), 0, 0}, .text="InputDouble", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
InputDouble((InputDoubleProps){.bounds = {right,y + Scale(534),Scale(350),Scale(36)}, .id = 309, .values = doubles, .value_count = 2, .step = 0.01, .step_fast = 1.0})
Text((TextProps){.bounds={x, y + Scale(628), 0, 0}, .text="VSliderFloat / VSliderInt", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
VSliderFloat((SliderFloatProps){.bounds = {x,y + Scale(666),Scale(48),Scale(150)}, .id = 310, .values = numbers, .value_count = 1, .min = 0.0f, .max = 1.0f})
VSliderInt((SliderIntProps){.bounds = {x + Scale(72),y + Scale(666),Scale(48),Scale(150)}, .id = 311, .values = integers, .value_count = 1, .min = 0, .max = 10})
Text((TextProps){.bounds={right, y + Scale(628), 0, 0}, .text="PlotLines", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
PlotLines((PlotProps){.bounds = {right,y + Scale(666),Scale(350),Scale(150)}, .values = plot, .value_count = 8, .scale_min = 0.0f, .scale_max = 1.0f})
Text((TextProps){.bounds={x, y + Scale(870), 0, 0}, .text="PlotHistogram", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
PlotHistogram((PlotProps){.bounds = {x,y + Scale(908),Scale(350),Scale(110)}, .values = plot, .value_count = 8, .scale_min = 0.0f, .scale_max = 1.0f})
}
if category == 8 {
Text("COLORS", x, y, Text20, GetThemeLink())
Text("ColorEdit3", x, y + ScaleUIPx(54), Text16, GetThemeText())
ColorEdit3((ColorEditProps){.bounds = {x,y + ScaleUIPx(90),ScaleUIPx(350),ScaleUIPx(36)}, .id = 320, .values = rgba, .value_count = 3})
Text("ColorEdit4", right, y + ScaleUIPx(54), Text16, GetThemeText())
ColorEdit4((ColorEditProps){.bounds = {right,y + ScaleUIPx(90),ScaleUIPx(350),ScaleUIPx(36)}, .id = 321, .values = rgba, .value_count = 4})
Text("ColorPicker3", x, y + ScaleUIPx(170), Text16, GetThemeText())
ColorPicker3((ColorEditProps){.bounds = {x,y + ScaleUIPx(208),ScaleUIPx(300),ScaleUIPx(160)}, .id = 322, .values = rgba, .value_count = 3})
Text("ColorPicker4", right, y + ScaleUIPx(170), Text16, GetThemeText())
ColorPicker4((ColorEditProps){.bounds = {right,y + ScaleUIPx(208),ScaleUIPx(300),ScaleUIPx(210)}, .id = 323, .values = rgba, .value_count = 4})
if ColorButton((ColorButtonProps){.bounds = {x,y + ScaleUIPx(450),ScaleUIPx(160),ScaleUIPx(36)}, .id = 324, .label = "ColorButton", .color = color_value}) {
Text((TextProps){.bounds={x, y, 0, 0}, .text="COLORS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
Text((TextProps){.bounds={x, y + Scale(54), 0, 0}, .text="ColorEdit3", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
ColorEdit3((ColorEditProps){.bounds = {x,y + Scale(90),Scale(350),Scale(36)}, .id = 320, .values = rgba, .value_count = 3})
Text((TextProps){.bounds={right, y + Scale(54), 0, 0}, .text="ColorEdit4", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
ColorEdit4((ColorEditProps){.bounds = {right,y + Scale(90),Scale(350),Scale(36)}, .id = 321, .values = rgba, .value_count = 4})
Text((TextProps){.bounds={x, y + Scale(170), 0, 0}, .text="ColorPicker3", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
ColorPicker3((ColorEditProps){.bounds = {x,y + Scale(208),Scale(300),Scale(160)}, .id = 322, .values = rgba, .value_count = 3})
Text((TextProps){.bounds={right, y + Scale(170), 0, 0}, .text="ColorPicker4", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
ColorPicker4((ColorEditProps){.bounds = {right,y + Scale(208),Scale(300),Scale(210)}, .id = 323, .values = rgba, .value_count = 4})
if ColorButton((ColorButtonProps){.bounds = {x,y + Scale(450),Scale(160),Scale(36)}, .id = 324, .label = "ColorButton", .color = color_value}) {
action_count += 1
}
}
if category == 3 {
Text("CascadingTreeView (expand folders)", x, y + ScaleUIPx(650), Text16, GetThemeText())
CascadingTreeView((CascadingTreeViewProps){.bounds = {x,y + ScaleUIPx(688),ScaleUIPx(350),ScaleUIPx(210)},.id = 964,.items = cascade_items,.item_count = 4,.selected_id = &cascade_selected,.activated_id = &cascade_activated,.expanded = {cascade_ids,&cascade_count,4},.scroll_offset = &cascade_scroll,.row_height = ScaleUIPx(30)})
Text((TextProps){.bounds={x, y + Scale(650), 0, 0}, .text="CascadingTreeView (expand folders)", .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
CascadingTreeView((CascadingTreeViewProps){.bounds = {x,y + Scale(688),Scale(350),Scale(210)},.id = 964,.items = cascade_items,.item_count = 4,.selected_id = &cascade_selected,.activated_id = &cascade_activated,.expanded = {cascade_ids,&cascade_count,4},.scroll_offset = &cascade_scroll,.row_height = Scale(30)})
}
if category == 9 {
Text("PAGES AND SETTINGS", x, y, Text20, GetThemeLink())
if Button((ButtonProps){.bounds = {x,y + ScaleUIPx(42),ScaleUIPx(350),ScaleUIPx(36)},.label = "Preview TitleBar and BottomNav",.id = 965}) { page_preview = 1 }
Page((PageProps){.bounds = {x,y + ScaleUIPx(110),ScaleUIPx(360),ScaleUIPx(210)},.title = "Page",.gap = ScaleUIPx(12),.padding = ScaleUIPx(12),.key = 966})
Section((SectionProps){.bounds = {0,0,ScaleUIPx(336),ScaleUIPx(180)},.label = "Section",.gap = ScaleUIPx(12),.key = 967})
Heading((HeadingProps){.bounds = {x + ScaleUIPx(12),y + ScaleUIPx(122),ScaleUIPx(312),ScaleUIPx(40)},.text = "Page / Section",.level = 2,.font = Text20,.color = GetThemeText(),.key = 968})
ParagraphText((ParagraphTextProps){.bounds = {x + ScaleUIPx(12),y + ScaleUIPx(174),ScaleUIPx(312),ScaleUIPx(72)},.text = "Semantic page content using standard headings and paragraphs.",.font = Text16,.color = GetThemeText(),.key = 969})
Text((TextProps){.bounds={x, y, 0, 0}, .text="PAGES AND SETTINGS", .font=Text20, .color=GetThemeLink(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {x,y + Scale(42),Scale(350),Scale(36)},.label = "Preview TitleBar and BottomNav",.id = 965}) { page_preview = 1 }
Page((PageProps){.bounds = {x,y + Scale(110),Scale(360),Scale(210)},.title = "Page",.gap = Scale(12),.padding = Scale(12),.key = 966})
Section((SectionProps){.bounds = {0,0,Scale(336),Scale(180)},.label = "Section",.gap = Scale(12),.key = 967})
Heading((HeadingProps){.bounds = {x + Scale(12),y + Scale(122),Scale(312),Scale(40)},.text = "Page / Section",.level = 2,.font = Text20,.color = GetThemeText(),.key = 968})
ParagraphText((ParagraphTextProps){.bounds = {x + Scale(12),y + Scale(174),Scale(312),Scale(72)},.text = "Semantic page content using standard headings and paragraphs.",.font = Text16,.color = GetThemeText(),.key = 969})
End()
End()
ThemeSettings((ThemeSettingsProps){.id_base = 980,.x = right,.y = y + ScaleUIPx(110),.w = ScaleUIPx(340),.theme_source = &theme_source,.theme_mode = &theme_mode,.theme_id = &theme_id,.theme_style = &theme_style,.allow_system_source = 1,.allow_system_mode = 1,.theme_label = "Source",.source_app_label = "App",.source_system_label = "System",.mode_label = "Mode",.mode_system_label = "System",.mode_light_label = "Light",.mode_dark_label = "Dark",.palette_label = "Palette",.style_label = "Style",.style_system_label = "System",.style_retro_label = "Retro",.style_material_label = "Material",.style_fluent_label = "Fluent",.style_adwaita_label = "Adwaita",.style_liquid_glass_label = "Liquid Glass",.system_theme_label = "System theme"}, &theme_state, &theme_result)
ThemeSettings((ThemeSettingsProps){.id_base = 980,.x = right,.y = y + Scale(110),.w = Scale(340),.theme_source = &theme_source,.theme_mode = &theme_mode,.theme_id = &theme_id,.theme_style = &theme_style,.allow_system_source = 1,.allow_system_mode = 1,.theme_label = "Source",.source_app_label = "App",.source_system_label = "System",.mode_label = "Mode",.mode_system_label = "System",.mode_light_label = "Light",.mode_dark_label = "Dark",.palette_label = "Palette",.style_label = "Style",.style_system_label = "System",.style_retro_label = "Retro",.style_material_label = "Material",.style_fluent_label = "Fluent",.style_adwaita_label = "Adwaita",.style_liquid_glass_label = "Liquid Glass",.system_theme_label = "System theme"}, &theme_state, &theme_result)
if theme_result.changed {
SetThemeSource((ThemeSource)theme_source)
SetThemeMode((ThemeMode)theme_mode)
@@ -539,17 +545,17 @@ WidgetCatalogExample :: (viewport: Rectangle) #ui {
}
if dialog == 6 {
frame: UIPanelFrame = ModalFrame(420,220,"ModalFrame",(Texture2D){0},(Texture2D){0})
Text("Custom modal content",frame.content_x,frame.content_y,Text20,GetThemeText())
if Button((ButtonProps){.bounds = {frame.content_x,frame.content_y + ScaleUIPx(56),ScaleUIPx(160),ScaleUIPx(36)},.label = "Close",.id = 970}) || IsKeyPressed(KEY_ESCAPE) {
Text((TextProps){.bounds={frame.content_x, frame.content_y, 0, 0}, .text="Custom modal content", .font=Text20, .color=GetThemeText(), .wrap=TextWrapNone})
if Button((ButtonProps){.bounds = {frame.content_x,frame.content_y + Scale(56),Scale(160),Scale(36)},.label = "Close",.id = 970}) || IsKeyPressed(KEY_ESCAPE) {
dialog = 0
}
}
if dialog == 7 && TextPopover((TextPopoverProps){.anchor = {ScaleUIPx(662),ScaleUIPx(520),ScaleUIPx(180),ScaleUIPx(36)},.title = "Edit",.text = text_value,.text_size = sizeof(text_value),.cursor_position = &text_cursor,.focused = &text_focused,.id = 971,.width = 360,.max_codepoints = 63}) != 0 {
if dialog == 7 && TextPopover((TextPopoverProps){.anchor = {Scale(662),Scale(520),Scale(180),Scale(36)},.title = "Edit",.text = text_value,.text_size = sizeof(text_value),.cursor_position = &text_cursor,.focused = &text_focused,.id = 971,.width = 360,.max_codepoints = 63}) != 0 {
dialog = 0
}
if dialog == 4 {
actions: [2] ModalAction = {{"Cancel",ButtonStyleSecondary,0},{"Continue",ButtonStylePrimary,0}}
if ActionModal((ModalProps){"Action modal","Choose a simple action.",actions,2,{0},ScaleUIPx(420)}) != 0 {
if ActionModal((ModalProps){"Action modal","Choose a simple action.",actions,2,{0},Scale(420)}) != 0 {
dialog = 0
}
}
+34 -33
View File
@@ -81,8 +81,26 @@ func EndFrame() {
active().EndFrame()
endDirectFrame()
}
func BeginDisabled(disabled bool) { active().BeginDisabled(disabled) }
func EndDisabled() { active().EndDisabled() }
func BeginDisabled(disabled bool) { active().BeginDisabled(disabled) }
func EndDisabled() { active().EndDisabled() }
func BeginCombo(props ComboProps) bool { return active().BeginCombo(props) }
func EndCombo() { active().EndCombo() }
func CloseCombo() { active().CloseCombo() }
func BeginPopup(props PopupProps) bool { return active().BeginPopup(props) }
func EndPopup() { active().EndPopup() }
func ClosePopup() { active().ClosePopup() }
func BeginTabBar(props TabBarProps, selectedIndex *int32) bool {
return active().BeginTabBar(props, selectedIndex)
}
func BeginTabItem(index int32) bool { return active().BeginTabItem(index) }
func EndTabItem() { active().EndTabItem() }
func EndTabBar() { active().EndTabBar() }
func AcceleratorPressed(accelerator Accelerator) int32 {
return active().AcceleratorPressed(accelerator)
}
func DispatchAccelerators(accelerators []Accelerator, count ...int32) int32 {
return active().DispatchAccelerators(accelerators, count...)
}
func SetFocus(id int32) {
if runtime, ok := active().(focusController); ok {
runtime.SetFocus(id)
@@ -143,18 +161,7 @@ func Selection(focusID int32) (anchor, cursor int32, ok bool) {
}
func ClearBackground(c Color) { active().ClearBackground(c) }
func Background(c Color) { active().Background(c) }
func Text(text string, x, y, fontSize int32, color Color) {
active().Text(text, x, y, fontSize, color)
}
func TextColored(text string, x, y, fontSize int32, color Color) {
active().TextColored(text, x, y, fontSize, color)
}
func TextDisabled(text string, x, y, fontSize int32) {
active().TextDisabled(text, x, y, fontSize)
}
func TextWrapped(text string, bounds Rectangle, fontSize int32, color Color) {
active().TextWrapped(text, bounds, fontSize, color)
}
func Text(props TextProps) { active().Text(props) }
func LabelText(label, value string, bounds Rectangle, fontSize int32, color Color) {
active().LabelText(label, value, bounds, fontSize, color)
}
@@ -174,13 +181,13 @@ func ValueFloat(prefix string, value float32, format string, bounds Rectangle, f
active().ValueFloat(prefix, value, format, bounds, fontSize, color)
}
func TextFormat(format string, args ...any) string { return active().TextFormat(format, args...) }
func ScaleUIPx(px int32) int32 { return active().ScaleUIPx(px) }
func GetFontSize() int32 { return ScaleUIPx(Text16) }
func GetSmallFontSize() int32 { return ScaleUIPx(Text14) }
func Scale(px int32) int32 { return active().Scale(px) }
func GetFontSize() int32 { return Scale(Text16) }
func GetSmallFontSize() int32 { return Scale(Text14) }
func GetTitleFontSize(title string, maxWidth int32) int32 {
large := ScaleUIPx(Text24)
medium := ScaleUIPx(Text16)
small := ScaleUIPx(Text14)
large := Scale(Text24)
medium := Scale(Text16)
small := Scale(Text14)
if maxWidth <= 0 || int32(runtimeTextWidth(title, large)) <= maxWidth {
return large
}
@@ -190,10 +197,10 @@ func GetTitleFontSize(title string, maxWidth int32) int32 {
return small
}
func FitFontSize(text string, maxWidth, preferredSize, minSize int32) int32 {
minimum := ScaleUIPx(Text8)
caption := ScaleUIPx(Text12)
small := ScaleUIPx(Text14)
body := ScaleUIPx(Text16)
minimum := Scale(Text8)
caption := Scale(Text12)
small := Scale(Text14)
body := Scale(Text16)
normalize := func(size int32) int32 {
switch size {
case Text8:
@@ -205,7 +212,7 @@ func FitFontSize(text string, maxWidth, preferredSize, minSize int32) int32 {
case Text16:
return body
case Text24:
return ScaleUIPx(Text24)
return Scale(Text24)
}
if size <= minimum {
return minimum
@@ -219,7 +226,7 @@ func FitFontSize(text string, maxWidth, preferredSize, minSize int32) int32 {
if size <= body {
return body
}
return ScaleUIPx(Text24)
return Scale(Text24)
}
fontSize := normalize(preferredSize)
minAllowed := normalize(minSize)
@@ -290,10 +297,7 @@ func ColorEdit4(props ColorEditProps) bool { return active().ColorEd
func ColorPicker3(props ColorEditProps) bool { return active().ColorPicker3(props) }
func ColorPicker4(props ColorEditProps) bool { return active().ColorPicker4(props) }
func ColorButton(props ColorButtonProps) bool { return active().ColorButton(props) }
func Tooltip(props TooltipProps) bool { return active().Tooltip(props) }
func TabBar(bounds Rectangle, labels []string, selected, hover *int32) int32 {
return active().TabBar(bounds, labels, selected, hover)
}
func TabBar(props TabBarProps) int32 { return active().TabBar(props) }
func Progress(props ProgressBarProps) {
active().Progress(props)
}
@@ -354,9 +358,6 @@ func GetThemeLink() Color { return active().GetThemeL
func GetThemePrimary() Color { return active().GetThemePrimary() }
func GetThemeOnPrimary() Color { return active().GetThemeOnPrimary() }
func GetThemeSurfaceVariant() Color { return active().GetThemeSurfaceVariant() }
func TextInRect(text string, rect Rectangle, fontSize int32, color Color) {
active().TextInRect(text, rect, fontSize, color)
}
func TextLines(lines any, count int32, x int32, y *int32, font, lineH int32, color Color) {
active().TextLines(lines, count, x, y, font, lineH, color)
}
+167
View File
@@ -0,0 +1,167 @@
package kryon
type comboScope struct {
id int32
open *bool
paint paintLayerToken
input popupInputToken
}
func (r *runtime) comboPopup(p ComboProps) Rectangle {
row := p.Bounds.Height
if row <= 0 {
row = 28
}
heights := p.Flags & (ComboHeightSmall | ComboHeightRegular | ComboHeightLarge | ComboHeightLargest)
if heights != 0 && heights&(heights-1) != 0 {
panic("combo height flags are mutually exclusive")
}
popup := Rectangle{X: p.Bounds.X, Y: p.Bounds.Y + p.Bounds.Height, Width: p.PopupSize.X, Height: p.PopupSize.Y}
if popup.Width <= 0 {
popup.Width = p.Bounds.Width
}
if popup.Height <= 0 {
rows := float32(8)
if p.Flags&ComboHeightSmall != 0 {
rows = 4
}
if p.Flags&ComboHeightLarge != 0 {
rows = 20
}
if p.Flags&ComboHeightLargest != 0 {
rows = 32
}
popup.Height = row * rows
}
w, h := float32(r.GetScreenWidth()), float32(r.GetScreenHeight())
if w > 0 {
if popup.Width > w {
popup.Width = w
}
if p.Flags&ComboPopupAlignLeft == 0 {
popup.X = p.Bounds.X + p.Bounds.Width - popup.Width
}
popup.X = max(float32(0), min(popup.X, w-popup.Width))
}
if h > 0 {
if popup.Height > h {
popup.Height = h
}
if popup.Y+popup.Height > h {
popup.Y = p.Bounds.Y - popup.Height
}
popup.Y = max(float32(0), popup.Y)
if popup.Y+popup.Height > h {
popup.Height = h - popup.Y
}
}
return popup
}
func (r *runtime) BeginCombo(p ComboProps) bool {
if p.ID <= 0 || p.Open == nil {
return false
}
if r.combosSeen == nil {
r.combosSeen = make(map[int32]bool)
}
if r.openCombos == nil {
r.openCombos = make(map[int32]*bool)
}
r.combosSeen[p.ID] = true
r.openCombos[p.ID] = p.Open
popup := r.comboPopup(p)
if p.Disabled {
*p.Open = false
}
if *p.Open {
for i := range r.taps {
if !r.taps[i].consumed && !pointInRect(r.taps[i].x, r.taps[i].y, popup) {
r.taps[i].consumed = true
*p.Open = false
r.closePopupInput(p.ID)
}
}
}
var input popupInputToken
hasInput := false
if *p.Open {
input, hasInput = r.beginPopupInput(p.ID, popup), true
}
trigger := p.Bounds
preview := p.Preview
if p.Flags&ComboNoPreview != 0 {
preview = ""
}
if p.Flags&ComboWidthFitPreview != 0 {
need := float32(runtimeTextWidth(preview, Text16) + 20)
if p.Flags&ComboNoArrowButton == 0 {
need += 20
}
if need > trigger.Width {
trigger.Width = need
}
}
label := preview
if p.Flags&ComboNoArrowButton == 0 {
label += " v"
}
pressed := r.Button(ButtonProps{Bounds: trigger, Label: label, ID: p.ID, Disabled: p.Disabled})
if pressed {
*p.Open = !*p.Open
}
if !*p.Open {
if hasInput {
r.closePopupInput(p.ID)
r.endPopupInput(input)
}
delete(r.openCombos, p.ID)
return false
}
if !hasInput {
input, hasInput = r.beginPopupInput(p.ID, popup), true
}
if r.keyDown[KeyEscape] && !r.popupKeyboardCaptures() {
*p.Open = false
r.closePopupInput(p.ID)
r.endPopupInput(input)
delete(r.openCombos, p.ID)
return false
}
paint := r.beginPaintLayer(p.ID)
r.scrollClips = append(r.scrollClips, popup)
t := r.theme()
r.record(FrameOp{Kind: FrameOpRect, Bounds: popup, Color: t.surface, BorderColor: t.border, ID: p.ID})
r.comboScopes = append(r.comboScopes, comboScope{id: p.ID, open: p.Open, paint: paint, input: input})
return true
}
func (r *runtime) CloseCombo() {
if len(r.comboScopes) == 0 {
return
}
s := &r.comboScopes[len(r.comboScopes)-1]
*s.open = false
r.closePopupInput(s.id)
delete(r.openCombos, s.id)
}
func (r *runtime) EndCombo() {
n := len(r.comboScopes)
if n == 0 {
panic("EndCombo without BeginCombo")
}
s := r.comboScopes[n-1]
if !*s.open {
r.closePopupInput(s.id)
delete(r.openCombos, s.id)
}
if len(r.scrollClips) == 0 {
panic("combo popup clip was unbalanced")
}
r.scrollClips = r.scrollClips[:len(r.scrollClips)-1]
r.endPopupInput(s.input)
r.endPaintLayer(s.paint)
r.comboScopes[n-1] = comboScope{}
r.comboScopes = r.comboScopes[:n-1]
}
+150
View File
@@ -0,0 +1,150 @@
package kryon
import "testing"
func countComboOps(ops []FrameOp, id int32) int {
n := 0
for _, op := range ops {
if op.ID == id {
n++
}
}
return n
}
func TestComposedComboOrdinaryContentsAndLayout(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.BeginFrame()
r.Column(ColumnProps{Bounds: NewRectangle(10, 10, 180, 120), Gap: 5})
r.Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "before", Font: 14, Color: BLACK, Wrap: TextWrapNone})
if !r.BeginCombo(ComboProps{Bounds: NewRectangle(0, 0, 100, 28), PopupSize: NewVector2(120, 80), Preview: "Choose", ID: 27000, Open: &open, Flags: ComboPopupAlignLeft}) {
t.Fatal("open composed combo returned false")
}
r.Column(ColumnProps{Bounds: NewRectangle(12, 45, 100, 60), Gap: 3})
if r.Button(ButtonProps{Bounds: NewRectangle(0, 0, 90, 24), Label: "Action", ID: 27001}) {
t.Fatal("unexpected action")
}
text := make([]byte, 16)
copy(text, "edit")
cursor := int32(4)
r.TextField(TextFieldProps{Bounds: NewRectangle(0, 0, 90, 24), Text: text, CursorPosition: &cursor, FocusID: 27002})
r.End()
r.EndCombo()
r.Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "after", Font: 14, Color: BLACK, Wrap: TextWrapNone})
r.End()
r.EndFrame()
ops := r.FrameOps()
textFound := false
for _, op := range ops {
if op.FocusID == 27002 {
textFound = true
}
}
if countComboOps(ops, 27001) == 0 || !textFound {
t.Fatalf("ordinary popup children were not composited: %+v", ops)
}
if len(r.layout) != 0 || len(r.paintLayerScopes) != 0 || len(r.popupInputScopes) != 0 {
t.Fatal("combo did not restore scopes")
}
child := -1
after := -1
for i, op := range ops {
if op.ID == 27001 {
child = i
}
if op.Kind == FrameOpText && op.Text == "after" {
after = i
}
}
if child <= after {
t.Fatalf("popup child did not composite above later parent: child=%d after=%d", child, after)
}
}
func TestComposedComboNestedInputAndExplicitClose(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
outerOpen, innerOpen := true, true
r.QueueTap(36, 94)
r.BeginFrame()
if !r.BeginCombo(ComboProps{Bounds: NewRectangle(10, 10, 100, 28), PopupSize: NewVector2(150, 130), Preview: "Outer", ID: 27100, Open: &outerOpen, Flags: ComboPopupAlignLeft}) {
t.Fatal("outer closed")
}
if !r.BeginCombo(ComboProps{Bounds: NewRectangle(20, 50, 100, 28), PopupSize: NewVector2(100, 70), Preview: "Inner", ID: 27101, Open: &innerOpen, Flags: ComboPopupAlignLeft}) {
t.Fatal("inner closed")
}
if !r.Button(ButtonProps{Bounds: NewRectangle(20, 82, 90, 24), Label: "Nested action", ID: 27102}) {
t.Fatal("nested ordinary button did not receive tap")
}
r.CloseCombo()
r.EndCombo()
if innerOpen {
t.Fatal("CloseCombo did not update caller state")
}
r.EndCombo()
r.EndFrame()
if countComboOps(r.FrameOps(), 27102) != 0 {
t.Fatal("explicitly closed layer was painted")
}
if !outerOpen {
t.Fatal("closing child closed parent")
}
}
func TestComposedComboPlacementFlagsAndMissingOwner(t *testing.T) {
for _, tc := range []struct {
name string
flags ComboFlags
x, y, w, h float32
}{
{"right", ComboHeightSmall, 90, 40, 120, 112},
{"left-fit", ComboPopupAlignLeft | ComboWidthFitPreview | ComboNoArrowButton | ComboNoPreview | ComboHeightLarge, 170, 0, 70, 180},
} {
t.Run(tc.name, func(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.BeginFrame()
p := ComboProps{Bounds: NewRectangle(170, 152, 40, 28), PopupSize: NewVector2(tc.w, 0), Preview: "A very long preview", ID: 27200, Open: &open, Flags: tc.flags}
if !r.BeginCombo(p) {
t.Fatal("combo closed")
}
r.EndCombo()
r.EndFrame()
var bg *FrameOp
for i := range r.ops {
if r.ops[i].ID == 27200 && r.ops[i].Kind == FrameOpRect {
bg = &r.ops[i]
}
}
if bg == nil {
t.Fatal("popup background missing")
}
if bg.Bounds.X != tc.x || bg.Bounds.Y != tc.y || bg.Bounds.Width != tc.w || bg.Bounds.Height != tc.h {
t.Fatalf("popup=%+v", bg.Bounds)
}
r.BeginFrame()
r.EndFrame()
if open {
t.Fatal("missing combo owner did not close caller state")
}
})
}
}
func TestComposedComboScopeBalance(t *testing.T) {
r := New(AppConfig{}).(*runtime)
mustPanic := func(f func()) {
t.Helper()
defer func() {
if recover() == nil {
t.Error("invalid combo scope was accepted")
}
}()
f()
}
mustPanic(func() { r.EndCombo() })
open := true
r.BeginFrame()
r.BeginCombo(ComboProps{Bounds: NewRectangle(0, 0, 100, 28), PopupSize: NewVector2(100, 60), ID: 27300, Open: &open})
mustPanic(func() { r.EndFrame() })
}
+9 -1
View File
@@ -61,7 +61,15 @@ func CheckCollisionPointRec(p Vector2, r Rectangle) bool {
}
func DrawTextEx(font Font, text string, pos Vector2, size float32, _ float32, c Color) {
active().TextWithFont(text, int32(pos.X), int32(pos.Y), int32(size), c, font.ID)
props := TextProps{Bounds: Rectangle{X: pos.X, Y: pos.Y}, Text: text,
Font: int32(size), Color: c, Wrap: TextWrapNone}
if runtime, ok := active().(interface {
textWithFont(TextProps, uint32)
}); ok {
runtime.textWithFont(props, font.ID)
return
}
active().Text(props)
}
func MeasureTextEx(font Font, text string, size float32, _ float32) Vector2 {
+2 -2
View File
@@ -18,7 +18,7 @@ func CarouselControls(p CarouselControlsProps) int32 {
if !p.Disabled {
s = (s + p.Move%p.Count + p.Count) % p.Count
}
hit, inset, icon := ScaleUIPx(48), ScaleUIPx(12), ScaleUIPx(10)
hit, inset, icon := Scale(48), Scale(12), Scale(10)
if p.Bounds.Width >= float32(hit*2) && p.Bounds.Height >= float32(hit) {
for i := int32(0); i < 2; i++ {
x := p.Bounds.X + float32(inset)
@@ -61,7 +61,7 @@ func CarouselControls(p CarouselControlsProps) int32 {
if p.Disabled {
c.A = 51
}
DrawCircleV(Vector2{X: b.X + float32(hit)/2, Y: b.Y + float32(hit)/2}, ScaleUIPx(r), c)
DrawCircleV(Vector2{X: b.X + float32(hit)/2, Y: b.Y + float32(hit)/2}, Scale(r), c)
}
}
return s
+86
View File
@@ -0,0 +1,86 @@
package kryon
import "strings"
// These phases and queue limits match the native C input front-end.
type KryTextCompositionPhase int32
const (
KRY_TEXT_COMPOSITION_START KryTextCompositionPhase = iota + 1
KRY_TEXT_COMPOSITION_UPDATE
KRY_TEXT_COMPOSITION_COMMIT
KRY_TEXT_COMPOSITION_CANCEL
KRY_TEXT_COMPOSITION_MAX = 256
)
type KryTextCompositionEvent struct {
Phase KryTextCompositionPhase
Text string
Cursor int32
SelectionLength int32
}
func (r *runtime) SubmitTextComposition(phase KryTextCompositionPhase, text string, cursor, selectionLength int32) int32 {
if phase < KRY_TEXT_COMPOSITION_START || phase > KRY_TEXT_COMPOSITION_CANCEL || len(r.compositionEvents) >= 16 {
return 0
}
if end := strings.IndexByte(text, 0); end >= 0 {
text = text[:end]
}
if len(text) >= KRY_TEXT_COMPOSITION_MAX {
text = text[:KRY_TEXT_COMPOSITION_MAX-1]
}
r.compositionEvents = append(r.compositionEvents, KryTextCompositionEvent{phase, text, max(cursor, 0), max(selectionLength, 0)})
return 1
}
func (r *runtime) PollTextComposition(event *KryTextCompositionEvent) int32 {
if event == nil || len(r.compositionEvents) == 0 {
return 0
}
*event = r.compositionEvents[0]
copy(r.compositionEvents, r.compositionEvents[1:])
r.compositionEvents[len(r.compositionEvents)-1] = KryTextCompositionEvent{}
r.compositionEvents = r.compositionEvents[:len(r.compositionEvents)-1]
return 1
}
func (r *runtime) ClearTextComposition() {
clear(r.compositionEvents)
r.compositionEvents = r.compositionEvents[:0]
}
func SubmitTextComposition(phase KryTextCompositionPhase, text string, cursor, selectionLength int32) int32 {
return active().SubmitTextComposition(phase, text, cursor, selectionLength)
}
func PollTextComposition(event *KryTextCompositionEvent) int32 {
return active().PollTextComposition(event)
}
func ClearTextComposition() { active().ClearTextComposition() }
func (r *runtime) editComposition(id int32, text string, pos int, sel selection, limit int) (string, int, selection, bool) {
changed := false
var event KryTextCompositionEvent
for r.PollTextComposition(&event) != 0 {
switch event.Phase {
case KRY_TEXT_COMPOSITION_START, KRY_TEXT_COMPOSITION_UPDATE:
if r.preedit == nil {
r.preedit = make(map[int32]KryTextCompositionEvent)
}
r.preedit[id] = event
case KRY_TEXT_COMPOSITION_COMMIT:
var inserted bool
text, pos, inserted = insertText(text, pos, sel, event.Text, limit)
if inserted {
changed = true
sel = selection{Anchor: pos, Cursor: pos}
}
delete(r.preedit, id)
case KRY_TEXT_COMPOSITION_CANCEL:
delete(r.preedit, id)
}
}
return text, pos, sel, changed
}
+164
View File
@@ -0,0 +1,164 @@
package kryon
import (
"bytes"
"strings"
"testing"
)
func TestCompositionQueueOwnership(t *testing.T) {
r := New(AppConfig{}).(*runtime)
other := New(AppConfig{}).(*runtime)
if r.SubmitTextComposition(0, "invalid", 0, 0) != 0 {
t.Fatal("invalid phase accepted")
}
for i := 0; i < 16; i++ {
if r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, strings.Repeat("x", 300), -1, -1) != 1 {
t.Fatal("queue filled early")
}
}
if r.SubmitTextComposition(KRY_TEXT_COMPOSITION_CANCEL, "", 0, 0) != 0 {
t.Fatal("queue overflow accepted")
}
var event KryTextCompositionEvent
if other.PollTextComposition(&event) != 0 || r.PollTextComposition(nil) != 0 {
t.Fatal("queue ownership or nil polling")
}
if r.PollTextComposition(&event) != 1 || len(event.Text) != 255 || event.Cursor != 0 || event.SelectionLength != 0 {
t.Fatalf("bad event: %+v", event)
}
r.ClearTextComposition()
if r.PollTextComposition(&event) != 0 {
t.Fatal("clear retained events")
}
}
func compositionEditor(r *runtime, area bool, text []byte, cursor *int32) {
if area {
r.TextArea(TextAreaProps{Bounds: NewRectangle(10, 10, 120, 80), Text: text, CursorPosition: cursor, FocusID: 26100})
} else {
r.TextField(TextFieldProps{Bounds: NewRectangle(10, 10, 120, 28), Text: text, CursorPosition: cursor, FocusID: 26100})
}
}
func TestCompositionPreeditCommitAndCancel(t *testing.T) {
for _, area := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
text := make([]byte, 32)
copy(text, "a")
cursor := int32(1)
r.setFocus(26100)
for frame := 0; frame < 5; frame++ {
switch frame {
case 0:
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "ni", 2, 0)
case 2:
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_COMMIT, "日", 1, 0)
case 3:
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "cancel", 6, 0)
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_CANCEL, "", 0, 0)
case 4:
r.setFocus(999)
}
r.BeginFrame()
compositionEditor(r, area, text, &cursor)
r.EndFrame()
want, display := "a", "ani"
if frame >= 2 {
want, display = "a日", "a日"
}
if got := string(text[:zeroIndex(text)]); got != want {
t.Fatalf("area=%v frame=%d buffer=%q want=%q", area, frame, got, want)
}
if got := r.FrameOps()[0].Text; got != display {
t.Fatalf("area=%v frame=%d display=%q want=%q", area, frame, got, display)
}
if frame == 0 {
withPreedit := RenderFrame(160, 120, r.FrameOps())
plain := append([]FrameOp(nil), r.FrameOps()...)
plain[0].Text = want
withoutPreedit := RenderFrame(160, 120, plain)
if bytes.Equal(withPreedit.Pix, withoutPreedit.Pix) {
t.Fatalf("area=%v: renderer omitted preedit", area)
}
}
if frame >= 2 && cursor != 4 {
t.Fatalf("commit cursor=%d want UTF-8 byte offset 4", cursor)
}
}
}
}
func TestPopupCompositionDismissalDoesNotReplay(t *testing.T) {
for _, area := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
text := make([]byte, 32)
copy(text, "a")
cursor := int32(1)
for frame := 0; frame < 3; frame++ {
if frame != 1 {
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "ni", 2, 0)
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_COMMIT, "x", 1, 0)
}
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(10, 10, 120, 120))
if frame == 0 {
child := r.beginPopupInput(1, NewRectangle(20, 20, 60, 60))
r.endPopupInput(child)
} else {
r.closePopupInput(1)
}
r.setFocus(26100)
compositionEditor(r, area, text, &cursor)
r.endPopupInput(parent)
r.EndFrame()
want := "a"
if frame == 2 {
want = "ax"
}
if got := string(text[:zeroIndex(text)]); got != want {
t.Fatalf("area=%v frame=%d buffer=%q want=%q", area, frame, got, want)
}
}
}
}
func TestCompositionPreeditRetiresWithEditor(t *testing.T) {
for _, cause := range []string{"missing", "focus", "disabled", "popup"} {
r := New(AppConfig{}).(*runtime)
text := make([]byte, 16)
copy(text, "a")
cursor := int32(1)
r.setFocus(26100)
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "ni", 2, 0)
r.BeginFrame()
compositionEditor(r, false, text, &cursor)
r.EndFrame()
r.BeginFrame()
switch cause {
case "focus":
r.setFocus(999)
compositionEditor(r, false, text, &cursor)
case "disabled":
r.BeginDisabled(true)
compositionEditor(r, false, text, &cursor)
r.EndDisabled()
case "popup":
popup := r.beginPopupInput(1, NewRectangle(20, 20, 60, 60))
r.endPopupInput(popup)
compositionEditor(r, false, text, &cursor)
}
r.EndFrame()
if len(r.preedit) != 0 {
t.Fatalf("%s editor retained preedit", cause)
}
r.closePopupInput(1)
r.setFocus(26100)
r.BeginFrame()
compositionEditor(r, false, text, &cursor)
r.EndFrame()
if r.FrameOps()[0].Text != "a" {
t.Fatalf("%s editor revived preedit", cause)
}
}
}
+43
View File
@@ -4,6 +4,8 @@ import (
"image"
"image/color"
"image/draw"
"os"
"path/filepath"
"strings"
"sync"
@@ -29,6 +31,47 @@ var (
activeUIFontName string
)
const defaultUIFontName = "kryon-default"
// ensureDefaultUIFont gives every native Go host the same default UI face as
// the C runtime. Applications can still replace it with RegisterUIFontData and
// UseUIFont; failure to resolve a packaged/system font keeps the small built-in
// renderer fallback available for minimal environments.
func ensureDefaultUIFont() {
fontMu.Lock()
if activeUIFontName != "" {
fontMu.Unlock()
return
}
fontMu.Unlock()
paths := []string{
"fonts/noto/NotoSans-Regular.ttf",
"../fonts/noto/NotoSans-Regular.ttf",
"../../fonts/noto/NotoSans-Regular.ttf",
"vendor/kryon/fonts/noto/NotoSans-Regular.ttf",
"/usr/local/share/fonts/noto/NotoSans-Regular.ttf",
"/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf",
}
if executable, err := os.Executable(); err == nil {
dir := filepath.Dir(executable)
paths = append([]string{
filepath.Join(dir, "fonts", "noto", "NotoSans-Regular.ttf"),
filepath.Join(dir, "..", "share", "kryon", "fonts", "noto", "NotoSans-Regular.ttf"),
}, paths...)
}
for _, path := range paths {
data, err := os.ReadFile(path)
if err != nil {
continue
}
if _, ok := registerFontData(defaultUIFontName, ".ttf", data); ok {
useUIFont(defaultUIFontName)
return
}
}
}
func registerFontData(name, typ string, data []byte) (uint32, bool) {
if len(data) == 0 {
return 0, false
+26
View File
@@ -0,0 +1,26 @@
package kryon
import "testing"
func TestNewRuntimeResolvesKryonDefaultUIFont(t *testing.T) {
fontMu.Lock()
previous := activeUIFontName
activeUIFontName = ""
fontMu.Unlock()
defer func() {
fontMu.Lock()
activeUIFontName = previous
fontMu.Unlock()
}()
_ = New(AppConfig{Width: 64, Height: 64})
fontMu.Lock()
active := activeUIFontName
fontMu.Unlock()
if active != defaultUIFontName {
t.Fatalf("default UI font = %q, want %q", active, defaultUIFontName)
}
if faceForFont(0, Text16) == nil {
t.Fatal("default UI font did not produce a native Go face")
}
}
+1
View File
@@ -50,6 +50,7 @@ type FrameOp struct {
Pressed bool
Disabled bool
Secure bool
ReadOnly bool
Row int32
Column int32
Selected bool
+2 -2
View File
@@ -15,7 +15,7 @@ func TestHostFrameQueuesInputAndRenders(t *testing.T) {
Padding: 4,
Key: Key("host-test"),
})
Text("Host", 0, 0, Text16, BLACK)
Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "Host", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
TextField("Name", &value)
Button("Save")
End()
@@ -63,7 +63,7 @@ func TestHostRestoresActiveRuntime(t *testing.T) {
host := NewHost(AppConfig{Width: 120, Height: 90})
host.Frame(func() {
BeginFrame()
Text("host", 4, 4, Text16, BLACK)
Text(TextProps{Bounds: NewRectangle(4, 4, 0, 0), Text: "host", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
EndFrame()
})
+883 -23
View File
@@ -170,6 +170,40 @@ func TestTreeHeaderModes(t *testing.T) {
}
}
func TestCloseableCollapsible(t *testing.T) {
r := New(AppConfig{}).(*runtime)
open, visible := false, true
p := CollapsibleProps{Bounds: NewRectangle(10, 10, 180, 32), Label: "A label long enough to need clipping", Open: &open, Visible: &visible, ID: 9961}
r.QueueTap(180, 20)
r.BeginFrame()
changed := r.Collapsible(p)
r.EndFrame()
if changed != 1 || visible || open {
t.Fatalf("close changed=%d visible=%v open=%v", changed, visible, open)
}
ops := r.FrameOps()
if len(ops) != 2 || ops[0].Kind != FrameOpButton || ops[1].Kind != FrameOpText || ops[1].Text != "×" || !ops[1].Pressed {
t.Fatalf("closeable collapsible ops: %+v", ops)
}
r.QueueTap(20, 20)
r.BeginFrame()
if r.Collapsible(p) != 0 || len(r.FrameOps()) != 0 || open {
t.Fatal("hidden collapsible emitted output or accepted input")
}
r.EndFrame()
visible = true
p.Disabled = true
r.QueueTap(180, 20)
r.BeginFrame()
changed = r.Collapsible(p)
r.EndFrame()
if changed != 0 || !visible || !r.FrameOps()[1].Disabled {
t.Fatal("disabled collapsible close was active")
}
}
func TestTreeHeaderKeyboardGates(t *testing.T) {
r := New(AppConfig{}).(*runtime)
open := false
@@ -404,26 +438,67 @@ func TestListBoxScope(t *testing.T) {
r.EndFrame()
}
func TestNativeTextHelpers(t *testing.T) {
func TestListBoxKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 200, Height: 120}).(*runtime)
selected, offset := int32(0), int32(0)
props := ListBoxProps{
Bounds: NewRectangle(20, 20, 120, 48), ID: 26130,
Items: []string{"0", "1", "2", "3", "4", "5", "6", "7"},
SelectedIndex: &selected, ScrollOffset: &offset, RowHeight: 24,
}
for _, step := range []struct {
key, selected, offset int32
}{{KeyEnd, 7, 144}, {KeyUp, 6, 144}, {KeyHome, 0, 0}} {
r.SetFocus(props.ID)
r.QueueKey(step.key)
r.BeginFrame()
if changed := r.ListBox(props); changed != 1 {
t.Fatalf("key %d changed=%d, want 1", step.key, changed)
}
r.EndFrame()
if selected != step.selected || offset != step.offset {
t.Fatalf("key %d selected=%d offset=%d, want %d,%d", step.key, selected, offset, step.selected, step.offset)
}
}
if ops := r.FrameOps(); len(ops) == 0 || !ops[0].Focused {
t.Fatal("focused list did not emit a focus presentation")
}
props.Disabled = true
r.QueueKey(KeyEnd)
r.BeginFrame()
if changed := r.ListBox(props); changed != 0 || selected != 0 || offset != 0 {
t.Fatalf("disabled list changed=%d selected=%d offset=%d", changed, selected, offset)
}
r.EndFrame()
props.Disabled = false
selected = -1
r.BeginFrame()
if changed := r.ListBox(props); changed != 0 || selected != -1 {
t.Fatalf("idle list changed=%d selected=%d, want 0,-1", changed, selected)
}
r.EndFrame()
}
func TestCanonicalTextProperties(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 240}).(*runtime)
color := Color{R: 20, G: 40, B: 60, A: 255}
r.BeginFrame()
r.TextColored("colored", 10, 10, Text16, color)
r.TextDisabled("disabled", 10, 30, Text16)
r.TextWrapped("one two three four", NewRectangle(10, 50, 48, 60), Text16, color)
r.Text(TextProps{Bounds: NewRectangle(10, 10, 0, 0), Text: "colored", Font: Text16, Color: color, Wrap: TextWrapNone})
r.Text(TextProps{Bounds: NewRectangle(10, 30, 0, 0), Text: "disabled", Font: Text16, Wrap: TextWrapNone, Disabled: true})
r.Text(TextProps{Bounds: NewRectangle(10, 50, 48, 60), Text: "one two three four", Font: Text16, Color: color})
r.LabelText("Status", "Ready", NewRectangle(10, 120, 160, 20), Text16, color)
r.BulletText("item", NewRectangle(10, 150, 120, 20), Text16, color)
r.EndFrame()
ops := r.FrameOps()
if len(ops) < 8 {
t.Fatalf("text helper ops=%d, want at least 8", len(ops))
t.Fatalf("text ops=%d, want at least 8", len(ops))
}
if ops[0].Text != "colored" || ops[0].Color != color {
t.Fatalf("TextColored op=%+v", ops[0])
t.Fatalf("colored Text op=%+v", ops[0])
}
if ops[1].Text != "disabled" || ops[1].Color.A >= 255 {
t.Fatalf("TextDisabled op=%+v", ops[1])
t.Fatalf("disabled Text op=%+v", ops[1])
}
wrapped := 0
for _, op := range ops {
@@ -432,7 +507,12 @@ func TestNativeTextHelpers(t *testing.T) {
}
}
if wrapped < 2 {
t.Fatalf("TextWrapped emitted %d wrapped lines", wrapped)
t.Fatalf("bounded Text emitted %d wrapped lines", wrapped)
}
for _, op := range ops[2 : 2+wrapped] {
if !op.HasClip || op.Clip != NewRectangle(10, 50, 48, 60) {
t.Fatalf("bounded Text clip=%+v", op)
}
}
}
@@ -501,26 +581,99 @@ func TestNativePopupAndContextMenus(t *testing.T) {
r.EndFrame()
}
func TestNativeTooltip(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 160}).(*runtime)
props := TooltipProps{Trigger: NewRectangle(20, 20, 80, 30), Text: "A tooltip with wrapped help text", Font: Text14, MaxWidth: 90}
r.QueueMouseMove(40, 30)
r.BeginFrame()
if !r.Tooltip(props) {
t.Fatal("Tooltip should be visible over its trigger")
func TestMenuKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
child := []MenuItem{{Kind: MenuCommand, Label: "Child", ID: 23}}
file := []MenuItem{
{Kind: MenuCommand, Label: "Open", ID: 21},
{Kind: MenuSeparator},
{Kind: MenuCommand, Label: "Disabled", ID: 22, Disabled: true},
{Kind: MenuSubmenu, Label: "More", ID: 24, Submenu: child, SubmenuCount: 1},
}
ops := r.FrameOps()
if len(ops) < 4 || ops[0].Kind != FrameOpRect || ops[1].Kind != FrameOpRect {
t.Fatalf("Tooltip ops=%+v", ops)
edit := []MenuItem{{Kind: MenuCommand, Label: "Copy", ID: 31}}
menus := []Menu{{Label: "File", Items: file, ItemCount: int32(len(file))}, {Label: "Edit", Items: edit, ItemCount: 1}}
open := int32(-1)
draw := func(key int32) MenuBarResult {
r.QueueKey(key)
r.BeginFrame()
result := r.MenuBar(300, NewRectangle(0, 0, 360, 30), menus, &open)
r.EndFrame()
return result
}
r.EndFrame()
r.QueueMouseMove(180, 120)
r.BeginFrame()
if r.Tooltip(props) || len(r.FrameOps()) != 0 {
t.Fatal("Tooltip rendered outside its trigger")
r.SetFocus(300)
if got := draw(KeyDown); got.OpenIndex != 0 || open != 0 {
t.Fatalf("Down opens focused menu: result=%+v open=%d", got, open)
}
if got := draw(KeyEnd); got.ActivatedID != 0 {
t.Fatalf("End activated menu item: %+v", got)
}
if got := draw(KeyRight); got.ActivatedID != 0 {
t.Fatalf("Right activated submenu: %+v", got)
}
if got := draw(KeyEnter); got.ActivatedID != 23 || open != -1 {
t.Fatalf("submenu Enter result=%+v open=%d, want 23/-1", got, open)
}
r.SetFocus(300)
draw(KeyRight)
if got := draw(KeyDown); got.OpenIndex != 1 || open != 1 {
t.Fatalf("Right then Down opens next menu: result=%+v open=%d", got, open)
}
if got := draw(KeyEnter); got.ActivatedID != 31 || open != -1 {
t.Fatalf("second menu Enter result=%+v open=%d, want 31/-1", got, open)
}
r.SetFocus(300)
draw(KeyDown)
draw(KeyEscape)
if open != -1 {
t.Fatalf("Escape left menu open at %d", open)
}
}
func TestContextMenuKeyboardNavigationAndOwnership(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
items := []MenuItem{
{Kind: MenuCommand, Label: "Disabled", ID: 41, Disabled: true},
{Kind: MenuSeparator},
{Kind: MenuCommand, Label: "Run", ID: 42},
}
open, x, y := int32(0), int32(20), int32(20)
props := ContextMenuProps{ID: 400, Trigger: NewRectangle(10, 10, 100, 50), Items: items, ItemCount: int32(len(items)), Open: &open, X: &x, Y: &y}
r.QueueMouseButtonUp(MouseButtonRight, 20, 20)
r.BeginFrame()
r.ContextMenu(props)
r.EndFrame()
if open != 1 || r.Focus() != 400 {
t.Fatalf("context open/focus=%d/%d, want 1/400", open, r.Focus())
}
r.QueueKey(KeyEnter)
r.BeginFrame()
got := r.ContextMenu(props)
r.EndFrame()
if got != 42 || open != 0 {
t.Fatalf("context Enter=%d open=%d, want 42/0", got, open)
}
open = 1
r.SetFocus(999)
r.QueueKey(KeyEnter)
r.BeginFrame()
got = r.ContextMenu(props)
r.EndFrame()
if got != 0 || open != 1 {
t.Fatalf("unfocused context consumed Enter: got=%d open=%d", got, open)
}
r.SetFocus(400)
r.QueueKey(KeyEscape)
r.BeginFrame()
r.ContextMenu(props)
r.EndFrame()
if open != 0 {
t.Fatalf("Escape left context menu open")
}
}
func TestCollapsibleComposesInteractiveChildren(t *testing.T) {
@@ -851,6 +1004,177 @@ func TestNativeDragScalars(t *testing.T) {
r.EndFrame()
}
func TestNumericDragAndSliderCtrlClickEditing(t *testing.T) {
r := New(AppConfig{Width: 480, Height: 240}).(*runtime)
floats := []float32{2.5}
drag := DragFloatProps{Bounds: NewRectangle(10, 10, 120, 30), ID: 520,
Values: floats, ValueCount: 1, Speed: 0.1, Min: 0, Max: 10}
r.QueueKey(KeyLeftControl)
r.QueueTap(40, 20)
r.BeginFrame()
if r.DragFloat(drag) || floats[0] != 2.5 {
t.Fatalf("Ctrl-click changed drag value before editing: %v", floats)
}
r.EndFrame()
foundEditor := false
for _, op := range r.FrameOps() {
if op.Kind == FrameOpTextField && op.FocusID == 520 && op.Focused {
foundEditor = true
}
}
if !foundEditor {
t.Fatal("Ctrl-click did not replace drag cell with a focused editor")
}
r.QueueShortcut(KeyA)
r.QueueText("7.25")
r.BeginFrame()
if !r.DragFloat(drag) || floats[0] != 7.25 {
t.Fatalf("edited drag value=%v, want 7.25", floats)
}
r.EndFrame()
r.QueueKey(KeyEnter)
r.BeginFrame()
r.DragFloat(drag)
r.EndFrame()
if r.numericInputs[numericInputKey{kind: numericEditDragFloat, widgetID: 520}].focused {
t.Fatal("Enter did not finish drag keyboard entry")
}
ints := []int32{4}
slider := SliderIntProps{Bounds: NewRectangle(10, 60, 120, 30), ID: 521,
Values: ints, ValueCount: 1, Min: 0, Max: 10}
r.QueueKey(KeyLeftControl)
r.QueueTap(40, 70)
r.BeginFrame()
r.SliderInt(slider)
r.EndFrame()
r.QueueShortcut(KeyA)
r.QueueText("19")
r.BeginFrame()
if !r.SliderInt(slider) || ints[0] != 19 {
t.Fatalf("temporary slider input should be unclamped: %v", ints)
}
r.EndFrame()
disabled := []int32{3}
r.QueueKey(KeyLeftControl)
r.QueueTap(40, 110)
r.BeginFrame()
r.DragInt(DragIntProps{Bounds: NewRectangle(10, 100, 120, 30), ID: 522,
Values: disabled, ValueCount: 1, Min: 0, Max: 10, Disabled: true})
r.EndFrame()
state := r.numericInputs[numericInputKey{kind: numericEditDragInt, widgetID: 522}]
if state != nil && state.focused {
t.Fatal("disabled drag accepted Ctrl-click keyboard entry")
}
}
func TestNativeDragKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 480, Height: 240}).(*runtime)
floats := []float32{2, 5}
ints := []int32{2, 5}
floatProps := DragFloatProps{Bounds: NewRectangle(10, 10, 200, 30), ID: 70, Values: floats, ValueCount: 2, Speed: 0.25, Min: 0, Max: 10}
intProps := DragIntProps{Bounds: NewRectangle(10, 50, 200, 30), ID: 71, Values: ints, ValueCount: 2, Speed: 2, Min: 0, Max: 10}
draw := func() {
r.BeginFrame()
r.DragFloat(floatProps)
r.DragInt(intProps)
r.EndFrame()
}
draw()
r.SetFocus(70)
r.QueueKey(KeyRight)
draw()
if floats[0] != 2.25 {
t.Fatalf("DragFloat Right=%v, want 2.25", floats[0])
}
foundFocus := false
for _, op := range r.ops {
if op.ID == 70 && op.Row == 0 && op.Focused && op.BorderColor == r.theme().focus {
foundFocus = true
}
}
if !foundFocus {
t.Fatal("focused drag component lacks focus presentation")
}
r.QueueShiftKey(KeyRight)
draw()
if floats[0] != 4.75 {
t.Fatalf("DragFloat Shift+Right=%v, want 4.75", floats[0])
}
r.QueueKey(KeyTab)
draw()
if r.Focus() == 70 {
t.Fatal("DragFloat Tab did not reach second component")
}
r.QueueKey(KeyHome)
draw()
if floats[1] != 0 {
t.Fatalf("DragFloat Home=%v, want 0", floats[1])
}
r.SetFocus(71)
r.QueueKey(KeyRight)
draw()
if ints[0] != 4 {
t.Fatalf("DragInt Right=%d, want 4", ints[0])
}
r.QueueKey(KeyTab)
draw()
r.QueueKey(KeyLeft)
draw()
if ints[1] != 3 {
t.Fatalf("DragInt second Left=%d, want 3", ints[1])
}
floatMin, floatMax := float32(2), float32(8)
intMin, intMax := int32(2), int32(8)
floatRange := DragFloatRange2Props{Bounds: NewRectangle(240, 10, 200, 30), ID: 72, CurrentMin: &floatMin, CurrentMax: &floatMax, Speed: 1, Min: 0, Max: 10}
intRange := DragIntRange2Props{Bounds: NewRectangle(240, 50, 200, 30), ID: 73, CurrentMin: &intMin, CurrentMax: &intMax, Speed: 2, Min: 0, Max: 10}
drawRanges := func(disabled bool) {
r.BeginFrame()
r.BeginDisabled(disabled)
r.DragFloatRange2(floatRange)
r.DragIntRange2(intRange)
r.EndDisabled()
r.EndFrame()
}
drawRanges(false)
r.SetFocus(72)
r.QueueKey(KeyRight)
drawRanges(false)
if floatMin != 3 {
t.Fatalf("DragFloatRange2 min Right=%v, want 3", floatMin)
}
r.QueueKey(KeyTab)
drawRanges(false)
r.QueueKey(KeyLeft)
drawRanges(false)
if floatMax != 7 {
t.Fatalf("DragFloatRange2 max Left=%v, want 7", floatMax)
}
r.SetFocus(73)
r.QueueKey(KeyRight)
drawRanges(false)
if intMin != 4 {
t.Fatalf("DragIntRange2 min Right=%d, want 4", intMin)
}
r.QueueKey(KeyTab)
drawRanges(false)
r.QueueKey(KeyLeft)
drawRanges(false)
if intMax != 6 {
t.Fatalf("DragIntRange2 max Left=%d, want 6", intMax)
}
r.SetFocus(72)
r.QueueKey(KeyRight)
drawRanges(true)
if floatMin != 3 {
t.Fatalf("disabled DragFloatRange2 changed min to %v", floatMin)
}
}
func TestNativeSliders(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
floats := []float32{0, 2}
@@ -886,6 +1210,88 @@ func TestNativeSliders(t *testing.T) {
r.EndFrame()
}
func TestNativeSliderKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
floats := []float32{0.25, 0.75}
floatProps := SliderFloatProps{Bounds: NewRectangle(10, 10, 200, 30), ID: 600,
Values: floats, ValueCount: 2, Min: 0, Max: 1}
r.BeginFrame()
r.SliderFloat(floatProps)
r.EndFrame()
r.SetFocus(600)
r.QueueKey(KeyRight)
r.BeginFrame()
if !r.SliderFloat(floatProps) || floats[0] < 0.2599 || floats[0] > 0.2601 {
t.Fatalf("horizontal slider Right values=%v, want first value 0.26", floats)
}
r.EndFrame()
focusedPaint := false
for _, op := range r.FrameOps() {
if op.Kind == FrameOpRect && op.ID == 600 && op.Row == 0 && op.Focused && op.BorderColor == r.theme().focus {
focusedPaint = true
}
}
if !focusedPaint {
t.Fatal("focused slider component lacks focus paint")
}
r.QueueShiftKey(KeyRight)
r.BeginFrame()
r.SliderFloat(floatProps)
r.EndFrame()
if floats[0] < 0.3599 || floats[0] > 0.3601 {
t.Fatalf("Shift slider value=%v, want 0.36", floats[0])
}
r.QueueKey(KeyLeftAlt)
r.QueueKey(KeyRight)
r.BeginFrame()
r.SliderFloat(floatProps)
r.EndFrame()
if floats[0] < 0.3609 || floats[0] > 0.3611 {
t.Fatalf("Alt slider value=%v, want 0.361", floats[0])
}
r.QueueKey(KeyTab)
r.BeginFrame()
r.SliderFloat(floatProps)
r.EndFrame()
secondFocus := sliderFocusID(600, 1, false)
if r.Focus() != secondFocus {
t.Fatalf("slider component Tab focus=%d, want %d", r.Focus(), secondFocus)
}
r.QueueKey(KeyLeft)
r.BeginFrame()
if !r.SliderFloat(floatProps) || floats[1] < 0.7399 || floats[1] > 0.7401 {
t.Fatalf("second slider component Left values=%v, want second value 0.74", floats)
}
r.EndFrame()
ints := []int32{5}
intProps := SliderIntProps{Bounds: NewRectangle(10, 60, 30, 120), ID: 601,
Values: ints, ValueCount: 1, Min: 0, Max: 10}
r.SetFocus(601)
for _, step := range []struct {
key int32
want int32
}{{KeyUp, 6}, {KeyDown, 5}, {KeyHome, 0}, {KeyEnd, 10}} {
r.QueueKey(step.key)
r.BeginFrame()
if !r.VSliderInt(intProps) || ints[0] != step.want {
t.Fatalf("vertical slider key %d value=%d, want %d", step.key, ints[0], step.want)
}
r.EndFrame()
}
intProps.Disabled = true
r.SetFocus(601)
r.QueueKey(KeyLeft)
r.BeginFrame()
if r.VSliderInt(intProps) || ints[0] != 10 {
t.Fatalf("disabled slider accepted keyboard input: value=%d", ints[0])
}
r.EndFrame()
}
func TestNativeDragRangesKeepOrderedEndpoints(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
floatMin, floatMax := float32(2), float32(4)
@@ -943,6 +1349,14 @@ func TestNativeNumericInputs(t *testing.T) {
t.Fatalf("InputInt step value=%d, want 6", ints[0])
}
r.EndFrame()
state := r.numericInputState(numericInputKey{kind: 1, widgetID: 71, component: 0}, "6")
r.SetFocus(state.token + 2)
r.QueueKey(KeySpace)
r.BeginFrame()
if !r.InputInt(intProps) || ints[0] != 8 {
t.Fatalf("InputInt keyboard step value=%d, want 8", ints[0])
}
r.EndFrame()
doubles := []float64{1}
doubleProps := InputDoubleProps{Bounds: NewRectangle(10, 90, 200, 30), ID: 72, Values: doubles}
@@ -959,6 +1373,49 @@ func TestNativeNumericInputs(t *testing.T) {
r.EndFrame()
}
func TestNativeSpinboxUsesButtonInteraction(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 120}).(*runtime)
value := int32(2)
props := SpinboxProps{Bounds: NewRectangle(10, 10, 120, 30), ID: 73,
Min: 0, Max: 4, Step: 1, Value: &value}
draw := func(disabled bool) bool {
r.BeginFrame()
r.BeginDisabled(disabled)
changed := r.Spinbox(props)
r.EndDisabled()
r.Button(ButtonProps{Bounds: NewRectangle(10, 54, 80, 28), ID: 74, Label: "Next"})
r.EndFrame()
return changed
}
draw(false)
r.SetFocus(props.ID*10 + 2)
r.QueueKey(KeyEnter)
if !draw(false) || value != 3 {
t.Fatalf("Spinbox keyboard value=%d, want 3", value)
}
focused := false
for _, op := range r.FrameOps() {
if op.ID == props.ID*10+2 && op.Focused {
focused = true
}
}
if !focused {
t.Fatal("Spinbox increment button lacks focus presentation")
}
r.QueueKey(KeySpace)
if draw(true) || value != 3 {
t.Fatalf("disabled Spinbox changed value=%d", value)
}
draw(false)
r.SetFocus(props.ID*10 + 1)
r.QueueKey(KeyTab)
draw(false)
if r.Focus() != props.ID*10+2 {
t.Fatalf("Spinbox Tab focus=%d, want %d", r.Focus(), props.ID*10+2)
}
}
func TestNativeBasicImGuiWidgets(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
r.QueueTap(20, 20)
@@ -1032,6 +1489,129 @@ func TestNativeSelectionAndImageWidgets(t *testing.T) {
r.EndFrame()
}
func TestFocusableChoiceAndImageWidgets(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
checkbox, selected, flags := int32(0), int32(0), int32(0)
picture := PictureProps{AssetPath: "tile.png", Bounds: NewRectangle(10, 170, 48, 32), Tint: White, Fit: PictureFitContain}
activations := make(map[int32]int)
draw := func(disableFlags bool) {
r.BeginFrame()
if r.Checkbox(900, 10, 10, "Check", &checkbox) {
activations[900]++
}
if r.Selectable(SelectableProps{Bounds: NewRectangle(10, 50, 140, 28), ID: 901, Label: "Choice", Selected: &selected}) {
activations[901]++
}
r.BeginDisabled(disableFlags)
if r.CheckboxFlags(CheckboxFlagsProps{Bounds: NewRectangle(10, 90, 140, 28), ID: 902, Label: "Flag", Flags: &flags, FlagsValue: 4}) {
activations[902]++
}
r.EndDisabled()
if got := r.Radio(RadioButtonProps{Bounds: NewRectangle(10, 130, 140, 28), ID: 903, Label: "Radio"}); got != 0 {
activations[got]++
}
if r.ImageButton(ImageButtonProps{Picture: picture, Background: Black, ID: 904}) {
activations[904]++
}
if r.InvisibleButton(InvisibleButtonProps{Bounds: NewRectangle(70, 170, 48, 32), ID: 905}) {
activations[905]++
}
if r.ColorButton(ColorButtonProps{Bounds: NewRectangle(10, 220, 100, 32), ID: 906, Label: "Color", Color: Color{R: 255, A: 255}}) {
activations[906]++
}
r.EndFrame()
}
draw(false)
for _, tc := range []struct {
id int32
key int32
}{
{900, KeySpace}, {901, KeyEnter}, {902, KeySpace},
{903, KeyEnter}, {904, KeySpace}, {905, KeyEnter}, {906, KeySpace},
} {
r.SetFocus(tc.id)
r.QueueKey(tc.key)
draw(false)
if activations[tc.id] != 1 {
t.Fatalf("widget %d keyboard activations=%d, want 1", tc.id, activations[tc.id])
}
}
if checkbox != 1 || selected != 1 || flags != 4 {
t.Fatalf("choice state checkbox=%d selected=%d flags=%d", checkbox, selected, flags)
}
r.SetFocus(901)
r.QueueKey(KeyTab)
draw(false)
if r.Focus() != 902 {
t.Fatalf("choice Tab focus=%d, want 902", r.Focus())
}
r.SetFocus(902)
r.QueueKey(KeySpace)
draw(true)
if flags != 4 || activations[902] != 1 {
t.Fatal("disabled choice accepted keyboard activation")
}
r.SetFocus(901)
draw(false)
focused := false
for _, op := range r.FrameOps() {
if op.ID == 901 && op.Focused {
focused = true
}
}
if !focused {
t.Fatal("focused selectable has no focus presentation")
}
}
func TestToggleKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 120}).(*runtime)
value := int32(0)
draw := func(disabled bool) bool {
r.BeginFrame()
r.BeginDisabled(disabled)
activated := r.Toggle(907, 10, 10, 120, 34, &value, "Off", "On")
r.EndDisabled()
r.Button(ButtonProps{Bounds: NewRectangle(10, 54, 80, 28), ID: 908, Label: "Next"})
r.EndFrame()
return activated
}
draw(false)
r.SetFocus(907)
r.QueueKey(KeySpace)
activated := draw(false)
if !activated || value != 1 {
t.Fatalf("toggle Space activation/state = %v/%d, want true/1", activated, value)
}
focused := false
for _, op := range r.FrameOps() {
if op.ID == 907 && op.Focused && op.BorderColor == r.theme().focus {
focused = true
}
}
if !focused {
t.Fatal("focused toggle has no focus presentation")
}
r.SetFocus(907)
r.QueueKey(KeyTab)
draw(false)
if r.Focus() != 908 {
t.Fatalf("toggle Tab focus=%d, want 908", r.Focus())
}
r.SetFocus(907)
r.QueueKey(KeyEnter)
if draw(true) || value != 1 {
t.Fatalf("disabled toggle activation/state = true/%d, want false/1", value)
}
}
func TestNativeSeparatorText(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 200}).(*runtime)
r.BeginFrame()
@@ -1073,6 +1653,222 @@ func TestNativeTabItemControls(t *testing.T) {
r.EndFrame()
}
func TestNativeTabBarKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 360, Height: 180}).(*runtime)
tabs := []Tab{{Label: "One"}, {Label: "Disabled", Disabled: true}, {Label: "Three", Closeable: true}}
selected, closed := int32(0), int32(-1)
props := TabBarProps{Bounds: NewRectangle(10, 10, 300, 32), Tabs: tabs, Count: 3,
SelectedIndex: selected, ClosedIndex: &closed, ID: 920}
draw := func(disabled bool) int32 {
props.SelectedIndex = selected
r.BeginFrame()
r.BeginDisabled(disabled)
clicked := r.TabBar(props)
r.EndDisabled()
r.Button(ButtonProps{Bounds: NewRectangle(10, 54, 80, 28), ID: 921, Label: "Next"})
r.EndFrame()
if clicked >= 0 {
selected = clicked
}
return clicked
}
draw(false)
r.SetFocus(props.ID)
r.QueueKey(KeyRight)
if clicked := draw(false); clicked != 2 || selected != 2 {
t.Fatalf("Right did not skip disabled tab: clicked=%d selected=%d", clicked, selected)
}
r.QueueKey(KeyDelete)
if clicked := draw(false); clicked != -1 || closed != 2 {
t.Fatalf("Delete close result clicked=%d closed=%d", clicked, closed)
}
r.QueueKey(KeyHome)
if clicked := draw(false); clicked != 0 || selected != 0 {
t.Fatalf("Home result clicked=%d selected=%d", clicked, selected)
}
focused := false
for _, op := range r.FrameOps() {
if op.ID == props.ID && op.Row == 0 && op.Focused && op.BorderColor == r.theme().focus {
focused = true
}
}
if !focused {
t.Fatal("selected tab lacks focus presentation")
}
r.QueueKey(KeyRight)
if clicked := draw(true); clicked != -1 || selected != 0 {
t.Fatalf("disabled tab bar changed selection: clicked=%d selected=%d", clicked, selected)
}
r.SetFocus(props.ID)
r.QueueKey(KeyTab)
draw(false)
if r.Focus() != 921 {
t.Fatalf("Tab focus=%d, want 921", r.Focus())
}
}
func TestNativeTabBarRichSignals(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 120}).(*runtime)
tabs := []Tab{{Label: "Alpha"}, {Label: "Beta"}, {Label: "Gamma"}}
scroll := int32(0)
selectedBounds := Rectangle{}
doubleClicked, middleClicked := int32(-1), int32(-1)
props := TabBarProps{Bounds: NewRectangle(10, 10, 180, 30), Tabs: tabs, Count: 3,
SelectedIndex: 2, MinTabWidth: 100, MaxTabWidth: 100, ScrollOffset: &scroll,
FocusSelected: true, DoubleClickedIndex: &doubleClicked,
SelectedTabBounds: &selectedBounds, MiddleClickedIndex: &middleClicked, ID: 922}
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
if scroll <= 0 || selectedBounds.X+selectedBounds.Width > props.Bounds.X+props.Bounds.Width+1 {
t.Fatalf("selected tab was not revealed: scroll=%d bounds=%+v", scroll, selectedBounds)
}
props.FocusSelected = false
props.SelectedIndex = 0
scroll = 0
r.QueueTap(30, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
r.QueueTap(30, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
if doubleClicked != 0 {
t.Fatalf("double-click index=%d, want 0", doubleClicked)
}
r.QueueMouseButton(MouseButtonMiddle, 130, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
if middleClicked != 1 {
t.Fatalf("middle-click index=%d, want 1", middleClicked)
}
from, to := int32(-1), int32(-1)
props.ReorderedFromIndex, props.ReorderedToIndex = &from, &to
r.QueueMouseButtonDown(MouseButtonLeft, 30, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
r.QueueMouseMove(170, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
r.QueueMouseButtonUp(MouseButtonLeft, 170, 20)
r.BeginFrame()
r.TabBar(props)
r.EndFrame()
if from != 0 || to != 2 {
t.Fatalf("reorder=%d->%d, want 0->2", from, to)
}
}
func TestNativeTabBarsOwnIndependentDefaultScroll(t *testing.T) {
r := New(AppConfig{Width: 420, Height: 160}).(*runtime)
tabs := []Tab{{Label: "Alpha"}, {Label: "Beta"}, {Label: "Gamma"}}
first := TabBarProps{Bounds: NewRectangle(10, 10, 160, 30), Tabs: tabs,
Count: 3, SelectedIndex: 2, MinTabWidth: 100, MaxTabWidth: 100,
FocusSelected: true, ID: 924}
second := first
second.Bounds = NewRectangle(210, 10, 160, 30)
second.SelectedIndex = 0
second.FocusSelected = false
second.ID = 925
r.BeginFrame()
r.TabBar(first)
r.TabBar(second)
r.EndFrame()
firstScroll := r.tabScroll[first.ID]
if firstScroll <= 0 {
t.Fatalf("first default scroll=%d, want a revealed selected tab", firstScroll)
}
if got := r.tabScroll[second.ID]; got != 0 {
t.Fatalf("second default scroll inherited %d from first tab bar", got)
}
first.FocusSelected = false
r.BeginFrame()
r.TabBar(first)
r.TabBar(second)
r.EndFrame()
if got := r.tabScroll[first.ID]; got != firstScroll {
t.Fatalf("default scroll did not persist: got %d want %d", got, firstScroll)
}
}
func TestNativeComposedTabBarScope(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 180}).(*runtime)
tabs := []Tab{{Label: "One"}, {Label: "Two"}}
selected := int32(0)
props := TabBarProps{Bounds: NewRectangle(10, 10, 200, 30), Tabs: tabs,
Count: 2, ID: 926}
visible := int32(-1)
r.BeginFrame()
if !r.BeginTabBar(props, &selected) {
t.Fatal("BeginTabBar rejected valid props")
}
if r.BeginTabItem(0) {
visible = 0
r.Button(ButtonProps{Bounds: NewRectangle(20, 60, 80, 28), ID: 927, Label: "First"})
r.EndTabItem()
}
if r.BeginTabItem(1) {
t.Fatal("BeginTabItem exposed an unselected tab")
}
r.EndTabBar()
r.EndFrame()
if visible != 0 {
t.Fatalf("visible tab=%d, want 0", visible)
}
r.QueueTap(160, 20)
r.BeginFrame()
if !r.BeginTabBar(props, &selected) {
t.Fatal("BeginTabBar rejected second frame")
}
if r.BeginTabItem(0) {
t.Fatal("old tab remained visible after header selection")
}
if r.BeginTabItem(1) {
visible = 1
r.Checkbox(928, 20, 60, "Second", &visible)
r.EndTabItem()
}
r.EndTabBar()
r.EndFrame()
if selected != 1 || visible != 1 {
t.Fatalf("selected/visible=%d/%d, want 1/1", selected, visible)
}
if r.BeginTabBar(TabBarProps{}, &selected) {
t.Fatal("BeginTabBar accepted invalid props")
}
mustPanic := func(call func()) {
t.Helper()
defer func() {
if recover() == nil {
t.Fatal("unbalanced tab scope did not panic")
}
}()
call()
}
mustPanic(func() { r.BeginTabItem(0) })
mustPanic(func() { r.EndTabItem() })
mustPanic(func() { r.EndTabBar() })
if !r.BeginTabBar(props, &selected) {
t.Fatal("BeginTabBar rejected frame-balance fixture")
}
mustPanic(func() { r.EndFrame() })
r.EndTabBar()
}
func TestNativeTypedDragDrop(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 200}).(*runtime)
payload := []byte("item-42")
@@ -1293,6 +2089,70 @@ func TestNativeMultiSelectListModifiers(t *testing.T) {
r.EndFrame()
}
func TestNativeMultiSelectListKeyboardNavigation(t *testing.T) {
r := New(AppConfig{Width: 320, Height: 240}).(*runtime)
selected := []int32{1, 0, 0}
selectedCount, anchor := int32(1), int32(0)
props := MultiSelectListProps{Bounds: NewRectangle(10, 10, 180, 84), ID: 89, Items: []string{"Alpha", "Beta", "Gamma"}, ItemCount: 3, Selected: selected, SelectedCount: &selectedCount, Anchor: &anchor, RowHeight: 28}
draw := func() int32 {
r.BeginFrame()
clicked := r.MultiSelectList(props)
r.Button(ButtonProps{Bounds: NewRectangle(10, 110, 80, 28), ID: 90, Label: "Next"})
r.EndFrame()
return clicked
}
draw()
r.SetFocus(89)
r.QueueKey(KeyDown)
if clicked := draw(); clicked != 1 || anchor != 1 || selectedCount != 1 || selected[1] != 1 || selected[0] != 0 {
t.Fatalf("Down selection clicked=%d selected=%v count=%d anchor=%d", clicked, selected, selectedCount, anchor)
}
r.QueueKey(KeyLeftShift)
r.QueueKey(KeyDown)
if clicked := draw(); clicked != 2 || anchor != 2 || selectedCount != 2 || selected[1] != 1 || selected[2] != 1 {
t.Fatalf("Shift+Down range clicked=%d selected=%v count=%d anchor=%d", clicked, selected, selectedCount, anchor)
}
r.QueueKey(KeySpace)
if clicked := draw(); clicked != 2 || selectedCount != 1 || selected[2] != 0 || selected[1] != 1 {
t.Fatalf("Space toggle clicked=%d selected=%v count=%d anchor=%d", clicked, selected, selectedCount, anchor)
}
r.QueueKey(KeyLeftControl)
r.QueueKey(KeyHome)
if clicked := draw(); clicked != -1 || anchor != 0 || selectedCount != 1 || selected[1] != 1 {
t.Fatalf("Control+Home cursor clicked=%d selected=%v count=%d anchor=%d", clicked, selected, selectedCount, anchor)
}
r.QueueKey(KeyEnter)
if clicked := draw(); clicked != 0 || selectedCount != 1 || selected[0] != 1 || selected[1] != 0 {
t.Fatalf("Enter selection clicked=%d selected=%v count=%d anchor=%d", clicked, selected, selectedCount, anchor)
}
foundFocus := false
for _, op := range r.ops {
if op.ID == 89 && op.Row == 0 && op.Focused && op.BorderColor == r.theme().focus {
foundFocus = true
}
}
if !foundFocus {
t.Fatal("focused multi-select row lacks focus presentation")
}
r.QueueKey(KeyTab)
draw()
if r.Focus() != 90 {
t.Fatalf("Tab focus=%d, want 90", r.Focus())
}
r.SetFocus(89)
r.QueueKey(KeySpace)
r.BeginFrame()
r.BeginDisabled(true)
clicked := r.MultiSelectList(props)
r.EndDisabled()
r.EndFrame()
if clicked != -1 || selectedCount != 1 || selected[0] != 1 {
t.Fatalf("disabled keyboard changed selection: clicked=%d selected=%v count=%d", clicked, selected, selectedCount)
}
}
func TestNativeColorWidgets(t *testing.T) {
r := New(AppConfig{Width: 640, Height: 480}).(*runtime)
rgb := []float32{0, 0.25, 0.75}
+128
View File
@@ -0,0 +1,128 @@
package kryon
type popupScope struct {
id int32
open *bool
paint paintLayerToken
input popupInputToken
capturesInput bool
}
func (r *runtime) BeginPopup(p PopupProps) bool {
tooltip := p.Flags&PopupTooltip != 0
modal := p.Flags&PopupModal != 0
context := p.Flags&PopupContext != 0
if p.Flags & ^(PopupTooltip|PopupModal|PopupContext) != 0 {
panic("unsupported popup flags")
}
if tooltip && (modal || context) || modal && context {
panic("tooltip, modal, and context popup flags are mutually exclusive")
}
if p.ID <= 0 || p.Bounds.Width <= 0 || p.Bounds.Height <= 0 ||
(!tooltip && p.Open == nil) ||
((tooltip || context) && (p.Trigger.Width <= 0 || p.Trigger.Height <= 0)) {
return false
}
if context && !p.Disabled && r.mouseReleased[MouseButtonRight] {
if r.pointerCanReach(p.Trigger) {
*p.Open = true
r.mouseReleased[MouseButtonRight] = false
}
}
if tooltip {
if p.Disabled || !pointInRect(r.mousePos.X, r.mousePos.Y, p.Trigger) {
return false
}
r.tooltipPopupsSeen[p.ID] = true
open := true
p.Open = &open
}
if !tooltip {
if r.popupsSeen == nil {
r.popupsSeen = make(map[int32]bool)
}
if r.openPopups == nil {
r.openPopups = make(map[int32]*bool)
}
r.popupsSeen[p.ID] = true
r.openPopups[p.ID] = p.Open
if p.Disabled {
*p.Open = false
}
if !*p.Open {
delete(r.openPopups, p.ID)
r.closePopupInput(p.ID)
return false
}
for i := range r.taps {
if modal {
break
}
if !r.taps[i].consumed && !pointInRect(r.taps[i].x, r.taps[i].y, p.Bounds) {
r.taps[i].consumed = true
*p.Open = false
r.closePopupInput(p.ID)
delete(r.openPopups, p.ID)
return false
}
}
}
var input popupInputToken
if !tooltip {
inputBounds := p.Bounds
if modal {
inputBounds = NewRectangle(0, 0, float32(r.GetScreenWidth()), float32(r.GetScreenHeight()))
}
input = r.beginPopupInput(p.ID, inputBounds)
if r.keyDown[KeyEscape] && !r.popupKeyboardCaptures() {
*p.Open = false
r.closePopupInput(p.ID)
r.endPopupInput(input)
delete(r.openPopups, p.ID)
return false
}
}
paint := r.beginPaintLayer(p.ID)
t := r.theme()
if modal {
r.record(FrameOp{Kind: FrameOpRect, Bounds: NewRectangle(0, 0, float32(r.GetScreenWidth()), float32(r.GetScreenHeight())), Color: Color{A: 180}})
}
r.scrollClips = append(r.scrollClips, p.Bounds)
r.record(FrameOp{Kind: FrameOpRect, Bounds: p.Bounds, Color: t.surface, BorderColor: t.border, ID: p.ID})
r.popupScopes = append(r.popupScopes, popupScope{id: p.ID, open: p.Open, paint: paint, input: input, capturesInput: !tooltip})
return true
}
func (r *runtime) ClosePopup() {
if len(r.popupScopes) == 0 {
panic("ClosePopup without BeginPopup")
}
s := &r.popupScopes[len(r.popupScopes)-1]
*s.open = false
if s.capturesInput {
r.closePopupInput(s.id)
delete(r.openPopups, s.id)
}
}
func (r *runtime) EndPopup() {
n := len(r.popupScopes)
if n == 0 {
panic("EndPopup without BeginPopup")
}
s := r.popupScopes[n-1]
if s.capturesInput && !*s.open {
r.closePopupInput(s.id)
delete(r.openPopups, s.id)
}
if len(r.scrollClips) == 0 {
panic("popup clip was unbalanced")
}
r.scrollClips = r.scrollClips[:len(r.scrollClips)-1]
if s.capturesInput {
r.endPopupInput(s.input)
}
r.endPaintLayer(s.paint)
r.popupScopes[n-1] = popupScope{}
r.popupScopes = r.popupScopes[:n-1]
}
+107 -6
View File
@@ -4,10 +4,14 @@ package kryon
// Entries persist until dismissal or frame-end owner removal, so background
// widgets declared before the popup cannot consume last frame's popup input.
type popupInputPanel struct {
bounds Rectangle
parent int32
hasParent bool
seen, order uint64
bounds Rectangle
parent int32
hasParent bool
seen, order uint64
restoreFocus int32
lastFocus int32
hasLastFocus bool
autofocus bool
}
type popupInputToken struct {
@@ -17,6 +21,25 @@ type popupInputToken struct {
depth int
}
type popupInputOwner struct {
owner int32
hasOwner bool
}
func (r *runtime) currentPopupInputOwner() popupInputOwner {
if n := len(r.popupInputScopes); n != 0 {
return popupInputOwner{owner: r.popupInputScopes[n-1].owner, hasOwner: true}
}
return popupInputOwner{}
}
func (r *runtime) popupInputOwnerCaptures(owner popupInputOwner) bool {
if r.currentPopupInputOwner() != owner {
return true
}
return r.popupKeyboardCapturesOwner(owner.owner, owner.hasOwner)
}
func (r *runtime) popupDescendsFrom(owner, ancestor int32) bool {
for {
panel, ok := r.popupPanels[owner]
@@ -41,7 +64,15 @@ func (r *runtime) beginPopupInput(owner int32, bounds Rectangle) popupInputToken
}
token := popupInputToken{r, r.paintLayerFrame, owner, len(r.popupInputScopes)}
r.popupInputOrder++
panel := popupInputPanel{bounds: bounds, seen: r.paintLayerFrame, order: r.popupInputOrder}
panel, existed := r.popupPanels[owner]
if !existed {
panel.restoreFocus = r.focusID
panel.autofocus = true
}
panel.bounds = bounds
panel.seen = r.paintLayerFrame
panel.order = r.popupInputOrder
panel.hasParent = false
if token.depth != 0 {
panel.parent = r.popupInputScopes[token.depth-1].owner
panel.hasParent = true
@@ -63,15 +94,28 @@ func (r *runtime) endPopupInput(token popupInputToken) {
}
func (r *runtime) closePopupInput(owner int32) {
panel, found := r.popupPanels[owner]
restore := false
removed := []int32{owner}
for id := range r.popupPanels {
for id, child := range r.popupPanels {
if r.popupDescendsFrom(id, owner) {
removed = append(removed, id)
}
if (id == owner || r.popupDescendsFrom(id, owner)) &&
child.hasLastFocus && child.lastFocus == r.focusID {
restore = true
}
}
if focusOwner, ok := r.popupFocus[r.focusID]; ok && focusOwner.hasOwner &&
(focusOwner.owner == owner || r.popupDescendsFrom(focusOwner.owner, owner)) {
restore = true
}
for _, id := range removed {
delete(r.popupPanels, id)
}
if found && restore {
r.setFocus(panel.restoreFocus)
}
}
func (r *runtime) prunePopupInput() {
@@ -148,3 +192,60 @@ func (r *runtime) closeDropdown(owner int32) {
delete(r.dropdownHighlight, owner)
r.closePopupInput(owner)
}
// Keyboard ownership follows the top branch regardless of pointer position.
func (r *runtime) popupKeyboardCaptures() bool {
if n := len(r.popupInputScopes); n != 0 {
return r.popupKeyboardCapturesOwner(r.popupInputScopes[n-1].owner, true)
}
return r.popupKeyboardCapturesOwner(0, false)
}
func (r *runtime) popupKeyboardCapturesOwner(owner int32, hasOwner bool) bool {
var top int32
found := false
for id := range r.popupPanels {
if !found || r.popupAbove(id, top) {
top, found = id, true
}
}
if hasOwner {
if _, alive := r.popupPanels[owner]; !alive {
return true
}
return found && owner != top
}
return found
}
type popupFocusOwner struct {
owner int32
hasOwner bool
seen uint64
}
func (r *runtime) registerPopupFocus(id int32) {
if r.popupFocus == nil {
r.popupFocus = make(map[int32]popupFocusOwner)
}
owner := popupFocusOwner{seen: r.paintLayerFrame}
if n := len(r.popupInputScopes); n != 0 {
owner.owner, owner.hasOwner = r.popupInputScopes[n-1].owner, true
panel := r.popupPanels[owner.owner]
if panel.autofocus && !r.popupKeyboardCapturesOwner(owner.owner, true) {
r.setFocus(id)
panel.autofocus = false
}
if r.focusID == id {
panel.lastFocus = id
panel.hasLastFocus = true
}
r.popupPanels[owner.owner] = panel
}
r.popupFocus[id] = owner
}
func (r *runtime) popupFocusCaptures(id int32) bool {
owner := r.popupFocus[id]
return r.popupKeyboardCapturesOwner(owner.owner, owner.hasOwner)
}
+673
View File
@@ -5,6 +5,479 @@ import (
"testing"
)
func TestPopupComboKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueKey(KeySpace)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
if r.popupKeyboardCaptures() == inside {
t.Fatal("keyboard ownership depends on pointer bounds or wrong branch")
}
r.setFocus(25400)
var selected int32
r.Combobox(ComboboxProps{Bounds: NewRectangle(10, 10, 100, 28), ID: 25400,
Options: []string{"One", "Two"}, SelectedIndex: &selected})
if r.openDropdowns[25400] != inside {
t.Fatalf("combo open = %v, inside top popup = %v", r.openDropdowns[25400], inside)
}
r.closeDropdown(25400)
if inside {
r.endPopupInput(child)
}
r.closePopupInput(1)
if r.popupKeyboardCaptures() {
t.Fatal("closing child did not restore parent keyboard")
}
r.endPopupInput(parent)
if !r.popupKeyboardCaptures() {
t.Fatal("parent did not capture background keyboard")
}
r.closePopupInput(0)
if r.popupKeyboardCaptures() {
t.Fatal("closing branch did not restore background keyboard")
}
r.EndFrame()
}
}
func TestPopupTextKeyboardOwnership(t *testing.T) {
for _, area := range []bool{false, true} {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueText("x")
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
text := make([]byte, 32)
copy(text, "a")
cursor, focused := int32(1), true
r.setFocus(25500)
if area {
r.TextArea(TextAreaProps{Bounds: NewRectangle(10, 10, 120, 80), Text: text,
CursorPosition: &cursor, Focused: &focused, FocusID: 25500})
} else {
r.TextField(TextFieldProps{Bounds: NewRectangle(10, 10, 120, 28), Text: text,
CursorPosition: &cursor, Focused: &focused, FocusID: 25500})
}
want := "a"
if inside {
want = "ax"
r.endPopupInput(child)
}
if got := string(text[:zeroIndex(text)]); got != want {
t.Fatalf("area=%v inside=%v: text=%q want=%q", area, inside, got, want)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
}
func TestPopupTabOwnership(t *testing.T) {
for mode := 0; mode < 6; mode++ {
r := New(AppConfig{}).(*runtime)
start := []int32{25620, 25621, 25620, 25600, 25620, 25620}
want := []int32{25621, 25620, 25621, 25621, 25610, 25600}
for frame := 0; frame < 2; frame++ {
if mode == 3 {
r.setFocus(start[mode])
r.QueueShiftKey(KeyTab)
}
if frame == 1 && mode < 3 {
if mode == 2 {
r.QueueShiftKey(KeyTab)
} else {
r.QueueKey(KeyTab)
}
}
r.BeginFrame()
r.registerField(25600)
parent := r.beginPopupInput(0, NewRectangle(10, 10, 120, 120))
r.registerField(25610)
child := r.beginPopupInput(1, NewRectangle(20, 20, 60, 60))
r.registerField(25620)
r.registerField(25621)
r.registerField(25620)
if frame == 1 && mode < 3 {
cursor, focused := int32(0), true
r.setFocus(start[mode])
r.TextField(TextFieldProps{Bounds: NewRectangle(20, 20, 60, 24),
Text: make([]byte, 16), CursorPosition: &cursor, Focused: &focused,
FocusID: start[mode]})
if r.Focus() != want[mode] {
t.Fatalf("editor Tab mode=%d: focus=%d want=%d", mode, r.Focus(), want[mode])
}
}
r.endPopupInput(child)
r.registerField(25611)
r.endPopupInput(parent)
r.registerField(25601)
if mode == 4 {
r.closePopupInput(1)
}
if mode == 5 {
r.closePopupInput(0)
}
got := r.nextFocus(start[mode], mode == 2 || mode == 3)
if got != want[mode] {
t.Fatalf("mode=%d frame=%d: next focus=%d want=%d", mode, frame, got, want[mode])
}
r.EndFrame()
if mode == 3 && r.Focus() != want[mode] {
t.Fatalf("unclaimed Tab did not enter top popup: got %d want %d", r.Focus(), want[mode])
}
}
}
}
func TestPopupButtonKeyboardOwnership(t *testing.T) {
for _, key := range []int32{KeyEnter, KeySpace} {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueKey(key)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
r.setFocus(25700)
p := ButtonProps{Bounds: NewRectangle(10, 10, 120, 28), Label: "Action", ID: 25700}
if got := r.Button(p); got != inside {
t.Fatalf("key=%d inside=%v: activated=%v", key, inside, got)
}
if inside {
if r.Button(p) {
t.Fatal("button replayed consumed activation")
}
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
}
func TestPopupChoiceKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
selected := int32(0)
wantSelected := int32(0)
if inside {
wantSelected = 1
}
r.QueueKey(KeySpace)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
r.setFocus(25705)
activated := r.Selectable(SelectableProps{
Bounds: NewRectangle(10, 10, 120, 28), Label: "Choice",
ID: 25705, Selected: &selected,
})
if activated != inside || selected != wantSelected {
t.Fatalf("inside=%v: activated=%v selected=%d", inside, activated, selected)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupMultiSelectKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
selected := []int32{1, 0}
count, anchor := int32(1), int32(0)
props := MultiSelectListProps{
Bounds: NewRectangle(10, 10, 120, 56), ID: 25706,
Items: []string{"Alpha", "Beta"}, ItemCount: 2, Selected: selected,
SelectedCount: &count, Anchor: &anchor, RowHeight: 28,
}
r.QueueKey(KeyDown)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
r.setFocus(props.ID)
clicked := r.MultiSelectList(props)
wantClicked, wantAnchor, wantSelected := int32(-1), int32(0), int32(0)
if inside {
wantClicked, wantAnchor, wantSelected = 1, 1, 1
}
if clicked != wantClicked || anchor != wantAnchor || selected[1] != wantSelected {
t.Fatalf("inside=%v: clicked=%d anchor=%d selected=%v", inside, clicked, anchor, selected)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupTabBarKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{Width: 240, Height: 120}).(*runtime)
props := TabBarProps{Bounds: NewRectangle(20, 20, 180, 30), ID: 26132,
Tabs: []Tab{{Label: "a"}, {Label: "b"}}, Count: 2, SelectedIndex: 0}
r.QueueKey(KeyRight)
r.BeginFrame()
parent := r.beginPopupInput(26100, NewRectangle(10, 10, 220, 100))
child := r.beginPopupInput(26101, NewRectangle(15, 15, 200, 80))
if !inside {
r.endPopupInput(child)
}
r.SetFocus(props.ID)
clicked := r.TabBar(props)
want := int32(-1)
if inside {
want = 1
}
if clicked != want {
t.Fatalf("inside=%v clicked=%d, want %d", inside, clicked, want)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupDragKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
values := []float32{1}
r.QueueKey(KeyRight)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
r.setFocus(25707)
changed := r.DragFloat(DragFloatProps{Bounds: NewRectangle(10, 10, 120, 28), ID: 25707, Values: values, ValueCount: 1, Speed: 1, Min: 0, Max: 10})
want := float32(1)
if inside {
want = 2
}
if changed != inside || values[0] != want {
t.Fatalf("inside=%v: changed=%v value=%v", inside, changed, values[0])
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupMenuKeyboardOwnership(t *testing.T) {
items := []MenuItem{{Kind: MenuCommand, Label: "Run", ID: 25710}}
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueKey(KeyEnter)
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(180, 180, 40, 40))
child := r.beginPopupInput(1, NewRectangle(190, 190, 20, 20))
if !inside {
r.endPopupInput(child)
}
r.setFocus(25711)
got := r.PopupMenu(25711, 10, 10, items, 1)
want := int32(0)
if inside {
want = 25710
}
if got != want {
t.Fatalf("inside=%v: popup menu activation=%d want=%d", inside, got, want)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupAcceleratorKeyboardOwnership(t *testing.T) {
r := New(AppConfig{}).(*runtime)
r.QueueShortcut(KeyC)
r.BeginFrame()
parent := r.beginPopupInput(26000, NewRectangle(10, 10, 120, 100))
child := r.beginPopupInput(26001, NewRectangle(20, 20, 80, 60))
copy := Accelerator{Key: KeyC, Ctrl: 1, ID: 91}
r.endPopupInput(child)
if got := r.AcceleratorPressed(copy); got != 0 {
t.Fatalf("parent accelerator behind child = %d, want 0", got)
}
child = r.beginPopupInput(26001, NewRectangle(20, 20, 80, 60))
if got := r.DispatchAccelerators([]Accelerator{{Key: KeyX, Ctrl: 1, ID: 90}, copy}); got != 91 {
t.Fatalf("top popup accelerator = %d, want 91", got)
}
r.endPopupInput(child)
r.closePopupInput(26001)
if got := r.AcceleratorPressed(copy); got != 91 {
t.Fatalf("parent accelerator after child close = %d, want 91", got)
}
r.endPopupInput(parent)
if got := r.AcceleratorPressed(copy); got != 0 {
t.Fatalf("background accelerator behind parent = %d, want 0", got)
}
r.closePopupInput(26000)
if got := r.AcceleratorPressed(copy); got != 91 {
t.Fatalf("background accelerator after popup close = %d, want 91", got)
}
r.EndFrame()
r.QueueShortcut(KeyC)
r.BeginFrame()
r.BeginDisabled(true)
if got := r.AcceleratorPressed(copy); got != 0 {
t.Fatalf("disabled accelerator = %d, want 0", got)
}
r.EndDisabled()
r.EndFrame()
}
func TestPopupCollapsibleKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueKey(KeyRight)
r.BeginFrame()
parent := r.beginPopupInput(26100, NewRectangle(10, 10, 120, 100))
child := r.beginPopupInput(26101, NewRectangle(20, 20, 80, 60))
if !inside {
r.endPopupInput(child)
}
open := false
r.setFocus(26110)
r.Collapsible(CollapsibleProps{Bounds: NewRectangle(20, 20, 80, 28),
ID: 26110, Label: "Node", Open: &open, Tree: true})
if open != inside {
t.Fatalf("inside=%v: popup-owned collapsible open=%v", inside, open)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupSelectableTextKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
r.QueueTap(12, 12)
r.BeginFrame()
r.SelectableText("copy me", 10, 10, Text16, WHITE)
r.EndFrame()
r.SetClipboardText("seed")
r.QueueShortcut(KeyC)
r.BeginFrame()
parent := r.beginPopupInput(26200, NewRectangle(10, 10, 120, 100))
child := r.beginPopupInput(26201, NewRectangle(20, 20, 80, 60))
if !inside {
r.endPopupInput(child)
}
r.SelectableText("copy me", 10, 10, Text16, WHITE)
want := "seed"
if inside {
want = "copy me"
r.endPopupInput(child)
}
if got := r.ClipboardText(); got != want {
t.Fatalf("inside=%v: selectable copy=%q want %q", inside, got, want)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupTabMissingOwner(t *testing.T) {
r := New(AppConfig{}).(*runtime)
for frame := 0; frame < 3; frame++ {
if frame != 0 {
r.QueueKey(KeyTab)
}
r.BeginFrame()
r.registerField(25800)
if frame < 2 {
parent := r.beginPopupInput(0, NewRectangle(10, 10, 120, 120))
r.registerField(25810)
if frame == 0 {
child := r.beginPopupInput(1, NewRectangle(20, 20, 60, 60))
r.registerField(25820)
r.setFocus(25820)
r.endPopupInput(child)
}
r.endPopupInput(parent)
}
r.EndFrame()
want := []int32{25820, 25810, 25800}[frame]
if r.Focus() != want {
t.Fatalf("frame=%d: missing owner retained Tab capture: got %d want %d", frame, r.Focus(), want)
}
}
}
func TestPopupTextDismissalDoesNotReplay(t *testing.T) {
for _, area := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
text := make([]byte, 32)
copy(text, "a")
cursor, focused := int32(1), true
for frame := 0; frame < 3; frame++ {
if frame != 1 {
r.QueueText("x")
}
r.BeginFrame()
parent := r.beginPopupInput(0, NewRectangle(10, 10, 120, 120))
if frame == 0 {
child := r.beginPopupInput(1, NewRectangle(20, 20, 60, 60))
r.endPopupInput(child)
} else {
r.closePopupInput(1)
}
r.setFocus(25900)
focused = true
if area {
r.TextArea(TextAreaProps{Bounds: NewRectangle(10, 10, 120, 80), Text: text,
CursorPosition: &cursor, Focused: &focused, FocusID: 25900})
} else {
r.TextField(TextFieldProps{Bounds: NewRectangle(10, 10, 120, 28), Text: text,
CursorPosition: &cursor, Focused: &focused, FocusID: 25900})
}
r.endPopupInput(parent)
r.EndFrame()
want := "a"
if frame == 2 {
want = "ax"
}
if got := string(text[:zeroIndex(text)]); got != want {
t.Fatalf("area=%v frame=%d: got %q want %q", area, frame, got, want)
}
}
}
}
func TestPopupWheelOwnershipAcrossScrollableWidgets(t *testing.T) {
bounds := NewRectangle(10, 10, 100, 100)
draws := map[string]func(*runtime, *int32){
@@ -168,6 +641,206 @@ func TestPopupDragDropOwnershipAndClipping(t *testing.T) {
r.EndFrame()
}
func TestPopupOwnsActiveScalarSliderAndTableResizeDrags(t *testing.T) {
panel := NewRectangle(20, 20, 120, 100)
t.Run("new popup preempts background drag", func(t *testing.T) {
r := New(AppConfig{Width: 260, Height: 180}).(*runtime)
values := []float32{10}
props := DragFloatProps{Bounds: NewRectangle(30, 30, 80, 24), ID: 391, Values: values, Speed: 1, Min: 0, Max: 500}
r.QueueMouseButtonDown(MouseButtonLeft, 40, 40)
r.BeginFrame()
r.DragFloat(props)
r.EndFrame()
r.QueueMouseMove(80, 40)
r.BeginFrame()
owner := r.beginPopupInput(390, panel)
r.endPopupInput(owner)
if r.DragFloat(props) || values[0] != 10 || r.drag.active {
t.Fatalf("background drag survived new popup: value=%g active=%v", values[0], r.drag.active)
}
r.EndFrame()
})
t.Run("drag value", func(t *testing.T) {
r := New(AppConfig{Width: 260, Height: 180}).(*runtime)
values := []float32{10}
props := DragFloatProps{Bounds: NewRectangle(30, 30, 80, 24), ID: 401, Values: values, Speed: 1, Min: 0, Max: 500}
r.QueueMouseButtonDown(MouseButtonLeft, 40, 40)
r.BeginFrame()
owner := r.beginPopupInput(400, panel)
r.DragFloat(props)
r.endPopupInput(owner)
r.EndFrame()
r.QueueMouseMove(200, 40)
r.BeginFrame()
owner = r.beginPopupInput(400, panel)
if !r.DragFloat(props) || values[0] != 170 {
t.Fatalf("popup drag outside bounds value=%g, want 170", values[0])
}
r.endPopupInput(owner)
r.closePopupInput(400)
before := values[0]
r.QueueMouseMove(230, 40)
if r.DragFloat(props) || values[0] != before || r.drag.active {
t.Fatalf("dismissed popup drag leaked to background: value=%g active=%v", values[0], r.drag.active)
}
r.EndFrame()
})
t.Run("slider", func(t *testing.T) {
r := New(AppConfig{Width: 260, Height: 180}).(*runtime)
values := []float32{0}
props := SliderFloatProps{Bounds: NewRectangle(30, 30, 80, 24), ID: 411, Values: values, Min: 0, Max: 100}
r.QueueMouseButtonDown(MouseButtonLeft, 50, 40)
r.BeginFrame()
owner := r.beginPopupInput(410, panel)
r.SliderFloat(props)
r.endPopupInput(owner)
r.EndFrame()
r.QueueMouseMove(90, 40)
r.BeginFrame()
owner = r.beginPopupInput(410, panel)
r.SliderFloat(props)
r.endPopupInput(owner)
before := values[0]
r.closePopupInput(410)
r.QueueMouseMove(30, 40)
if r.SliderFloat(props) || values[0] != before || r.slider.active {
t.Fatalf("dismissed popup slider leaked to background: value=%g active=%v", values[0], r.slider.active)
}
r.EndFrame()
})
t.Run("splitter", func(t *testing.T) {
r := New(AppConfig{Width: 260, Height: 180}).(*runtime)
split := int32(50)
props := PanedViewProps{Bounds: NewRectangle(30, 30, 100, 80), ID: 416, Vertical: true, Split: &split, MinFirst: 20, MinSecond: 20}
r.QueueMouseButtonDown(MouseButtonLeft, 80, 40)
r.BeginFrame()
owner := r.beginPopupInput(415, panel)
r.PanedView(props)
r.endPopupInput(owner)
r.EndFrame()
r.QueueMouseMove(110, 40)
r.BeginFrame()
owner = r.beginPopupInput(415, panel)
if r.PanedView(props) == 0 || split != 80 {
t.Fatalf("popup splitter value=%d, want 80", split)
}
r.endPopupInput(owner)
r.closePopupInput(415)
before := split
r.QueueMouseMove(60, 40)
r.PanedView(props)
if split != before || r.drag.active {
t.Fatalf("dismissed popup splitter leaked to background: split=%d active=%v", split, r.drag.active)
}
r.EndFrame()
})
t.Run("table resize", func(t *testing.T) {
r := New(AppConfig{Width: 300, Height: 200}).(*runtime)
widths := []int32{70, 70}
props := TableViewProps{Bounds: NewRectangle(25, 25, 140, 90), ID: 421,
Columns: []string{"A", "B"}, Rows: []TableRow{{Cells: []string{"a", "b"}}},
ColumnWidths: widths, Resizable: true, MinColumnWidth: 32}
r.QueueMouseButtonDown(MouseButtonLeft, 93, 35)
r.BeginFrame()
owner := r.beginPopupInput(420, NewRectangle(20, 20, 160, 110))
r.TableView(props)
r.endPopupInput(owner)
r.EndFrame()
r.QueueMouseMove(123, 35)
r.BeginFrame()
owner = r.beginPopupInput(420, NewRectangle(20, 20, 160, 110))
if r.TableView(props) == 0 || widths[0] != 100 {
t.Fatalf("popup table resize width=%d, want 100", widths[0])
}
r.endPopupInput(owner)
r.closePopupInput(420)
before := widths[0]
r.QueueMouseMove(153, 35)
r.TableView(props)
if widths[0] != before || r.tableResize.active {
t.Fatalf("dismissed popup resize leaked to background: width=%d active=%v", widths[0], r.tableResize.active)
}
r.EndFrame()
})
}
func TestPopupTableKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{Width: 240, Height: 160}).(*runtime)
selectedRow, selectedColumn := int32(0), int32(0)
props := TableViewProps{
Bounds: NewRectangle(20, 20, 100, 80), ID: 26120,
Columns: []string{"A"}, Rows: []TableRow{{Cells: []string{"a"}}, {Cells: []string{"b"}}},
SelectedRow: &selectedRow, SelectedColumn: &selectedColumn,
}
r.QueueKey(KeyDown)
r.BeginFrame()
parent := r.beginPopupInput(26100, NewRectangle(10, 10, 140, 120))
child := r.beginPopupInput(26101, NewRectangle(15, 15, 120, 100))
if !inside {
r.endPopupInput(child)
}
r.SetFocus(26120)
r.TableView(props)
want := int32(0)
if inside {
want = 1
}
if selectedRow != want {
t.Fatalf("inside=%v selected row=%d, want %d", inside, selectedRow, want)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupListBoxKeyboardOwnership(t *testing.T) {
for _, inside := range []bool{false, true} {
r := New(AppConfig{Width: 200, Height: 120}).(*runtime)
selected, offset := int32(0), int32(0)
props := ListBoxProps{
Bounds: NewRectangle(20, 20, 100, 48), ID: 26131,
Items: []string{"a", "b"}, SelectedIndex: &selected,
ScrollOffset: &offset, RowHeight: 24,
}
r.QueueKey(KeyDown)
r.BeginFrame()
parent := r.beginPopupInput(26100, NewRectangle(10, 10, 140, 100))
child := r.beginPopupInput(26101, NewRectangle(15, 15, 120, 80))
if !inside {
r.endPopupInput(child)
}
r.SetFocus(props.ID)
r.ListBox(props)
want := int32(0)
if inside {
want = 1
}
if selected != want {
t.Fatalf("inside=%v selected=%d, want %d", inside, selected, want)
}
if inside {
r.endPopupInput(child)
}
r.endPopupInput(parent)
r.EndFrame()
}
}
func TestPopupInputBranchOrder(t *testing.T) {
r := New(AppConfig{}).(*runtime)
panel := NewRectangle(0, 0, 100, 100)
+323
View File
@@ -0,0 +1,323 @@
package kryon
import "testing"
func TestComposedTooltipOwnsArbitraryPaintWithoutInputCapture(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
r.QueueMouseMove(30, 25)
r.BeginFrame()
if !r.BeginPopup(PopupProps{
Bounds: NewRectangle(80, 50, 130, 70), ID: 29300,
Trigger: NewRectangle(20, 20, 80, 30), Flags: PopupTooltip,
}) {
t.Fatal("hovered tooltip popup returned false")
}
r.Column(ColumnProps{Bounds: NewRectangle(88, 58, 114, 54), Gap: 4})
r.Text(TextProps{Text: "arbitrary tooltip", Font: Text14, Color: BLACK})
r.Button(ButtonProps{Bounds: NewRectangle(0, 0, 90, 24), Label: "detail", ID: 29301})
r.End()
r.EndPopup()
r.EndFrame()
panel, text, child := -1, -1, -1
for i, op := range r.ops {
if op.ID == 29300 {
panel = i
}
if op.Text == "arbitrary tooltip" {
text = i
}
if op.ID == 29301 {
child = i
}
}
if panel < 0 || text <= panel || child <= text {
t.Fatalf("tooltip layer order panel=%d text=%d child=%d", panel, text, child)
}
if len(r.popupPanels) != 0 {
t.Fatalf("tooltip captured popup input: %+v", r.popupPanels)
}
r.QueueMouseMove(230, 170)
r.BeginFrame()
if r.BeginPopup(PopupProps{
Bounds: NewRectangle(80, 50, 130, 70), ID: 29300,
Trigger: NewRectangle(20, 20, 80, 30), Flags: PopupTooltip,
}) {
t.Fatal("tooltip remained visible outside its trigger")
}
r.EndFrame()
}
func TestComposedModalOwnsArbitraryContentAndFullViewInput(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.QueueTap(190, 150)
r.BeginFrame()
if !r.BeginPopup(PopupProps{
Bounds: NewRectangle(40, 30, 120, 90), ID: 29400,
Open: &open, Flags: PopupModal,
}) {
t.Fatal("open modal popup returned false")
}
r.Column(ColumnProps{Bounds: NewRectangle(48, 38, 104, 70), Gap: 4})
r.Text(TextProps{Text: "arbitrary modal", Font: Text14, Color: BLACK})
r.Button(ButtonProps{Bounds: NewRectangle(0, 0, 90, 24), Label: "confirm", ID: 29401})
r.End()
r.EndPopup()
if r.Button(ButtonProps{Bounds: NewRectangle(170, 130, 60, 40), Label: "Behind", ID: 29402}) {
t.Fatal("modal leaked an outside tap to the background")
}
r.EndFrame()
if !open {
t.Fatal("outside tap dismissed modal")
}
backdrop, panel, text, child := -1, -1, -1, -1
for i, op := range r.ops {
if op.Kind == FrameOpRect && op.Bounds == (Rectangle{Width: 240, Height: 180}) {
backdrop = i
}
if op.ID == 29400 {
panel = i
}
if op.Text == "arbitrary modal" {
text = i
}
if op.ID == 29401 {
child = i
}
}
if backdrop < 0 || panel <= backdrop || text <= panel || child <= text {
t.Fatalf("modal layer order backdrop=%d panel=%d text=%d child=%d", backdrop, panel, text, child)
}
if r.ops[backdrop].HasClip {
t.Fatal("modal backdrop was clipped to the popup panel")
}
r.QueueKey(KeyEscape)
r.BeginFrame()
if r.BeginPopup(PopupProps{
Bounds: NewRectangle(40, 30, 120, 90), ID: 29400,
Open: &open, Flags: PopupModal,
}) {
t.Fatal("Escape left modal popup open")
}
r.EndFrame()
if open {
t.Fatal("Escape did not update modal caller state")
}
}
func TestComposedContextPopupOpensOnRightRelease(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := false
r.QueueMouseButton(MouseButtonRight, 30, 25)
r.BeginFrame()
if !r.BeginPopup(PopupProps{
Bounds: NewRectangle(80, 50, 130, 70), ID: 29500, Open: &open,
Trigger: NewRectangle(20, 20, 80, 30), Flags: PopupContext,
}) {
t.Fatal("right release in trigger did not open context popup")
}
r.Text(TextProps{Bounds: NewRectangle(88, 58, 0, 0), Text: "context child", Font: Text14, Color: BLACK, Wrap: TextWrapNone})
r.EndPopup()
r.EndFrame()
if !open {
t.Fatal("context popup did not update caller-owned open state")
}
found := false
for _, op := range r.FrameOps() {
if op.Text == "context child" {
found = true
}
}
if !found {
t.Fatal("context popup did not retain an ordinary child")
}
r.QueueTap(220, 160)
r.BeginFrame()
if r.BeginPopup(PopupProps{
Bounds: NewRectangle(80, 50, 130, 70), ID: 29500, Open: &open,
Trigger: NewRectangle(20, 20, 80, 30), Flags: PopupContext,
}) {
t.Fatal("outside tap did not dismiss context popup")
}
r.EndFrame()
if open {
t.Fatal("context-popup dismissal did not update open state")
}
r.QueueMouseButton(MouseButtonRight, 30, 25)
r.BeginFrame()
if r.BeginPopup(PopupProps{
Bounds: NewRectangle(80, 50, 130, 70), ID: 29500, Open: &open,
Trigger: NewRectangle(20, 20, 80, 30), Flags: PopupContext, Disabled: true,
}) {
t.Fatal("disabled context popup opened")
}
r.EndFrame()
}
func TestComposedPopupAcquiresAndRestoresNestedFocus(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
parentOpen, childOpen := true, false
r.setFocus(29600)
r.BeginFrame()
if !r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 180, 130), ID: 29610, Open: &parentOpen}) {
t.Fatal("parent popup did not open")
}
r.BeginDisabled(true)
r.Button(ButtonProps{Bounds: NewRectangle(30, 30, 100, 24), Label: "Disabled", ID: 29612})
r.EndDisabled()
r.Button(ButtonProps{Bounds: NewRectangle(30, 30, 100, 24), Label: "Parent", ID: 29611})
r.EndPopup()
r.EndFrame()
if r.Focus() != 29611 {
t.Fatalf("parent popup focus=%d, want first child 29611", r.Focus())
}
childOpen = true
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 180, 130), ID: 29610, Open: &parentOpen})
r.Button(ButtonProps{Bounds: NewRectangle(30, 30, 100, 24), Label: "Parent", ID: 29611})
r.BeginPopup(PopupProps{Bounds: NewRectangle(50, 60, 130, 80), ID: 29620, Open: &childOpen})
r.Button(ButtonProps{Bounds: NewRectangle(60, 70, 100, 24), Label: "Child", ID: 29621})
if r.Focus() != 29621 {
t.Fatalf("nested popup focus=%d, want first child 29621", r.Focus())
}
r.ClosePopup()
if r.Focus() != 29611 {
t.Fatalf("nested close restored focus=%d, want parent 29611", r.Focus())
}
r.EndPopup()
r.EndPopup()
r.EndFrame()
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 180, 130), ID: 29610, Open: &parentOpen})
r.Button(ButtonProps{Bounds: NewRectangle(30, 30, 100, 24), Label: "Parent", ID: 29611})
r.ClosePopup()
if r.Focus() != 29600 {
t.Fatalf("parent close restored focus=%d, want background 29600", r.Focus())
}
r.EndPopup()
r.EndFrame()
}
func TestComposedPopupMissingOwnerRestoresFocus(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.setFocus(29700)
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 120, 80), ID: 29710, Open: &open})
r.Button(ButtonProps{Bounds: NewRectangle(30, 30, 90, 24), Label: "Popup", ID: 29711})
r.EndPopup()
r.EndFrame()
if r.Focus() != 29711 {
t.Fatalf("popup focus=%d, want 29711", r.Focus())
}
r.BeginFrame()
r.EndFrame()
if r.Focus() != 29700 {
t.Fatalf("missing owner restored focus=%d, want 29700", r.Focus())
}
}
func TestComposedPopupOwnsOrdinaryChildrenAndPaintOrder(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.BeginFrame()
if !r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 30, 140, 100), ID: 29000, Open: &open}) {
t.Fatal("open popup returned false")
}
r.Column(ColumnProps{Bounds: NewRectangle(28, 40, 120, 70), Gap: 4})
r.Button(ButtonProps{Bounds: NewRectangle(0, 0, 100, 28), Label: "Apply", ID: 29001})
r.End()
r.EndPopup()
r.Button(ButtonProps{Bounds: NewRectangle(20, 30, 140, 100), Label: "Later", ID: 29002})
r.EndFrame()
background, popupPanel, child := -1, -1, -1
for i, op := range r.ops {
switch op.ID {
case 29000:
popupPanel = i
case 29001:
child = i
case 29002:
background = i
}
}
if background < 0 || popupPanel <= background || child <= popupPanel {
t.Fatalf("popup layer order background=%d panel=%d child=%d", background, popupPanel, child)
}
if got := r.ops[child].Bounds; got.X != 28 || got.Y != 40 {
t.Fatalf("popup child layout = %+v", got)
}
}
func TestComposedPopupDismissalConsumesOutsideTap(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 100, 80), ID: 29100, Open: &open})
r.EndPopup()
r.EndFrame()
r.QueueTap(160, 40)
r.BeginFrame()
if r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 100, 80), ID: 29100, Open: &open}) {
t.Fatal("outside tap left popup open")
}
if r.Button(ButtonProps{Bounds: NewRectangle(140, 20, 80, 40), Label: "Behind", ID: 29101}) {
t.Fatal("outside dismissal leaked into background button")
}
r.EndFrame()
if open {
t.Fatal("outside dismissal did not update caller state")
}
}
func TestComposedPopupCloseAndMissingOwner(t *testing.T) {
r := New(AppConfig{Width: 240, Height: 180}).(*runtime)
open := true
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 100, 80), ID: 29200, Open: &open})
r.Text(TextProps{Bounds: NewRectangle(24, 24, 0, 0), Text: "hidden", Font: Text14, Color: BLACK, Wrap: TextWrapNone})
r.ClosePopup()
r.EndPopup()
r.EndFrame()
if open {
t.Fatal("ClosePopup did not update caller state")
}
for _, op := range r.ops {
if op.ID == 29200 || op.Text == "hidden" {
t.Fatal("same-frame close retained popup paint")
}
}
open = true
r.BeginFrame()
r.BeginPopup(PopupProps{Bounds: NewRectangle(20, 20, 100, 80), ID: 29200, Open: &open})
r.EndPopup()
r.EndFrame()
r.BeginFrame()
r.EndFrame()
if open {
t.Fatal("missing popup owner did not close caller state")
}
}
func TestComposedPopupScopeBalance(t *testing.T) {
r := New(AppConfig{}).(*runtime)
defer func() {
if recover() == nil {
t.Fatal("EndPopup without BeginPopup was accepted")
}
}()
r.EndPopup()
}
+73
View File
@@ -0,0 +1,73 @@
package kryon
import (
"bytes"
"testing"
)
func TestReadOnlyEditorsPreserveInputAndCancelPreedit(t *testing.T) {
for _, area := range []bool{false, true} {
r := New(AppConfig{}).(*runtime)
text := make([]byte, 32)
copy(text, "base")
cursor := int32(4)
draw := func(readOnly bool) {
if area {
r.TextArea(TextAreaProps{Bounds: NewRectangle(10, 10, 120, 80), Text: text,
CursorPosition: &cursor, FocusID: 26200, ReadOnly: readOnly})
} else {
r.TextField(TextFieldProps{Bounds: NewRectangle(10, 10, 120, 28), Text: text,
CursorPosition: &cursor, FocusID: 26200, ReadOnly: readOnly})
}
}
r.setFocus(26200)
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_UPDATE, "ni", 2, 0)
r.BeginFrame()
draw(false)
r.EndFrame()
if r.FrameOps()[0].Text != "baseni" {
t.Fatal("preedit not established")
}
// Bytes beyond the terminating NUL also belong to the caller.
text[20] = 99
before := append([]byte(nil), text...)
r.QueueShortcut(KeyA)
r.QueueShortcut(KeyC)
r.QueueShortcut(KeyX)
r.QueueShortcut(KeyV)
r.QueueText("blocked")
r.QueueKey(KeyBackspace)
r.QueueKey(KeyDelete)
r.SubmitTextComposition(KRY_TEXT_COMPOSITION_COMMIT, "blocked", 7, 0)
r.BeginFrame()
draw(true)
r.EndFrame()
if !bytes.Equal(text, before) || r.ClipboardText() != "base" || r.Focus() != 26200 {
t.Fatalf("area=%v: read-only buffer/copy/focus contract failed", area)
}
op := r.FrameOps()[0]
if !op.ReadOnly || !op.Focused || op.Text != "base" || len(r.preedit) != 0 {
t.Fatalf("area=%v: stale preedit or metadata", area)
}
withoutCaret := RenderFrame(160, 120, []FrameOp{op})
op.ReadOnly = false
withCaret := RenderFrame(160, 120, []FrameOp{op})
if bytes.Equal(withoutCaret.Pix, withCaret.Pix) {
t.Fatalf("area=%v: read-only caret paint not suppressed", area)
}
r.BeginFrame()
draw(false)
r.EndFrame()
if string(text[:zeroIndex(text)]) != "base" || r.FrameOps()[0].Text != "base" {
t.Fatal("read-only input replayed on re-enable")
}
r.SetSelection(26200, 4, 4)
r.QueueText("x")
r.BeginFrame()
draw(false)
r.EndFrame()
if string(text[:zeroIndex(text)]) != "basex" {
t.Fatal("fresh text rejected after re-enable")
}
}
}
+1 -1
View File
@@ -334,7 +334,7 @@ func renderTextInput(img *image.RGBA, op FrameOp) {
}
drawText(img, sliceTextByByteCursor(op.Text, start, end), sx, y, op.FontSize, selected, op.FontID)
}
if op.Focused {
if op.Focused && !op.ReadOnly {
cursorX := x + textAdvance(op.Text, op.Cursor, op.FontSize, op.FontID)
top := int(round(op.Bounds.Y)) + 5
bottom := int(round(op.Bounds.Y+op.Bounds.Height)) - 5
+1573 -284
View File
File diff suppressed because it is too large. Load diff
+17 -17
View File
@@ -737,11 +737,11 @@ func TestFrameOpsRecordRenderableNativeFrame(t *testing.T) {
cursor := int32(len("secret"))
focused := true
rt.QueueTap(18, 42)
rt.QueueTap(18, 50)
rt.BeginFrame()
rt.ClearBackground(WHITE)
rt.Column(ColumnProps{Bounds: Rectangle{X: 10, Y: 10, Width: 180, Height: 160}, Gap: 6, Padding: 4, Key: Key("ops")})
rt.Text("geld", 0, 0, Text16, BLACK)
rt.Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "geld", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
clicked := rt.Button(ButtonProps{Bounds: Rectangle{Width: 90, Height: 28}, Label: "Save", ID: 7, Font: Text16})
rt.TextField(TextFieldProps{
Bounds: Rectangle{Width: 120, Height: 28},
@@ -801,8 +801,8 @@ func TestPageAPIsRecordSemanticFrameOps(t *testing.T) {
rt.PagePicture(PictureProps{AssetPath: "hero.png", Bounds: Rectangle{Width: 120, Height: 60}, Tint: WHITE}, "Hero")
rt.End()
rt.PageGrid(GridProps{Bounds: Rectangle{X: 10, Y: 140, Width: 200, Height: 80}, Columns: 2, Gap: 4, Padding: 4})
rt.Text("A", 0, 0, Text16, BLACK)
rt.Text("B", 0, 0, Text16, BLACK)
rt.Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "A", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
rt.Text(TextProps{Bounds: NewRectangle(0, 0, 0, 0), Text: "B", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
rt.End()
rt.EndFrame()
@@ -851,7 +851,7 @@ func TestFrameOpsResetEachFrame(t *testing.T) {
rt := New(AppConfig{}).(*runtime)
rt.BeginFrame()
rt.Text("first", 10, 10, Text16, BLACK)
rt.Text(TextProps{Bounds: NewRectangle(10, 10, 0, 0), Text: "first", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
rt.EndFrame()
if got, want := len(rt.FrameOps()), 1; got != want {
t.Fatalf("first frame op count = %d, want %d", got, want)
@@ -1847,7 +1847,7 @@ func TestRenderCurrentFramePaintsNativeOps(t *testing.T) {
BeginFrame()
ClearBackground(RAYWHITE)
Text("geld", 12, 12, Text16, BLACK)
Text(TextProps{Bounds: NewRectangle(12, 12, 0, 0), Text: "geld", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
Button(ButtonProps{Bounds: Rectangle{X: 12, Y: 40, Width: 82, Height: 28}, Label: "Save", ID: 1, Font: Text16})
TextField(TextFieldProps{
Bounds: Rectangle{X: 12, Y: 82, Width: 140, Height: 32},
@@ -1878,7 +1878,7 @@ func TestTakeScreenshotWritesCurrentFramePNG(t *testing.T) {
BeginFrame()
ClearBackground(WHITE)
Text("shot", 4, 4, Text16, BLACK)
Text(TextProps{Bounds: NewRectangle(4, 4, 0, 0), Text: "shot", Font: Text16, Color: BLACK, Wrap: TextWrapNone})
EndFrame()
path := filepath.Join(t.TempDir(), "shot.png")
@@ -1978,8 +1978,8 @@ func TestTabBarRecordsOpsAndSelectsOnClick(t *testing.T) {
r := New(AppConfig{Width: 400, Height: 100}).(*runtime)
defer SetRuntime(nil)
SetRuntime(r)
labels := []string{"Alpha", "Beta", "Gamma"}
sel, hov := int32(1), int32(-1)
tabs := []Tab{{Label: "Alpha"}, {Label: "Beta"}, {Label: "Gamma"}}
sel := int32(1)
BeginFrame()
EndFrame()
@@ -1987,7 +1987,11 @@ func TestTabBarRecordsOpsAndSelectsOnClick(t *testing.T) {
r.QueueMouseMove(350, 10)
r.QueueMouseButton(MouseButtonLeft, 350, 10)
BeginFrame() // the queued input lands on the next frame's state
clicked := TabBar(NewRectangle(0, 0, 400, 30), labels, &sel, &hov)
clicked := TabBar(TabBarProps{Bounds: NewRectangle(0, 0, 400, 30), Tabs: tabs,
Count: int32(len(tabs)), SelectedIndex: sel, ID: 901})
if clicked >= 0 {
sel = clicked
}
ops := FrameOps()
buttons := 0
var active *FrameOp
@@ -1997,15 +2001,12 @@ func TestTabBarRecordsOpsAndSelectsOnClick(t *testing.T) {
active = &ops[i]
}
}
if buttons != len(labels) {
t.Fatalf("recorded %d tab buttons, want %d", buttons, len(labels))
if buttons != len(tabs) {
t.Fatalf("recorded %d tab buttons, want %d", buttons, len(tabs))
}
if clicked != 2 || sel != 2 {
t.Fatalf("click selected %d (sel=%d), want 2", clicked, sel)
}
if hov != 2 {
t.Fatalf("hover = %d, want 2", hov)
}
if active == nil || active.Text != "Gamma" || !active.Pressed {
t.Fatalf("last tab op = %+v, want active Gamma", active)
}
@@ -2016,9 +2017,8 @@ func TestTabBarEmptyLabels(t *testing.T) {
r := New(AppConfig{Width: 100, Height: 30}).(*runtime)
defer SetRuntime(nil)
SetRuntime(r)
sel := int32(0)
BeginFrame()
if got := TabBar(NewRectangle(0, 0, 100, 30), nil, &sel, nil); got != -1 {
if got := TabBar(TabBarProps{Bounds: NewRectangle(0, 0, 100, 30)}); got != -1 {
t.Fatalf("TabBar with no labels = %d, want -1", got)
}
EndFrame()
+69
View File
@@ -0,0 +1,69 @@
package kryon
// BeginTabBar renders the canonical tab header and opens a scope in which
// BeginTabItem exposes only the selected tab's arbitrary child widgets.
func (r *runtime) BeginTabBar(props TabBarProps, selectedIndex *int32) bool {
count := props.Count
if count <= 0 || count > int32(len(props.Tabs)) {
count = int32(len(props.Tabs))
}
if count <= 0 || props.Bounds.Width <= 0 || props.Bounds.Height <= 0 {
return false
}
selected := props.SelectedIndex
if selectedIndex != nil {
selected = *selectedIndex
}
if selected < 0 || selected >= count {
selected = 0
}
props.Count = count
props.SelectedIndex = selected
if clicked := r.TabBar(props); clicked >= 0 {
selected = clicked
}
if selectedIndex != nil {
*selectedIndex = selected
}
r.tabBarScopes = append(r.tabBarScopes, tabBarScope{
count: count,
selected: selected,
})
return true
}
func (r *runtime) BeginTabItem(index int32) bool {
if len(r.tabBarScopes) == 0 {
panic("BeginTabItem without BeginTabBar")
}
scope := &r.tabBarScopes[len(r.tabBarScopes)-1]
if scope.itemOpen {
panic("BeginTabItem before EndTabItem")
}
if index < 0 || index >= scope.count || index != scope.selected {
return false
}
scope.itemOpen = true
return true
}
func (r *runtime) EndTabItem() {
if len(r.tabBarScopes) == 0 ||
!r.tabBarScopes[len(r.tabBarScopes)-1].itemOpen {
panic("EndTabItem without selected BeginTabItem")
}
r.tabBarScopes[len(r.tabBarScopes)-1].itemOpen = false
}
func (r *runtime) EndTabBar() {
if len(r.tabBarScopes) == 0 {
panic("EndTabBar without BeginTabBar")
}
n := len(r.tabBarScopes)
if r.tabBarScopes[n-1].itemOpen {
panic("EndTabBar before EndTabItem")
}
r.tabBarScopes[n-1] = tabBarScope{}
r.tabBarScopes = r.tabBarScopes[:n-1]
}
+10
View File
@@ -34,6 +34,16 @@ type windowRuntime struct {
dirty bool
}
func (w *windowRuntime) textWithFont(props TextProps, fontID uint32) {
if runtime, ok := w.Runtime.(interface {
textWithFont(TextProps, uint32)
}); ok {
runtime.textWithFont(props, fontID)
return
}
w.Runtime.Text(props)
}
type legacyPointerController interface {
QueueMouseButton(int32, float32, float32)
QueueMouseWheel(float32)
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 142 KiB

+13 -4
View File
@@ -1,14 +1,14 @@
{
"version": 1,
"sheet": "ui",
"icon_count": 56,
"icon_count": 57,
"image": "ui.png",
"cell_size": 64,
"content_size": 48,
"columns": 8,
"rows": 7,
"rows": 8,
"width": 512,
"height": 448,
"height": 512,
"icons": [
{
"index": 0,
@@ -513,9 +513,18 @@
"width": 64,
"height": 64,
"upstream": "core/filled/close.svg"
},
{
"index": 56,
"name": "warning",
"x": 0,
"y": 448,
"width": 64,
"height": 64,
"upstream": "core/regular/system/alert.svg"
}
],
"style": "mingcute-core-filled",
"style": "mingcute-core",
"tintable": true,
"license": "Apache-2.0",
"upstream": "https://github.com/mingcute-design/mingcute-icons",
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

+1 -1
View File
@@ -3,7 +3,7 @@
*
* Streaming interface plus a one-shot file hasher used by kry_update to
* verify downloaded artifacts against an appcast digest. No external
* dependencies; the ksync crypto stack intentionally stays separate.
* dependencies; the account sync crypto stack intentionally stays separate.
*/
#ifndef KRYON_KRY_SHA256_H
#define KRYON_KRY_SHA256_H
+5 -5
View File
@@ -48,10 +48,10 @@
#include "ui_text_layout.h"
#include "ui_transition.h"
#include "locale.h"
#if (defined(KRYON_WITH_DAOCHI) && KRYON_WITH_DAOCHI) || \
(defined(KRYON_WITH_KSYNC) && KRYON_WITH_KSYNC)
#include "ksync_account.h"
#include "ksync_sync.h"
#if defined(KRYON_WITH_SYNC) && KRYON_WITH_SYNC
#include "sync/account.h"
#include "sync.h"
#include "sync_nodes.h"
#endif
#include "theme.h"
#include "theme_meta.h"
@@ -95,7 +95,7 @@
* layout or a public function changes signature; KryonAbiVersion() is
* compiled into libkryon.a, while the macro is read from the current
* headers — a mismatch means the archive is stale and must be rebuilt. */
#define KRYON_ABI_VERSION 7
#define KRYON_ABI_VERSION 10
int KryonAbiVersion(void);
#endif /* KRYON_H */
+2 -2
View File
@@ -3,7 +3,7 @@
#define KRYON_VERSION_MAJOR 0
#define KRYON_VERSION_MINOR 1
#define KRYON_VERSION_PATCH 53
#define KRYON_VERSION_STRING "v0.1.53"
#define KRYON_VERSION_PATCH 76
#define KRYON_VERSION_STRING "v0.1.76"
#endif /* KRYON_VERSION_H */
-50
View File
@@ -1,50 +0,0 @@
#ifndef KSYNC_ACCOUNT_H
#define KSYNC_ACCOUNT_H
#include <stddef.h>
#include <stdint.h>
enum {
KSYNC_PUBLIC_ID_HEX_SIZE = 65,
KSYNC_PUBLIC_KEY_HEX_SIZE = 2625,
KSYNC_PRIVATE_KEY_HEX_SIZE = 5121,
KSYNC_SIGNATURE_HEX_SIZE = 4841,
KSYNC_ACCOUNT_EXPORT_TEXT_SIZE = 8200,
/* v2 encrypted export: ciphertext is the v1 text plus a 16-byte tag,
* hex encoded, plus header lines */
KSYNC_ACCOUNT_EXPORT_ENCRYPTED_TEXT_SIZE = 17664,
KSYNC_ACCOUNT_PASSPHRASE_ITERATIONS = 600000
};
typedef struct KsyncAccount {
char public_id[KSYNC_PUBLIC_ID_HEX_SIZE];
char public_key_hex[KSYNC_PUBLIC_KEY_HEX_SIZE];
char private_key_hex[KSYNC_PRIVATE_KEY_HEX_SIZE];
} KsyncAccount;
int IsKsyncAccountAvailable(void);
int HasKsyncAccountValues(const KsyncAccount *account);
int CreateKsyncAccount(KsyncAccount *account);
int ValidateKsyncAccount(KsyncAccount *account);
const char *GetKsyncAccountLastError(void);
int ParseKsyncAccountText(const char *text, KsyncAccount *account);
int ExportKsyncAccountText(const KsyncAccount *account, char *out, size_t out_size);
int ImportKsyncAccountFile(const char *filename, KsyncAccount *account);
int ExportKsyncAccountFile(const KsyncAccount *account, const char *filename);
/* Passphrase-protected export: PBKDF2-SHA256 key derivation plus
* ChaCha20-Poly1305 authenticated encryption. The v1 plaintext export
* remains available for compatibility. */
int ExportKsyncAccountTextEncrypted(const KsyncAccount *account, const char *passphrase,
char *out, size_t out_size);
int ExportKsyncAccountFileEncrypted(const KsyncAccount *account, const char *passphrase,
const char *filename);
int ParseKsyncAccountTextEncrypted(const char *text, const char *passphrase,
KsyncAccount *account);
int ImportKsyncAccountFileEncrypted(const char *filename, const char *passphrase,
KsyncAccount *account);
void KsyncSha256Hex(const uint8_t *data, size_t len, char out_hex[KSYNC_PUBLIC_ID_HEX_SIZE]);
int SignKsyncAccountHex(const KsyncAccount *account, const uint8_t *message,
size_t message_len, char *out_signature_hex,
size_t out_size);
#endif
-31
View File
@@ -1,31 +0,0 @@
#ifndef KSYNC_CRYPTO_H
#define KSYNC_CRYPTO_H
#include <stddef.h>
#include <stdint.h>
void KsyncCryptoSha256(const uint8_t *data, size_t len, uint8_t out[32]);
void KsyncCryptoHmacSha256(const uint8_t *key, size_t key_len,
const uint8_t *data, size_t data_len,
uint8_t out[32]);
void KsyncCryptoPbkdf2Sha256(const uint8_t *password, size_t password_len,
const uint8_t *salt, size_t salt_len,
unsigned long iterations, uint8_t out[32]);
/* AEAD: ciphertext_and_tag must have plain_len + 16 bytes; returns 0 on
* forgery or bad input. */
int KsyncCryptoChaCha20Poly1305Seal(const uint8_t key[32], const uint8_t nonce[12],
const uint8_t *plain, size_t plain_len,
const uint8_t *aad, size_t aad_len,
uint8_t *ciphertext_and_tag);
int KsyncCryptoChaCha20Poly1305Open(const uint8_t key[32], const uint8_t nonce[12],
const uint8_t *ciphertext_and_tag, size_t total_len,
const uint8_t *aad, size_t aad_len,
uint8_t *plain);
void KsyncCryptoRandom(uint8_t *out, size_t len);
int KsyncCryptoBytesToHex(const uint8_t *bytes, size_t len, char *out, size_t out_size);
int KsyncCryptoHexToBytes(const char *hex, uint8_t *out, size_t out_len);
#endif
-118
View File
@@ -1,118 +0,0 @@
#ifndef KSYNC_SYNC_H
#define KSYNC_SYNC_H
#include "ksync_account.h"
#include <stddef.h>
typedef enum KsyncSyncResult {
KSYNC_SYNC_OK = 0,
KSYNC_SYNC_INVALID_URL,
KSYNC_SYNC_NO_ACCOUNT,
KSYNC_SYNC_PAYLOAD_FAILED,
KSYNC_SYNC_CHALLENGE_FAILED,
KSYNC_SYNC_SIGN_FAILED,
KSYNC_SYNC_REQUEST_FAILED,
KSYNC_SYNC_AUTH_FAILED
} KsyncSyncResult;
typedef struct KsyncSyncBuffer {
char *data;
size_t len;
size_t cap;
} KsyncSyncBuffer;
typedef int (*KsyncSyncHttpRequestFn)(const char *method, const char *url,
const char *body,
const char *const *headers,
int header_count,
KsyncSyncBuffer *response,
long *status, void *user);
typedef const char *(*KsyncSyncGetTextFn)(const char *key, void *user);
typedef void (*KsyncSyncSetTextFn)(const char *key, const char *value, void *user);
typedef char *(*KsyncSyncBuildPayloadFn)(const char *user_id_hash,
const char *public_key_hex, void *user);
typedef void (*KsyncSyncFreePayloadFn)(char *payload, void *user);
typedef int (*KsyncSyncApplyResponseFn)(const char *response_json, void *user);
typedef void (*KsyncSyncVoidFn)(void *user);
typedef void (*KsyncSyncLogFn)(const char *step, long status,
const char *response, void *user);
typedef struct KsyncSyncConfig {
const char *base_url;
const KsyncAccount *account;
const char *client_id;
const char *signature_context;
const char *user_header_name;
const char *signature_header_name;
KsyncSyncHttpRequestFn http_request;
KsyncSyncGetTextFn get_text;
KsyncSyncSetTextFn set_text;
KsyncSyncBuildPayloadFn build_payload;
KsyncSyncFreePayloadFn free_payload;
KsyncSyncApplyResponseFn apply_response;
KsyncSyncVoidFn purge_synced_deleted;
KsyncSyncLogFn log_http_failure;
/* Retry policy for transient failures (transport errors, 429, 5xx).
* Retries only happen when sleep_ms is provided; without it the single
* attempt behaviour is unchanged. Delay grows exponentially:
* retry_delay_ms << attempt, capped at 30s. */
int retry_max;
int retry_delay_ms;
void (*sleep_ms)(int ms, void *user);
/* When set, RunKsyncSync encrypts the outgoing payload with a key
* derived from the account and decrypts envelope responses before
* apply_response (server sees opaque ciphertext). */
int encrypt_payload;
void *user;
} KsyncSyncConfig;
const char *GetKsyncSyncResultName(KsyncSyncResult result);
int IsKsyncSyncURLValid(const char *url);
int NormalizeKsyncSyncURL(const char *input, char *out, size_t out_size);
int JoinKsyncSyncURL(char *out, size_t out_size,
const char *base_url, const char *path);
int JoinKsyncSyncWebSocketURL(char *out, size_t out_size,
const char *base_url, const char *path);
int AppendKsyncSyncBuffer(KsyncSyncBuffer *buffer,
const void *data, size_t bytes);
int AppendKsyncSyncBufferJSONString(KsyncSyncBuffer *buffer,
const char *text);
void FreeKsyncSyncBuffer(KsyncSyncBuffer *buffer);
int FindKsyncSyncJSONString(const char *json, const char *key,
char *out, size_t out_size);
long long FindKsyncSyncJSONInt64(const char *json, const char *key,
long long fallback);
void ClearKsyncSyncAuthToken(const KsyncSyncConfig *cfg);
KsyncSyncResult LoginKsyncSync(const KsyncSyncConfig *cfg);
KsyncSyncResult RunKsyncSync(const KsyncSyncConfig *cfg);
KsyncSyncResult RequestKsyncSyncBearer(const KsyncSyncConfig *cfg,
const char *method,
const char *path,
const char *body,
char *out,
size_t out_size);
KsyncSyncResult DeleteKsyncSyncAccount(const KsyncSyncConfig *cfg);
/* Opt-in end-to-end payload encryption. v1 envelopes seal plaintext JSON.
* v2 envelopes compress plaintext first when that reduces size, then seal
* the compressed bytes. Both versions use ChaCha20-Poly1305 under a key
* derived from the account private key. Unwrap returns 0 for input that is
* not an envelope. Caller frees *out. */
int WrapKsyncSyncPayload(const KsyncAccount *account, const char *payload, char **out);
int UnwrapKsyncSyncPayload(const KsyncAccount *account, const char *envelope_json, char **out);
int KsyncDefaultHttpRequest(const char *method, const char *url,
const char *body,
const char *const *headers,
int header_count,
KsyncSyncBuffer *response,
long *status, void *user);
KsyncSyncResult KsyncRemoteEventWait(const KsyncSyncConfig *cfg,
const char *path);
#if defined(__EMSCRIPTEN__)
int KsyncWebSyncStart(const KsyncSyncConfig *cfg);
int KsyncWebSyncPoll(KsyncSyncResult *result, int *changed);
int KsyncWebRemoteEventsStart(const KsyncSyncConfig *cfg, const char *path);
int KsyncWebRemoteEventsPoll(void);
#endif
#endif
+120
View File
@@ -0,0 +1,120 @@
#ifndef SYNC_H
#define SYNC_H
#include "sync/account.h"
#include <stddef.h>
typedef enum SyncResult {
SYNC_OK = 0,
SYNC_INVALID_URL,
SYNC_NO_ACCOUNT,
SYNC_PAYLOAD_FAILED,
SYNC_CHALLENGE_FAILED,
SYNC_SIGN_FAILED,
SYNC_REQUEST_FAILED,
SYNC_AUTH_FAILED
} SyncResult;
typedef struct SyncBuffer {
char *data;
size_t len;
size_t cap;
} SyncBuffer;
typedef int (*SyncHttpRequestFn)(const char *method, const char *url,
const char *body,
const char *const *headers,
int header_count,
SyncBuffer *response,
long *status, void *user);
typedef const char *(*SyncGetTextFn)(const char *key, void *user);
typedef void (*SyncSetTextFn)(const char *key, const char *value, void *user);
typedef char *(*SyncBuildPayloadFn)(const char *user_id_hash,
const char *public_key_hex, void *user);
typedef void (*SyncFreePayloadFn)(char *payload, void *user);
typedef int (*SyncApplyResponseFn)(const char *response_json, void *user);
typedef void (*SyncVoidFn)(void *user);
typedef void (*SyncLogFn)(const char *step, long status,
const char *response, void *user);
typedef struct SyncConfig {
const char *base_url;
const SyncAccount *account;
const char *client_id;
const char *app_id;
int protocol_version;
const char *signature_context;
const char *user_header_name;
const char *signature_header_name;
SyncHttpRequestFn http_request;
SyncGetTextFn get_text;
SyncSetTextFn set_text;
SyncBuildPayloadFn build_payload;
SyncFreePayloadFn free_payload;
SyncApplyResponseFn apply_response;
SyncVoidFn purge_synced_deleted;
SyncLogFn log_http_failure;
/* Retry policy for transient failures (transport errors, 429, 5xx).
* Retries only happen when sleep_ms is provided; without it the single
* attempt behaviour is unchanged. Delay grows exponentially:
* retry_delay_ms << attempt, capped at 30s. */
int retry_max;
int retry_delay_ms;
void (*sleep_ms)(int ms, void *user);
/* When set, RunSync encrypts the outgoing payload with a key
* derived from the account and decrypts envelope responses before
* apply_response (server sees opaque ciphertext). */
int encrypt_payload;
void *user;
} SyncConfig;
const char *GetSyncResultName(SyncResult result);
int IsSyncURLValid(const char *url);
int NormalizeSyncURL(const char *input, char *out, size_t out_size);
int JoinSyncURL(char *out, size_t out_size,
const char *base_url, const char *path);
int JoinSyncWebSocketURL(char *out, size_t out_size,
const char *base_url, const char *path);
int AppendSyncBuffer(SyncBuffer *buffer,
const void *data, size_t bytes);
int AppendSyncBufferJSONString(SyncBuffer *buffer,
const char *text);
void FreeSyncBuffer(SyncBuffer *buffer);
int FindSyncJSONString(const char *json, const char *key,
char *out, size_t out_size);
long long FindSyncJSONInt64(const char *json, const char *key,
long long fallback);
void ClearSyncAuthToken(const SyncConfig *cfg);
SyncResult LoginSync(const SyncConfig *cfg);
SyncResult RunSync(const SyncConfig *cfg);
SyncResult RequestSyncBearer(const SyncConfig *cfg,
const char *method,
const char *path,
const char *body,
char *out,
size_t out_size);
SyncResult DeleteSyncAccount(const SyncConfig *cfg);
/* Opt-in end-to-end payload encryption. v1 envelopes seal plaintext JSON.
* v2 envelopes compress plaintext first when that reduces size, then seal
* the compressed bytes. Both versions use ChaCha20-Poly1305 under a key
* derived from the account private key. Unwrap returns 0 for input that is
* not an envelope. Caller frees *out. */
int WrapSyncPayload(const SyncAccount *account, const char *payload, char **out);
int UnwrapSyncPayload(const SyncAccount *account, const char *envelope_json, char **out);
int DefaultSyncHttpRequest(const char *method, const char *url,
const char *body,
const char *const *headers,
int header_count,
SyncBuffer *response,
long *status, void *user);
SyncResult WaitForRemoteSyncEvent(const SyncConfig *cfg,
const char *path);
#if defined(__EMSCRIPTEN__)
int StartWebSync(const SyncConfig *cfg);
int PollWebSync(SyncResult *result, int *changed);
int StartWebRemoteEvents(const SyncConfig *cfg, const char *path);
int PollWebRemoteEvents(void);
#endif
#endif
+49
View File
@@ -0,0 +1,49 @@
#ifndef SYNC_ACCOUNT_H
#define SYNC_ACCOUNT_H
#include <stddef.h>
#include <stdint.h>
enum {
SYNC_PUBLIC_ID_HEX_SIZE = 65,
SYNC_PUBLIC_KEY_HEX_SIZE = 2625,
SYNC_PRIVATE_KEY_HEX_SIZE = 5121,
SYNC_SIGNATURE_HEX_SIZE = 4841,
SYNC_ACCOUNT_EXPORT_TEXT_SIZE = 8200,
/* v2 encrypted export: ciphertext is the v1 text plus a 16-byte tag,
* hex encoded, plus header lines */
SYNC_ACCOUNT_EXPORT_ENCRYPTED_TEXT_SIZE = 17664,
SYNC_ACCOUNT_PASSPHRASE_ITERATIONS = 600000
};
typedef struct SyncAccount {
char public_id[SYNC_PUBLIC_ID_HEX_SIZE];
char public_key_hex[SYNC_PUBLIC_KEY_HEX_SIZE];
char private_key_hex[SYNC_PRIVATE_KEY_HEX_SIZE];
} SyncAccount;
int IsSyncAccountAvailable(void);
int HasSyncAccountValues(const SyncAccount *account);
int CreateSyncAccount(SyncAccount *account);
int ValidateSyncAccount(SyncAccount *account);
const char *GetSyncAccountLastError(void);
int ParseSyncAccountText(const char *text, SyncAccount *account);
int ExportSyncAccountText(const SyncAccount *account, char *out, size_t out_size);
int ImportSyncAccountFile(const char *filename, SyncAccount *account);
int ExportSyncAccountFile(const SyncAccount *account, const char *filename);
/* Passphrase-protected export: PBKDF2-SHA256 key derivation plus
* ChaCha20-Poly1305 authenticated encryption. The v1 plaintext export
* remains available for compatibility. */
int ExportSyncAccountTextEncrypted(const SyncAccount *account, const char *passphrase,
char *out, size_t out_size);
int ExportSyncAccountFileEncrypted(const SyncAccount *account, const char *passphrase,
const char *filename);
int ParseSyncAccountTextEncrypted(const char *text, const char *passphrase,
SyncAccount *account);
int ImportSyncAccountFileEncrypted(const char *filename, const char *passphrase,
SyncAccount *account);
int SignSyncAccountHex(const SyncAccount *account, const uint8_t *message,
size_t message_len, char *out_signature_hex,
size_t out_size);
#endif
+48
View File
@@ -0,0 +1,48 @@
#ifndef SYNC_CRYPTO_H
#define SYNC_CRYPTO_H
#include <stddef.h>
#include <stdint.h>
enum {
SYNC_SHA256_HEX_SIZE = 65,
SYNC_ED25519_PUBLIC_KEY_SIZE = 32,
SYNC_ED25519_PRIVATE_KEY_SIZE = 64,
SYNC_ED25519_SIGNATURE_SIZE = 64
};
void SyncCryptoSha256(const uint8_t *data, size_t len, uint8_t out[32]);
void SyncCryptoSha256Hex(const uint8_t *data, size_t len,
char out_hex[SYNC_SHA256_HEX_SIZE]);
void SyncCryptoHmacSha256(const uint8_t *key, size_t key_len,
const uint8_t *data, size_t data_len,
uint8_t out[32]);
void SyncCryptoPbkdf2Sha256(const uint8_t *password, size_t password_len,
const uint8_t *salt, size_t salt_len,
unsigned long iterations, uint8_t out[32]);
/* AEAD: ciphertext_and_tag must have plain_len + 16 bytes; returns 0 on
* forgery or bad input. */
int SyncCryptoChaCha20Poly1305Seal(const uint8_t key[32], const uint8_t nonce[12],
const uint8_t *plain, size_t plain_len,
const uint8_t *aad, size_t aad_len,
uint8_t *ciphertext_and_tag);
int SyncCryptoChaCha20Poly1305Open(const uint8_t key[32], const uint8_t nonce[12],
const uint8_t *ciphertext_and_tag, size_t total_len,
const uint8_t *aad, size_t aad_len,
uint8_t *plain);
void SyncCryptoRandom(uint8_t *out, size_t len);
int SyncCryptoBytesToHex(const uint8_t *bytes, size_t len, char *out, size_t out_size);
int SyncCryptoHexToBytes(const char *hex, uint8_t *out, size_t out_len);
int SyncCryptoCreateDeviceKey(uint8_t private_key[SYNC_ED25519_PRIVATE_KEY_SIZE],
uint8_t public_key[SYNC_ED25519_PUBLIC_KEY_SIZE]);
void SyncCryptoSignDevice(const uint8_t private_key[SYNC_ED25519_PRIVATE_KEY_SIZE],
const uint8_t *message, size_t message_len,
uint8_t signature[SYNC_ED25519_SIGNATURE_SIZE]);
int SyncCryptoVerifyDevice(const uint8_t public_key[SYNC_ED25519_PUBLIC_KEY_SIZE],
const uint8_t *message, size_t message_len,
const uint8_t signature[SYNC_ED25519_SIGNATURE_SIZE]);
#endif
+53
View File
@@ -0,0 +1,53 @@
#ifndef SYNC_NODES_H
#define SYNC_NODES_H
#include "sync.h"
#include <stddef.h>
enum {
SYNC_NODE_POOL_CAPACITY = 8,
SYNC_NODE_ID_SIZE = 65,
SYNC_NODE_NAME_SIZE = 80,
SYNC_NODE_URL_SIZE = 512
};
typedef enum SyncNodeTrust {
SYNC_NODE_PUBLIC = 0,
SYNC_NODE_PAIRED = 1
} SyncNodeTrust;
typedef struct SyncNode {
char id[SYNC_NODE_ID_SIZE];
char name[SYNC_NODE_NAME_SIZE];
char url[SYNC_NODE_URL_SIZE];
SyncNodeTrust trust;
int local;
int consecutive_failures;
long long retry_after;
} SyncNode;
typedef struct SyncNodePool {
SyncNode nodes[SYNC_NODE_POOL_CAPACITY];
int count;
int active_index;
} SyncNodePool;
void InitSyncNodePool(SyncNodePool *pool);
int AddSyncNode(SyncNodePool *pool, const char *id, const char *name,
const char *url, SyncNodeTrust trust, int local);
const SyncNode *SelectSyncNode(const SyncNodePool *pool, long long now);
const SyncNode *GetActiveSyncNode(const SyncNodePool *pool);
void MarkSyncNodeResult(SyncNodePool *pool, int index, int succeeded,
long long now);
int BuildSyncNodeStorageKey(const SyncNode *node, const char *key,
char *out, size_t out_size);
/* Tries paired local nodes first, then other paired nodes, then public nodes.
* Authentication tokens and clock skew are stored under a node-specific key.
* Payload or account failures are returned immediately; connectivity and
* authentication failures continue to the next eligible node. */
SyncResult RunSyncWithNodes(SyncNodePool *pool,
const SyncConfig *config);
#endif
+9 -3
View File
@@ -195,6 +195,7 @@ typedef struct UIStyleTokens {
float panel_radius;
unsigned char control_alpha;
unsigned char panel_alpha;
unsigned char title_bar_alpha;
unsigned char border_alpha;
unsigned char shadow_alpha;
unsigned char shine_alpha;
@@ -226,7 +227,7 @@ typedef void (*UIVerticalSliderMarkCallback)(void *user_data, int x, int y,
typedef struct {
const char *label;
const char *font_name;
} UIDropdownOption;
} DropdownOption;
typedef struct {
const char *label;
@@ -285,6 +286,13 @@ int EditText(TextEdit edit);
void QueueTextInputCodepoint(int codepoint);
void QueueTextInputBackspace(void);
void QueueTextInputEnter(void);
int TextBufferLineAtCursor(const char *text, int cursor);
int TextBufferColumnAtCursor(const char *text, int cursor);
int TextBufferLineCount(const char *text);
int TextBufferToggleLineComment(char *text, int text_size, int *cursor);
int TextBufferIndentLine(char *text, int text_size, int *cursor, int outdent);
int TextBufferBracketMatch(const char *text, int cursor);
Rectangle TextAreaGutter(TextAreaProps area, int gutter_width);
int GetTextAreaSelection(int focus_id, int *start, int *end);
void SetTextAreaSelection(int focus_id, int anchor, int cursor);
@@ -299,7 +307,5 @@ SegmentedControlResult SegmentedControl(SegmentedControlProps control);
int GetScoreControlHeight(ScoreControlProps control);
ScoreControlResult ScoreControl(ScoreControlProps control);
void SetUIDropdownClipTop(int top);
void SetUIDropdownClipBottom(int bottom);
#endif
+10 -2
View File
@@ -7,10 +7,15 @@
#define UI_DPI_BASE_HEIGHT 560
typedef struct UIDPIState {
int physical_width;
int physical_height;
int view_width;
int view_height;
int layout_width;
int layout_height;
float ui_scale;
float ui_scale_clamped;
float render_scale;
float camera_zoom;
int base_width;
int base_height;
@@ -25,9 +30,12 @@ void InvalidateUIDPI(void);
void SetUIDeviceDensity(float density);
void UpdateUIDPI(int view_width, int view_height);
int IsUIDPIDirty(void);
int GetLayoutWidth(void);
int GetLayoutHeight(void);
float GetRenderScale(void);
static inline float GetUIDPIScale(void) { return ui_dpi_state.ui_scale_clamped; }
static inline int GetUIDPIViewWidth(void) { return ui_dpi_state.view_width; }
static inline int GetUIDPIViewHeight(void) { return ui_dpi_state.view_height; }
static inline int GetUIDPIViewWidth(void) { return ui_dpi_state.layout_width; }
static inline int GetUIDPIViewHeight(void) { return ui_dpi_state.layout_height; }
static inline float GetUIDPICameraZoom(void) { return ui_dpi_state.camera_zoom; }
#endif
+1 -2
View File
@@ -13,6 +13,7 @@ typedef struct {
int font;
int line_gap;
Color color;
int align;
} ParagraphSpec;
int GetFontSize(void);
@@ -22,8 +23,6 @@ int FitFontSize(const char *text, int max_width,
int preferred_size, int min_size);
int GetUIControlTextY(const char *text, int box_y, int box_h, int font);
void DrawCenteredUIControlText(const char *text, int center_x, int center_y,
int font, Color color);
void DrawLeftUIControlTextInRect(const char *text, Rectangle rect,
int font_size, Color color);
void DrawFittedTextInRect(const char *text, Rectangle rect,
+2 -1
View File
@@ -117,6 +117,7 @@ typedef enum {
UI_ICON_TYPE_TODOS,
UI_ICON_TYPE_TRASH,
UI_ICON_TYPE_VENUS,
UI_ICON_TYPE_WARNING,
UI_ICON_TYPE_WEEKLY,
UI_ICON_TYPE_WORKBOOK_CLEAR_FORMATTING,
UI_ICON_TYPE_WORKBOOK_FILL_COLOR,
@@ -124,7 +125,7 @@ typedef enum {
UI_ICON_TYPE_WRENCH,
UI_ICON_TYPE_X,
UI_ICON_TYPE_COUNT = 119
UI_ICON_TYPE_COUNT = 120
} UIIconType;
#endif /* UI_ICON_TYPES_H */
+1
View File
@@ -28,6 +28,7 @@ Texture2D LoadIconSheet(UIIconSheet sheet);
void UnloadIconSheets(void);
void DrawIcon(UIIconType type, Rectangle bounds, Color tint);
void DrawIconByName(const char *name, Rectangle bounds, Color tint);
void DrawProfilePictureIcon(UIIconType type, Rectangle bounds, int dark_mode);
/* Transitional texture API for controls that do not yet accept UIIconType. */
Texture2D LoadUIIconTexture(UIIconType type);
+2
View File
@@ -221,6 +221,8 @@ typedef struct {
int *reordered_to_index;
Rectangle *selected_tab_bounds;
int *middle_clicked_index;
int id;
int disabled;
} TabBarProps;
typedef enum {
+30 -30
View File
@@ -44,39 +44,39 @@ typedef struct {
} ProfilePicturePickerResult;
typedef enum {
UI_KSYNC_PROFILE_ICON_NONE = 0,
UI_KSYNC_PROFILE_ICON_BIRD = 1,
UI_KSYNC_PROFILE_ICON_BOWL = 2,
UI_KSYNC_PROFILE_ICON_CACTUS = 3,
UI_KSYNC_PROFILE_ICON_HEART = 4,
UI_KSYNC_PROFILE_ICON_INCENSE = 5,
UI_KSYNC_PROFILE_ICON_LOTUS = 6,
UI_KSYNC_PROFILE_ICON_TREE1 = 7,
UI_KSYNC_PROFILE_ICON_TREE2 = 8,
UI_KSYNC_PROFILE_ICON_TREE3 = 9,
UI_KSYNC_PROFILE_ICON_TREE4 = 10,
UI_KSYNC_PROFILE_ICON_TREE5 = 11,
UI_KSYNC_PROFILE_ICON_BAMBUS = 12,
UI_KSYNC_PROFILE_ICON_BUSH = 13,
UI_KSYNC_PROFILE_ICON_COFFEE = 14,
UI_KSYNC_PROFILE_ICON_FLOWER1 = 15,
UI_KSYNC_PROFILE_ICON_FLOWER2 = 16,
UI_KSYNC_PROFILE_ICON_MOUNTAIN = 17,
UI_KSYNC_PROFILE_ICON_MUSHROOM = 18,
UI_KSYNC_PROFILE_ICON_PERSON1 = 19,
UI_KSYNC_PROFILE_ICON_RAINBOW = 20,
UI_KSYNC_PROFILE_ICON_TENT = 21,
UI_KSYNC_PROFILE_ICON_BUTTERFLY = 22,
UI_KSYNC_PROFILE_ICON_DRAGONFLY = 23,
UI_KSYNC_PROFILE_ICON_FIREPLACE = 24,
UI_KSYNC_PROFILE_ICON_FOX = 25,
UI_KSYNC_PROFILE_ICON_PALM = 26
} UIKsyncProfileIcon;
UI_SYNC_PROFILE_ICON_NONE = 0,
UI_SYNC_PROFILE_ICON_BIRD = 1,
UI_SYNC_PROFILE_ICON_BOWL = 2,
UI_SYNC_PROFILE_ICON_CACTUS = 3,
UI_SYNC_PROFILE_ICON_HEART = 4,
UI_SYNC_PROFILE_ICON_INCENSE = 5,
UI_SYNC_PROFILE_ICON_LOTUS = 6,
UI_SYNC_PROFILE_ICON_TREE1 = 7,
UI_SYNC_PROFILE_ICON_TREE2 = 8,
UI_SYNC_PROFILE_ICON_TREE3 = 9,
UI_SYNC_PROFILE_ICON_TREE4 = 10,
UI_SYNC_PROFILE_ICON_TREE5 = 11,
UI_SYNC_PROFILE_ICON_BAMBUS = 12,
UI_SYNC_PROFILE_ICON_BUSH = 13,
UI_SYNC_PROFILE_ICON_COFFEE = 14,
UI_SYNC_PROFILE_ICON_FLOWER1 = 15,
UI_SYNC_PROFILE_ICON_FLOWER2 = 16,
UI_SYNC_PROFILE_ICON_MOUNTAIN = 17,
UI_SYNC_PROFILE_ICON_MUSHROOM = 18,
UI_SYNC_PROFILE_ICON_PERSON1 = 19,
UI_SYNC_PROFILE_ICON_RAINBOW = 20,
UI_SYNC_PROFILE_ICON_TENT = 21,
UI_SYNC_PROFILE_ICON_BUTTERFLY = 22,
UI_SYNC_PROFILE_ICON_DRAGONFLY = 23,
UI_SYNC_PROFILE_ICON_FIREPLACE = 24,
UI_SYNC_PROFILE_ICON_FOX = 25,
UI_SYNC_PROFILE_ICON_PALM = 26
} UISyncProfileIcon;
int GetUIProfilePictureIconCount(void);
UIIconType GetUIProfilePictureIconType(int index);
const char *GetUIProfilePictureIconName(int index);
UIIconType GetUIProfilePictureIconTypeForKsyncID(int ksync_id);
int GetUIKsyncIDForProfilePictureIconType(UIIconType type);
UIIconType GetUIProfilePictureIconTypeForSyncID(int sync_id);
int GetUISyncIDForProfilePictureIconType(UIIconType type);
#endif
+1 -1
View File
@@ -10,7 +10,7 @@ void SetUIScale(float scale);
float GetUIScale(void);
// Scale a pixel value by the DPI factor
int ScaleUIPx(int px);
int Scale(int px);
// Scale and clamp a pixel value between min and max
int ClampUIPx(int px, int min_px, int max_px);
+67 -8
View File
@@ -245,6 +245,28 @@ typedef struct {
int disabled;
} InvisibleButtonProps;
typedef enum {
TextWrapAuto = 0,
TextWrapNone
} TextWrap;
typedef enum {
TextAlignStart = 0,
TextAlignCenter,
TextAlignEnd
} TextAlign;
typedef struct {
Rectangle bounds;
const char *text;
int font;
Color color;
TextWrap wrap;
TextAlign align;
TextAlign vertical_align;
int disabled;
} TextProps;
typedef struct {
Rectangle bounds;
const char *label;
@@ -314,14 +336,6 @@ typedef struct {
int disabled;
} ColorButtonProps;
typedef struct {
Rectangle trigger;
const char *text;
int font;
int max_width;
int disabled;
} TooltipProps;
typedef struct {
Rectangle bounds;
int id;
@@ -343,6 +357,44 @@ typedef struct {
int disabled;
} ComboboxProps;
typedef enum {
ComboFlagsNone = 0,
ComboPopupAlignLeft = 1 << 0,
ComboHeightSmall = 1 << 1,
ComboHeightRegular = 1 << 2,
ComboHeightLarge = 1 << 3,
ComboHeightLargest = 1 << 4,
ComboNoArrowButton = 1 << 5,
ComboNoPreview = 1 << 6,
ComboWidthFitPreview = 1 << 7
} ComboFlags;
typedef struct {
Rectangle bounds;
Vector2 popup_size;
const char *preview;
int id;
bool *open;
unsigned int flags;
int disabled;
} ComboProps;
typedef enum {
PopupFlagsNone = 0,
PopupTooltip = 1 << 0,
PopupModal = 1 << 1,
PopupContext = 1 << 2
} PopupFlags;
typedef struct {
Rectangle bounds;
int id;
bool *open;
int disabled;
Rectangle trigger;
unsigned int flags;
} PopupProps;
typedef struct {
Rectangle bounds;
const char *title;
@@ -455,6 +507,10 @@ typedef struct {
int header_height;
float header_angle;
int custom_cells;
const char *copy_text;
const char **pasted_text;
int *pasted_row;
int *pasted_column;
} TableViewProps;
typedef struct {
@@ -499,6 +555,9 @@ typedef struct {
int selected;
int disabled;
int id;
/* Optional ImGui-style close state. A false value hides the header;
activating the close affordance sets it false without toggling open. */
bool *visible;
} CollapsibleProps;
typedef struct {
+24 -12
View File
@@ -83,7 +83,6 @@ typedef enum UIWidgetKind {
UI_WIDGET_ANGLE_SLIDER_NODE,
UI_WIDGET_FLOAT_DRAG_NODE,
UI_WIDGET_INT_DRAG_NODE,
UI_WIDGET_TEXT_IN_RECT_NODE,
UI_WIDGET_TEXT_INPUT_PAINT_NODE
} UIWidgetKind;
@@ -145,6 +144,9 @@ typedef union UIWidgetData {
int font;
int font_token;
int heading_level;
int wrap;
int align;
int vertical_align;
Color color;
Color border;
} primitive;
@@ -190,6 +192,8 @@ typedef struct UIWidgetNode {
int has_input_clip;
/* Internal frame-local paint snapshot index; zero means ordinary painting. */
unsigned paint_capture;
/* Internal declaration snapshot for deferred popup hit testing. */
unsigned popup_input_capture;
int parent;
int first_child;
int next_sibling;
@@ -298,16 +302,12 @@ typedef struct {
int *selected_index;
int font;
int *closed_index;
int id;
int disabled;
} ClosableTabBarProps;
void Background(Color color);
void Text(const char *text, int x, int y, int font_size, Color color);
void TextInRect(const char *text, Rectangle rect, int font_size,
Color color);
void TextColored(const char *text, int x, int y, int font_size, Color color);
void TextDisabled(const char *text, int x, int y, int font_size);
void TextWrapped(const char *text, Rectangle bounds, int font_size,
Color color);
void Text(TextProps text);
void LabelText(const char *label, const char *value, Rectangle bounds,
int font_size, Color color);
void BulletText(const char *text, Rectangle bounds, int font_size,
@@ -349,9 +349,9 @@ void IconLink(int id, int x, int y, int icon_size, Texture2D icon,
int Dropdown(int id, int x, int y, int w, int h,
const char **options, int option_count,
int *selected_index);
int DropdownEx(int id, int x, int y, int w, int h,
const UIDropdownOption *options, int option_count,
int *selected_index);
int DropdownOptions(int id, int x, int y, int w, int h,
const DropdownOption *options, int option_count,
int *selected_index);
int Slider(int id, int x, int y, int w, const char *label,
int min, int max, int *value, const char *suffix,
const char *value_text_override);
@@ -388,6 +388,12 @@ int InputInt(InputIntProps input);
int InputDouble(InputDoubleProps input);
int Spinbox(SpinboxProps spinbox);
int Combobox(ComboboxProps combo);
int BeginCombo(ComboProps combo);
void EndCombo(void);
void CloseCombo(void);
int BeginPopup(PopupProps popup);
void EndPopup(void);
void ClosePopup(void);
void LabelFrame(LabelFrameProps frame);
void ImageBox(ImageBoxProps image);
int ListBox(ListBoxProps list);
@@ -440,6 +446,13 @@ ToolbarResult Toolbar(ToolbarProps toolbar);
ToolbarHeaderResult ToolbarHeader(ToolbarHeaderProps header);
int SubtabBar(SubtabBarProps bar);
int TabBar(TabBarProps bar);
/* Render a canonical tab bar and begin its arbitrary-content scope. The
* caller owns selected_index; a tab selected by pointer or keyboard is
* written before BeginTabItem is evaluated in the same frame. */
int BeginTabBar(TabBarProps bar, int *selected_index);
int BeginTabItem(int index);
void EndTabItem(void);
void EndTabBar(void);
PaneTabBarResult PaneTabs(PaneTabBar bar);
void PaneDropPreview(Rectangle bounds, PaneDropZone zone);
SidebarAccountHeaderResult SidebarAccountHeader(SidebarAccountHeaderProps header);
@@ -475,7 +488,6 @@ int ColorEdit4(ColorEditProps edit);
int ColorPicker3(ColorEditProps picker);
int ColorPicker4(ColorEditProps picker);
int ColorButton(ColorButtonProps button);
int Tooltip(TooltipProps tooltip);
/* Layout nodes: auto-position children like flexbox. */
typedef struct {
+1 -1
View File
@@ -40,7 +40,7 @@ enum {
/*
* Open a window. ui_scale is the UI scale widgets inside the window should
* use (ScaleUIPx etc.); pass the callers current combined DPI/user scale.
* use (Scale etc.); pass the callers current combined DPI/user scale.
* Returns NULL when windows are unsupported or resources ran out.
*/
UIWindow *OpenUIWindow(const char *title, int x, int y, int width, int height,
+14 -11
View File
@@ -62,13 +62,12 @@ else
$(error Unknown KRYON_BACKEND '$(KRYON_BACKEND)' (expected raylib, canvas, dom, libdraw, termi, or null))
endif
KRYON_ALL_SRCS = $(filter-out $(KRYON_ICON_ASSETS_C),$(shell find $(KRYON_DIR)/src -type f -name '*.c' | LC_ALL=C sort))
KRYON_WITH_KSYNC ?=
KRYON_WITH_DAOCHI ?= $(if $(strip $(KRYON_WITH_KSYNC)),$(KRYON_WITH_KSYNC),0)
KRYON_DAOCHI_SRCS = $(wildcard $(KRYON_DIR)/src/ksync/*.c)
KRYON_DAOCHI_CFLAGS = $(if $(filter 1,$(KRYON_WITH_DAOCHI)),-DKRYON_WITH_DAOCHI=1 -DKRYON_WITH_KSYNC=1,-DKRYON_WITH_DAOCHI=0 -DKRYON_WITH_KSYNC=0)
KRYON_WEB_DAOCHI_CFLAGS = $(if $(filter 1,$(KRYON_WITH_DAOCHI)),-DHAS_LIBOQS=1 -DKRYON_HAS_LIBOQS=1 -I$(KRYON_WEB_LIBOQS_BUILD_DIR)/include,)
KRYON_WEB_DAOCHI_DEPS = $(if $(filter 1,$(KRYON_WITH_DAOCHI)),$(KRYON_WEB_LIBOQS_A),)
KRYON_WEB_DAOCHI_LIBS = $(if $(filter 1,$(KRYON_WITH_DAOCHI)),$(KRYON_WEB_LIBOQS_A),)
KRYON_WITH_SYNC ?= 0
KRYON_SYNC_SRCS = $(wildcard $(KRYON_DIR)/src/sync/*.c)
KRYON_SYNC_CFLAGS = $(if $(filter 1,$(KRYON_WITH_SYNC)),-DKRYON_WITH_SYNC=1,-DKRYON_WITH_SYNC=0)
KRYON_WEB_SYNC_CFLAGS = $(if $(filter 1,$(KRYON_WITH_SYNC)),-DHAS_LIBOQS=1 -DKRYON_HAS_LIBOQS=1 -I$(KRYON_WEB_LIBOQS_BUILD_DIR)/include,)
KRYON_WEB_SYNC_DEPS = $(if $(filter 1,$(KRYON_WITH_SYNC)),$(KRYON_WEB_LIBOQS_A),)
KRYON_WEB_SYNC_LIBS = $(if $(filter 1,$(KRYON_WITH_SYNC)),$(KRYON_WEB_LIBOQS_A),)
ifneq ($(KRYON_BACKEND),canvas)
KRYON_ALL_SRCS := $(filter-out $(KRYON_DIR)/src/backend/canvas_%.c,$(KRYON_ALL_SRCS))
endif
@@ -82,11 +81,15 @@ endif
ifneq ($(KRYON_BACKEND),termi)
KRYON_ALL_SRCS := $(filter-out $(KRYON_DIR)/src/backend/termi_%.c,$(KRYON_ALL_SRCS))
endif
ifneq ($(KRYON_WITH_DAOCHI),1)
KRYON_ALL_SRCS := $(filter-out $(KRYON_DAOCHI_SRCS),$(KRYON_ALL_SRCS))
ifneq ($(KRYON_WITH_SYNC),1)
KRYON_ALL_SRCS := $(filter-out $(KRYON_SYNC_SRCS),$(KRYON_ALL_SRCS))
endif
KRYON_SRCS = $(KRYON_ALL_SRCS) $(KRYON_ICON_ASSETS_C) $(KRYON_BACKEND_SRCS)
KRYON_INCLUDE = -I$(KRYON_DIR)/include
ifeq ($(KRYON_WITH_SYNC),1)
KRYON_INCLUDE += -I$(KRYON_DIR)/vendor/monocypher/src
KRYON_INCLUDE += -I$(KRYON_DIR)/vendor/monocypher/src/optional
endif
KRYON_USE_SYSTEM_CURL ?= 1
ifeq ($(KRYON_USE_SYSTEM_CURL),1)
KRYON_CURL_CFLAGS ?= $(shell pkg-config --cflags libcurl 2>/dev/null)
@@ -97,7 +100,7 @@ endif
KRYON_NATIVE_DEPS ?=
KRYON_NATIVE_CFLAGS ?=
KRYON_NATIVE_LDLIBS ?=
ifeq ($(KRYON_WITH_DAOCHI),1)
ifeq ($(KRYON_WITH_SYNC),1)
KRYON_NATIVE_DEPS += $(KRYON_LIBOQS_A)
KRYON_NATIVE_CFLAGS += $(KRYON_LIBOQS_INCLUDE) -DHAS_LIBOQS=1 -DKRYON_HAS_LIBOQS=1
KRYON_NATIVE_LDLIBS += $(KRYON_LIBOQS_A)
@@ -227,7 +230,7 @@ else
KRYON_NATIVE_FEATURE_DEFS ?=
endif
CFLAGS = -Wall -Wextra -std=c99 -Os -fPIE $(KRYON_NATIVE_FEATURE_DEFS) -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -DUI_EMBEDDED_ONLY=1 $(KRYON_DAOCHI_CFLAGS) $(KRYON_RUNTIME_ASSET_CFLAGS)
CFLAGS = -Wall -Wextra -std=c99 -Os -fPIE $(KRYON_NATIVE_FEATURE_DEFS) -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -DUI_EMBEDDED_ONLY=1 $(KRYON_SYNC_CFLAGS) $(KRYON_RUNTIME_ASSET_CFLAGS)
LDFLAGS = -Wl,--gc-sections -s
.NOTPARALLEL:
+1 -1
View File
@@ -4,7 +4,7 @@ KRYON_RAYLIB_MK_INCLUDED := 1
KRYON_DIR ?= vendor/kryon
RAYLIB_DIR ?= $(KRYON_DIR)/vendor/raylib/src
RAYLIB_SOURCES = $(shell if [ -d "$(RAYLIB_DIR)" ]; then find "$(RAYLIB_DIR)" -type f \( -name '*.c' -o -name '*.h' \); fi)
RAYLIB_SOURCES = $(shell if [ -d "$(RAYLIB_DIR)" ]; then find "$(RAYLIB_DIR)" -type f \( -name '*.c' -o -name '*.h' \); fi) $(KRYON_DIR)/src/backend/kry_rlgl_blend.inc
KRYON_RAYLIB_GENERATED_DIR ?= $(BUILD_DIR)/generated
KRYON_RAYLIB_GENERATED_PUBLIC_HEADER ?= $(KRYON_RAYLIB_GENERATED_DIR)/kryon_compat.generated.h
KRYON_RAYLIB_BACKEND_RENAME_HEADER ?= $(KRYON_RAYLIB_GENERATED_DIR)/raylib_backend_rename.h
+3 -3
View File
@@ -13,7 +13,7 @@ else
endif
WEB_KRYON_SRCS = $(filter-out $(KRYON_DIR)/src/file_dialog/file_dialog.c,$(KRYON_SRCS))
WEB_RAYLIB_OBJS = $(KRYON_RAYLIB_WEB_OBJS)
WEB_CFLAGS = -Wall -Wextra -std=gnu99 -Os -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -D_DEFAULT_SOURCE -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1 -DSUPPORT_FILEFORMAT_MP3=1 -DUI_EMBEDDED_ONLY=1 $(KRYON_DAOCHI_CFLAGS) $(KRYON_WEB_DAOCHI_CFLAGS)
WEB_CFLAGS = -Wall -Wextra -std=gnu99 -Os -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -D_DEFAULT_SOURCE -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1 -DSUPPORT_FILEFORMAT_MP3=1 -DUI_EMBEDDED_ONLY=1 $(KRYON_SYNC_CFLAGS) $(KRYON_WEB_SYNC_CFLAGS)
WEB_SHELL = src/web_shell.html
WEB_PUBLIC_FILES = $(wildcard manifest.json) $(shell find web-assets -type f 2>/dev/null)
WEB_LDFLAGS = -sUSE_GLFW=3 -sFETCH=1 -sALLOW_MEMORY_GROWTH=1 -lidbfs.js --shell-file $(WEB_SHELL)
@@ -53,7 +53,7 @@ $(WEB_RAYLIB_BUILD_DIR)/%.o: $(RAYLIB_DIR)/%.c $(KRYON_RAYLIB_BACKEND_RENAME_HEA
$(WEB_RAYLIB_A): kryon-raylib-check $(RAYLIB_SOURCES) $(WEB_RAYLIB_OBJS)
$(WEB_AR) rcs $@ $(WEB_RAYLIB_OBJS)
$(WEB_WORK_TARGET): $(BUILD_MAKEFILES) $(SRC) $(WEB_KRYON_SRCS) $(CORE_SRCS) $(WEB_SHELL) $(WEB_BACKEND_LIBS) $(KRYON_WEB_DAOCHI_DEPS) $(WEB_PUBLIC_FILES) | $(WEB_BUILD_DIR)
$(WEB_WORK_TARGET): $(BUILD_MAKEFILES) $(SRC) $(WEB_KRYON_SRCS) $(CORE_SRCS) $(WEB_SHELL) $(WEB_BACKEND_LIBS) $(KRYON_WEB_SYNC_DEPS) $(WEB_PUBLIC_FILES) | $(WEB_BUILD_DIR)
$(WEB_CC) $(WEB_CFLAGS) \
$(APP_INCLUDE) \
$(KRYON_INCLUDE) \
@@ -63,7 +63,7 @@ $(WEB_WORK_TARGET): $(BUILD_MAKEFILES) $(SRC) $(WEB_KRYON_SRCS) $(CORE_SRCS) $(W
$(WEB_KRYON_SRCS) \
$(CORE_SRCS) \
$(WEB_BACKEND_LIBS) \
$(KRYON_WEB_DAOCHI_LIBS) \
$(KRYON_WEB_SYNC_LIBS) \
$(WEB_LDFLAGS)
cache_buster=$$(find $(WEB_BUILD_DIR) -maxdepth 1 \( -name 'index.js' -o -name 'index.data' -o -name 'index.wasm' \) -type f -print | sort | xargs cksum | cksum | cut -d ' ' -f 1); \
sed -i "s#src=\"index.js\"#src=\"index.js?v=$$cache_buster\"#; s#src=index.js#src=\"index.js?v=$$cache_buster\"#; s#WEB_CACHE_BUSTER#$$cache_buster#g" $(WEB_WORK_TARGET)
+5 -5
View File
@@ -10,7 +10,7 @@
# Sources: the portable core, the libdraw backend, the full UI toolkit, the
# kry_std modules that do not need hosted OS services.
# Excluded on purpose: canvas/KRB backends, raylib audio, dylib/process/http
# surfaces, ksync, notifications, desktop integration, file dialogs, preview
# surfaces, sync, notifications, desktop integration, file dialogs, preview
# hosts, and runtime asset downloads.
#
# After `mk install`, link with -lkryon (or /$objtype/lib/libkryon.a) and
@@ -56,7 +56,7 @@ OFILES=\
src/core/theme.$O\
src/core/theme_meta.$O\
src/kry_std/audio_library.$O\
src/ksync/ksync_crypto.$O\
src/sync/sync_crypto.$O\
src/ui/bottom_nav.$O\
src/ui/button.$O\
src/ui/dropdown.$O\
@@ -129,7 +129,7 @@ OFILES=\
src/platform/plan9/plan9_ui_globals.$O\
src/platform/system_theme/system_theme.$O\
CLEANFILES=src/backend/*.$O src/core/*.$O src/kry_std/*.$O src/ksync/*.$O src/platform/*/*.$O \
CLEANFILES=src/backend/*.$O src/core/*.$O src/kry_std/*.$O src/sync/*.$O src/platform/*/*.$O \
src/platform/*.$O src/ui/*.$O *.$O src/*/*.i src/*.i
all:V: $LIB
@@ -165,8 +165,8 @@ src/core/%.$O: src/core/%.c
src/kry_std/%.$O: src/kry_std/%.c
cd src/kry_std && cpp -+ $CPPFLAGS $stem.c > $stem.i && $CC $CFLAGS -c $stem.i && mv $stem.i.$O $stem.$O && rm -f $stem.i
src/ksync/%.$O: src/ksync/%.c
cd src/ksync && cpp -+ $CPPFLAGS $stem.c > $stem.i && $CC $CFLAGS -c $stem.i && mv $stem.i.$O $stem.$O && rm -f $stem.i
src/sync/%.$O: src/sync/%.c
cd src/sync && cpp -+ $CPPFLAGS $stem.c > $stem.i && $CC $CFLAGS -c $stem.i && mv $stem.i.$O $stem.$O && rm -f $stem.i
src/platform/plan9/%.$O: src/platform/plan9/%.c
cd src/platform/plan9 && cpp -+ $CPPFLAGS $stem.c > $stem.i && $CC $CFLAGS -c $stem.i && mv $stem.i.$O $stem.$O && rm -f $stem.i
+149
View File
@@ -0,0 +1,149 @@
#!/usr/bin/env python3
"""Reject positional Text calls and duplicate public text-widget helpers."""
from __future__ import annotations
import argparse
import re
import sys
from pathlib import Path
SOURCE_SUFFIXES = {".c", ".h", ".kry"}
SKIPPED_DIRECTORIES = {".git", "build", "dist", "vendor", "vendor-builds"}
TEXT_CALL = re.compile(r"\bText\s*\(")
TEXT_PROPS_ARGUMENT = re.compile(r"\s*\(\s*TextProps\s*\)\s*\{")
TEXT_VARIANT = re.compile(r"\bText(?:Wrapped|Colored|Disabled|InRect)\s*\(")
def source_files(paths: list[Path]) -> list[Path]:
files: list[Path] = []
for path in paths:
if path.is_file():
if path.suffix in SOURCE_SUFFIXES:
files.append(path)
continue
for candidate in path.rglob("*"):
if not candidate.is_file() or candidate.suffix not in SOURCE_SUFFIXES:
continue
if any(part in SKIPPED_DIRECTORIES for part in candidate.parts):
continue
files.append(candidate)
return sorted(set(files))
def code_without_comments_or_strings(source: str) -> str:
"""Mask comments and literals while preserving newlines and offsets."""
result = list(source)
index = 0
state = "code"
while index < len(source):
current = source[index]
following = source[index + 1] if index + 1 < len(source) else ""
if state == "code":
if current == "/" and following == "/":
result[index] = " "
result[index + 1] = " "
index += 2
state = "line_comment"
continue
if current == "/" and following == "*":
result[index] = " "
result[index + 1] = " "
index += 2
state = "block_comment"
continue
if current == '"':
result[index] = " "
index += 1
state = "string"
continue
if current == "'":
result[index] = " "
index += 1
state = "character"
continue
elif state == "line_comment":
if current == "\n":
state = "code"
else:
result[index] = " "
elif state == "block_comment":
if current == "*" and following == "/":
result[index] = " "
result[index + 1] = " "
index += 2
state = "code"
continue
if current != "\n":
result[index] = " "
elif state in {"string", "character"}:
if current == "\\" and following:
result[index] = " "
if following != "\n":
result[index + 1] = " "
index += 2
continue
terminator = '"' if state == "string" else "'"
if current == terminator:
state = "code"
if current != "\n":
result[index] = " "
index += 1
return "".join(result)
def line_number(source: str, offset: int) -> int:
return source.count("\n", 0, offset) + 1
def violations(path: Path) -> list[str]:
source = path.read_text(encoding="utf-8")
code = code_without_comments_or_strings(source)
findings: list[str] = []
for match in TEXT_CALL.finditer(code):
argument_start = match.end()
if TEXT_PROPS_ARGUMENT.match(code, argument_start) is None:
findings.append(
f"{path}:{line_number(source, match.start())}: "
"Text must receive one TextProps value"
)
for match in TEXT_VARIANT.finditer(code):
findings.append(
f"{path}:{line_number(source, match.start())}: "
"text variations belong in TextProps, not a separate helper"
)
return findings
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("paths", nargs="+", type=Path)
arguments = parser.parse_args()
findings: list[str] = []
for path in source_files(arguments.paths):
findings.extend(violations(path))
if findings:
print("Clean Text API check failed:", file=sys.stderr)
print("\n".join(findings), file=sys.stderr)
return 1
print("Clean Text API check passed")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+5 -2
View File
@@ -279,6 +279,8 @@ KRB_WEB_EXPORTED_FUNCTIONS = (
KRB_ALPHA_BYTE_GAPS = {
"examples/26_widget_catalog.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
"tests/parity/composed_combo.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
"tests/parity/composition.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
"tests/parity/drag_drop.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
"tests/parity/scroll_content.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
"examples/20_scene.kry": "RGB exact; SDL readback alpha differs from headless kry_sw",
@@ -491,11 +493,11 @@ WIDGETS = {
"Spinbox",
"Stack",
"TabBar",
"TabItem",
"TableView",
"Text",
"TextArea",
"TextField",
"TextInRect",
"TextLines",
"TitleBar",
"Toast",
@@ -507,6 +509,7 @@ WIDGETS = {
WIDGET_ALIASES = {
"Toast": {"ShowToast", "ShowToastFor"},
"TabItem": {"BeginTabItem"},
}
CALL_RE = re.compile(r"\b([A-Z][A-Za-z0-9_]*)\s*\(")
@@ -1170,7 +1173,7 @@ def canvas_backend_sources() -> list[str]:
sources = []
for path in sorted((ROOT / "src").rglob("*.c")):
r = rel(path)
if "/ksync/" in f"/{r}/":
if "/sync/" in f"/{r}/":
continue
if "/platform/plan9/" in f"/{r}/":
continue
-1
View File
@@ -18,7 +18,6 @@ SHEETS = (
("logos", "UI_ICON_SHEET_LOGOS", "ui_logos_atlas_png"),
)
def enum_name(name: str) -> str:
return re.sub(r"[^A-Za-z0-9]", "_", name).upper()
+23 -6
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Import only Kryon's used MingCute Core Filled UI subset."""
"""Import only Kryon's used MingCute Core UI subset."""
import argparse
import copy
@@ -68,6 +68,7 @@ MAPPING = {
"todos": "task_2.svg",
"trash": "delete_2.svg",
"venus": "female.svg",
"warning": "alert.svg",
"weekly": "calendar_week.svg",
"workbook/clear_formatting": "eraser.svg",
"workbook/fill_color": "paint.svg",
@@ -76,6 +77,13 @@ MAPPING = {
"x": "close.svg",
}
# Most of Kryon's UI sheet uses the filled family. Safety guidance benefits
# from MingCute's regular alert outline, which stays legible over a tinted
# callout without turning into a heavy solid shape.
SOURCE_OVERRIDES = {
"warning": Path("regular/system/alert.svg"),
}
# MingCute ships matching mute and two-wave volume glyphs, but no discrete
# low/medium files. These two variants retain the exact filled speaker and
# inner-wave geometry from its Apache-2.0 volume.svg so all four slider states
@@ -166,6 +174,8 @@ def render_sheet(paths: list[Path], destination: Path, columns: int,
"height": str(CONTENT_SIZE),
"viewBox": source.get("viewBox", "0 0 24 24"),
})
if source.get("fill") is not None:
nested.set("fill", source.get("fill"))
for child in source:
nested.append(copy.deepcopy(child))
@@ -189,7 +199,8 @@ def main() -> None:
parser.add_argument("checkout", type=Path, help="local MingCute repository checkout")
args = parser.parse_args()
checkout = args.checkout.resolve()
source_root = checkout / "assets" / "svg" / "core" / "filled"
core_root = checkout / "assets" / "svg" / "core"
source_root = core_root / "filled"
license_path = checkout / "LICENSE"
if not source_root.is_dir():
@@ -225,7 +236,11 @@ def main() -> None:
with tempfile.TemporaryDirectory(prefix="kryon-mingcute-") as temporary:
temp = Path(temporary)
sources.update(write_derived_volume_icons(temp))
alias_paths = [sources[MAPPING[name]] for name in names]
alias_paths = [
core_root / SOURCE_OVERRIDES[name]
if name in SOURCE_OVERRIDES else sources[MAPPING[name]]
for name in names
]
alias_rows = render_sheet(alias_paths, OUTPUT / "ui.png", COLUMNS, temp)
for stale in (*OUTPUT.glob("mingcute-*.png"), *OUTPUT.glob("mingcute-*.json")):
@@ -238,12 +253,14 @@ def main() -> None:
"y": index // COLUMNS * CELL_SIZE,
"width": CELL_SIZE,
"height": CELL_SIZE,
"upstream": (f"derived/{MAPPING[icon['name']]}"
"upstream": (f"core/{SOURCE_OVERRIDES[icon['name']]}"
if icon["name"] in SOURCE_OVERRIDES
else f"derived/{MAPPING[icon['name']]}"
if MAPPING[icon["name"]] in DERIVED_VOLUME_PATHS
else f"core/filled/{MAPPING[icon['name']]}")
})
manifest.update({
"style": "mingcute-core-filled",
"style": "mingcute-core",
"license": "Apache-2.0",
"upstream": "https://github.com/mingcute-design/mingcute-icons",
"upstream_revision": revision,
@@ -255,7 +272,7 @@ def main() -> None:
"tintable": True,
})
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n")
print(f"imported {len(names)} used MingCute Core Filled icons")
print(f"imported {len(names)} used MingCute Core icons")
if __name__ == "__main__":
+30 -37
View File
@@ -19,8 +19,8 @@ Commands:
fmt [--check] FILE... format .kry source files
locale-check SRC... -- LOCALE...
check t("key") source references against locales
dev-backend run a local Ksync sync server for this project
(locates the server at $KSYNC_DIR or ../ksync; prints
dev-backend run a local Daochi sync node for this project
(locates it at $DAOCHI_DIR or ../daochi; prints
the sync URL to point your app at)
USAGE
}
@@ -139,68 +139,61 @@ locale-check)
exit $?
;;
dev-backend)
# Run a local Ksync sync server for development. Locates the server source
# at $KSYNC_DIR (if set) or as a sibling checkout (../ksync relative to this
# script), isolates its data in <project>/.kryon/, and runs it in the
# foreground. The server regenerates its token secret each start, so this
# is for local development only — do not use it for shared deployments.
ksync_dir=${KSYNC_DIR:-}
if [ -z "$ksync_dir" ]; then
# Try a sibling checkout: walk up from the current directory looking
# for a ../ksync that contains the server, then fall back to a sibling
# of the script's own location (for the in-tree kryon build).
# Run a local Daochi node for development.
daochi_dir=${DAOCHI_DIR:-}
if [ -z "$daochi_dir" ]; then
search_dir=$(pwd)
while [ "$search_dir" != "/" ]; do
candidate=$search_dir/../ksync
if [ -f "$candidate/main.go" ] || [ -x "$candidate/ksync" ]; then
ksync_dir=$(cd "$candidate" 2>/dev/null && pwd)
candidate=$search_dir/../daochi
if [ -f "$candidate/main.go" ] || [ -x "$candidate/daochi" ]; then
daochi_dir=$(cd "$candidate" 2>/dev/null && pwd)
break
fi
search_dir=$(dirname "$search_dir")
done
fi
if [ -z "$ksync_dir" ]; then
if [ -z "$daochi_dir" ]; then
script_dir=$(cd "$(dirname "$0" 2>/dev/null || printf '.')" 2>/dev/null && pwd)
candidate=$script_dir/../ksync
if [ -f "$candidate/main.go" ] || [ -x "$candidate/ksync" ]; then
ksync_dir=$(cd "$candidate" 2>/dev/null && pwd)
candidate=$script_dir/../daochi
if [ -f "$candidate/main.go" ] || [ -x "$candidate/daochi" ]; then
daochi_dir=$(cd "$candidate" 2>/dev/null && pwd)
fi
fi
if [ -z "$ksync_dir" ] || { [ ! -f "$ksync_dir/main.go" ] && [ ! -x "$ksync_dir/ksync" ]; }; then
die "could not find the Ksync server source.
Set KSYNC_DIR to its checkout path (e.g. export KSYNC_DIR=/home/wao/src/ksync),
or place it as a sibling of a parent directory (../ksync)."
if [ -z "$daochi_dir" ] ||
{ [ ! -f "$daochi_dir/main.go" ] && [ ! -x "$daochi_dir/daochi" ]; }; then
die "could not find the Daochi server source.
Set DAOCHI_DIR to its checkout path, or place Daochi at ../daochi."
fi
# Per-project data dir. SQLite needs a native filesystem: shared/virtual
# mounts (9p, etc.) fail its WAL/locking with "disk I/O error". Default to
# a runtime cache dir on tmpfs, keyed by project so concurrent projects
# don't collide; let KSYNC_DB override for users who want it elsewhere.
# don't collide; let DAOCHI_DB override for users who want it elsewhere.
project_tag=$(pwd | cksum | awk '{print $1}')
dev_root=${XDG_CACHE_HOME:-${TMPDIR:-/tmp}}/kryon-dev-backend
mkdir -p "$dev_root"
dev_db=${KSYNC_DB:-$dev_root/ksync-$project_tag.db}
dev_addr=${KSYNC_ADDR:-127.0.0.1:8080}
dev_db=${DAOCHI_DB:-$dev_root/daochi-$project_tag.db}
dev_addr=${DAOCHI_ADDR:-127.0.0.1:8080}
printf '== kryon dev-backend ==\n'
printf 'server: %s\n' "$ksync_dir"
printf 'server: %s\n' "$daochi_dir"
printf 'data: %s\n' "$dev_db"
printf 'listen: http://%s\n' "$dev_addr"
printf '\nPoint your app at this URL, e.g. by setting the sync base URL\n'
printf 'to http://%s before calling RunKsyncSync/RequestKsyncSyncBearer.\n' "$dev_addr"
printf 'to http://%s before calling RunSync/RequestSyncBearer.\n' "$dev_addr"
printf '(Tokens are ephemeral; they reset on each restart.)\n\n'
export KSYNC_ADDR=$dev_addr
export KSYNC_BASE_URL=http://$dev_addr
export KSYNC_DB=$dev_db
export KSYNC_ALLOW_EPHEMERAL_TOKEN_SECRET=1
if [ -x "$ksync_dir/ksync" ]; then
exec "$ksync_dir/ksync"
export DAOCHI_ADDR=$dev_addr
export DAOCHI_BASE_URL=http://$dev_addr
export DAOCHI_DB=$dev_db
export DAOCHI_ALLOW_EPHEMERAL_TOKEN_SECRET=1
if [ -x "$daochi_dir/daochi" ]; then
exec "$daochi_dir/daochi"
fi
if ! command -v go >/dev/null 2>&1; then
die "found Ksync source at $ksync_dir but 'go' is not on PATH.
Install Go, or build the server once with 'make build' in $ksync_dir."
die "found Daochi source at $daochi_dir but 'go' is not on PATH.
Install Go, or build the server once with 'make build' in $daochi_dir."
fi
printf '(building + running via "go run ."; first run compiles liboqs)\n\n'
make_cmd=${MAKE:-make}
"$make_cmd" -C "$ksync_dir" run
"$make_cmd" -C "$daochi_dir" run
;;
clean)
case "$target" in
+2 -2
View File
@@ -3,7 +3,7 @@ set -eu
usage() {
echo "Usage: $0 <module-name> [--apply]"
echo "Example: $0 ksync --apply"
echo "Example: $0 sync --apply"
exit 1
}
@@ -15,7 +15,7 @@ if [ "${2:-}" = "--apply" ]; then APPLY=1; fi
SRC_DIR=src
TARGET_DIR=$SRC_DIR/$MODULE
# gather candidate files: src/ksync_*.c and src/ksync_*.h
# Gather matching C source and header files from src/.
candidates=$(find "$SRC_DIR" -maxdepth 1 -type f \( -name "${MODULE}_*.[ch]" -o -name "${MODULE}*.c" -o -name "${MODULE}*.h" \) | sort)
if [ -z "$candidates" ]; then
+8
View File
@@ -11,6 +11,14 @@ sdl_core="$src_dir/platforms/rcore_desktop_sdl.c"
audio="$src_dir/raudio.c"
rgfw_core="$src_dir/platforms/rcore_desktop_rgfw.c"
# Compile private paint-state hooks inside rlgl, where its renderer cache is
# visible. Patch only the build copy; keep the raylib submodule unchanged.
prepare_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cp "$prepare_dir/../src/backend/kry_rlgl_blend.inc" "$src_dir/kry_rlgl_blend.inc"
if ! grep -q '#include "kry_rlgl_blend.inc"' "$src_dir/rlgl.h"; then
perl -0pi -e 's/(?=void rlSetBlendMode\(int mode\)\n\{)/#include "kry_rlgl_blend.inc"\n\n/ or die "rlgl blend hook insertion point missing\n"' "$src_dir/rlgl.h"
fi
if [ -f "$sdl_core" ] && ! grep -q 'Kryon: avoid X11 Font typedef collision' "$sdl_core"; then
perl -0pi -e 's@(#elif defined\(USING_SDL2_PROJECT\)\n\s*#include "SDL2/SDL\.h"\n)(\s*#include "SDL2/SDL_syswm\.h"\s*// Required to get window handlers)@$1 // Kryon: avoid X11 Font typedef collision when SDL_syswm.h pulls X11 headers.\n #if defined(__unix__) \&\& !defined(__APPLE__)\n #define Font X11Font\n #endif\n$2\n #if defined(__unix__) \&\& !defined(__APPLE__)\n #undef Font\n #endif@' "$sdl_core"
fi
Loaded 100 of 209 files, more files were not shown because too many files have changed in this diff. Show more