Compare commits

..
Author SHA1 Message Date
waozi c26b7ec943 Fix web build: include <stddef.h> for NULL in platform_thread.c
platform_thread.c uses NULL but only included <stdlib.h> under _WIN32.
On native, <pthread.h> (pulled in by platform.h) transitively provides
NULL, so the build passed. Emscripten's stricter header setup under
-DUI_EMBEDDED_ONLY does not, causing:

  error: use of undeclared identifier 'NULL'

Add the standard <stddef.h> include unconditionally.
2026-07-26 10:58:16 -05:00
waozi 22afa3105d Make text input focus persistent and single-owner across frames 2026-07-25 21:23:45 -05:00
waozi 5db666b64e Update website code sample to verb-free Kry syntax
The Get Started example still showed the removed 'draw' verb. Switch it
to bare calls (WidgetText, app_draw_bottom_nav) to match the v0.1.7
language. inbe's own .kry files live in the separate inbe repo and are
updated there, not here.
2026-07-25 21:13:43 -05:00
github-actions[bot] 711a9c4be8 Update CHANGELOG for v0.1.7 2026-07-26 02:02:20 +00:00
waozi 73220d9c25 Bump version to v0.1.7 2026-07-25 21:00:24 -05:00
waozi d403c726a7 Remove native_widget_name compiler name-rewrite hack
kc silently rewrote a few widget call names (Text->DrawUIText,
TextButton->DrawUITextButton, CenteredColumn->GetUICenteredColumn,
ScrollEnd->EndUIScrollPage) inside emit_call. That was library behavior
baked into the compiler — exactly the kind of hack that shouldn't exist:
the compiler must not know widget names. Calls now pass through verbatim.

No source used the aliased names (examples already call the real
WidgetText/GetUICenteredColumn), so this is pure dead-code removal.
make test passes.
2026-07-25 17:07:58 -05:00
waozi 63a8c366a2 Finish removing Kry sugar verbs — language is now minimal
The previous pass removed the redundant call/assignment verbs (draw,
native, set, widget) and the widget keywords (text/rect/line/background/
swatch). This pass removes the remaining bespoke sugar so the statement
language is just declarations, assignments, calls, and control flow:

Removed (now fatal errors with migration hints):
- advance x by N   -> x += N
- clamp_min/max x N -> if (x < N) x = N
- c_rect name = .. -> name: Rectangle = (Rectangle){..}
- texture name = .. -> name: Texture2D = ..
- set_theme id mode -> SetCurrentTheme(id, mode)
- button label {..} -> if WidgetButton(x, y, w, h, label, style) {..}
- on key K {..}     -> if (UIKeyPressed(K)) {..}
- on key_down K {..}-> if (UIKeyDown(K)) {..}
- event/on expr {..}-> if (expr) {..}
- icon_button .. {..}-> if DrawUIIconButton((UIIconButton){..}) {..}

Also moved the background/set_theme fatal-error arms ahead of the
line_is_c_uninit_decl heuristic in the dispatcher, since the heuristic
was swallowing them as bogus 'TYPE NAME' C declarations.

What remains in parse_statement: control flow (if/else/for/while/switch/
case/default/guard/return/break/continue/goto/labels), declarations
(name :=, name: T =), assignments (incl. compound), bare calls, enum,
and the two escape hatches (c, unused). Rewrote the 9 example files that
used button/on-key (22 sites). Extended kc_syntax_test.sh to assert each
removed sugar keyword now errors. make clean && make all test passes.

KRY_LANGUAGE_PLAN.md updated to document the final minimal statement set.
2026-07-25 17:04:29 -05:00
waozi 236ea20a1a Remove redundant Kry verbs; widgets are now a library
The Kry statement language had a tangle of overlapping verbs (draw,
native, set, widget, text, rect, line, background, swatch) that all did
minor variants of the same thing: emit a call or assignment statement.
This removes the redundant ones and replaces the widget keywords with an
ordinary library of functions, so 'widget' is a convention (a function
that draws) rather than compiler syntax.

Removed statement verbs (now fatal errors with a migration hint):
- draw / widget  -> call the expression directly; bare call statements
  already wrap with PushUIInspectSource/PopUIInspectSource, so
  click-to-source keeps working with no keyword.
- native         -> call the expression directly.
- set            -> write the assignment/call directly.
- text/rect/line/background/swatch -> call the matching Widget* library
  function (WidgetText, WidgetRect, WidgetLine, WidgetBackground).

Kept keywords earn their place: button, on/event, icon_button,
set_theme, advance, clamp_min/max, c_rect, texture, c, unused, and all
control flow.

New widget library (include/ui_widgets.h, src/ui/ui_widgets.c):
WidgetText, WidgetRect, WidgetLine, WidgetBackground, WidgetButton —
ordinary C functions wrapping the existing DrawUI* primitives, with the
same defaults the removed keywords used. Included via kryon.h.

Rewrote all 17 example .kry files to the verb-free syntax (positional
args; named args deferred to a later phase since kc has no parameter
table). Updated kc_syntax_test.sh: the 'valid' screen and cross-file
tests no longer use removed verbs, and new tests assert that each
removed verb errors with a migration message.

Regenerated icon assets pick up the freebsd/macos platform PNGs added
earlier.

make clean && make all test passes (kc syntax, raylib compat, runtime).
2026-07-25 12:54:52 -05:00
waozi e4659ea31f Rework Platforms grid: add Windows, macOS, FreeBSD
Replace the Native and Network placeholder cards with concrete
targets that Kryon actually ships: Windows (native + WinINet assets),
macOS (native desktop builds), and FreeBSD (native/embedded). Native
and Network were not first-class runtime targets.

Add hand-drawn 16x16 pixel-art icons for FreeBSD (beastie devil head)
and macOS (graphite apple) to match the existing tux/droid/win/wasm
icon set, plus a generator script for reproducibility.
2026-07-25 10:15:50 -05:00
waozi 674af78687 Make text input focus exclusive across UITextField and UITextArea
UITextField and UITextArea tracked focus with separate, uncoordinated
globals (g_ui_text_field_drag_id vs g_ui_text_area_drag_id). Clicking one
type never cleared the other's focused flag, so two text inputs could
appear focused at once: e.g. focusing a habit's multiline description
left the title field's cursor blinking on the shared GetTime() phase.

Introduce a single text-focus owner (the address of the focused widget's
 flag). Each frame the owner resets; a widget keeps focus only
while it remains the owner, and claiming focus on click/drag displaces
any other text widget. This works across widget types without relying on
focus_id, which defaults to 0 and is shared when the caller leaves it
unset.

Also fixes the latent drag collision: with focus_id unset, the drag-down
branch (g_ui_text_*_drag_id == field.focus_id == 0) matched every field,
re-asserting focus on unrelated fields while the mouse was held.
2026-07-25 08:59:24 -05:00
github-actions[bot] 3f5d8254c3 Update CHANGELOG for v0.1.6 2026-07-25 13:34:48 +00:00
waozi 62c76fdb8e Bump version to v0.1.6 2026-07-25 08:33:12 -05:00
waozi c478df4896 Resolve tray icon from installed hicolor paths
GetDesktopTrayIconPath previously only checked next to the executable and
the caller-supplied (often CWD-relative) candidate paths. When the app is
launched from a menu, .desktop file, or AppImage, the CWD is typically the
home directory, so neither probe found the icon and the tray fell back to a
generic/blank icon.

Also probe the standard installed locations:
  - <exedir>/../share/icons/hicolor/<size>/apps/<icon>.png
  - /usr/local/share:/usr/share/icons/hicolor/<size>/apps/<icon>.png
    (default /usr/local/share:/usr/share)

Sizes are tried largest-first for the sharpest rendering.
2026-07-25 08:31:14 -05:00
waozi 19b1137657 Fix site card cursors, release CI, and IDE recent-projects grid
Website:
- Apply hand cursor to feature/platform/goal cards so hover feedback
  matches their clickable affordance.

Release CI (releases were broken since v0.1.4):
- Fix the root cause: vendored curl needs -lzstd/-lbrotli but the link
  line never got them. Query each codec library independently instead
  of one pkg-config call that collapses to empty if any package is
  missing, and install libzstd-dev/libbrotli-dev on the release runner.
- Auto-generate a CHANGELOG.md entry from commits since the last tag
  when a version.h bump has no hand-written entry, instead of failing
  the build. This makes releases fully automatic: bump version.h, push,
  get a tagged release with a proper changelog.

IDE start page:
- Render recent projects as a responsive grid (matching the examples
  grid) instead of a single full-width column.
2026-07-25 08:19:45 -05:00
waozi 07dba94d0e Trigger site deploy (previous run hit GitHub internal error) 2026-07-25 07:56:46 -05:00
waozi d3e35a4160 Restyle docs site with refined modern-retro theme
Adopt the waozi modern-retro aesthetic: warm off-white surfaces,
slate ink with teal accent, soft translucent borders, rounded cards
with layered bevel/shadow, fine low-opacity dither texture, and smooth
hover transitions. Preserves the retro signatures (pixelated rendering,
custom cursors, beveled controls, inset code blocks).

- Rewrote styles.css design tokens and component styles
- Updated theme-color meta to #f3f1ea on index and api-template
- Switched feature/platform/goal layouts to CSS grid auto-fit
- Ignore .zcode tooling dir
2026-07-25 07:27:26 -05:00
waozi ce2bddba02 Add Kryon IDE start page and fix preview inspection
Replace the bare recent-projects welcome screen with a centered start
page: a New Project action that scaffolds project.kryon + a hello-world
main.kry into a chosen folder, a Recent Projects list, and an Examples
grid with one card per examples/*.kry. The sidebar is hidden when no
project is open so the start page fills the canvas; opening a .kry
selects its screen and shows the preview column.

Update examples to the current kc syntax: drop the removed `var` keyword
from all declarations (they already use `name: type = value`) and replace
the custom `set_theme` verb in 03_theme.kry with `native SetCurrentTheme`
so the generated C compiles. All 17 examples now transpile and build.

Fix the preview inspect overlay registering zero widgets. draw_preview_pane
restored the editor camera via SetUIInspectFrame(NULL) through SetUIFrame,
which wiped the widget list that DrawAppScreen had just populated. Restore
the camera directly instead, so the 17 preview widgets survive and
DrawUIInspectOverlay can outline them and click-to-source works.

Build with -fPIE in mk/common.mk so the static lib links into PIE
executables on PIE-default Linux toolchains.
2026-07-24 20:16:11 -05:00
waozi 93913f12a3 Improve Kry language and generic APIs 2026-07-23 13:44:45 -03:00
waozi d568cd2bd4 Support uninitialized C locals in kc 2026-07-23 00:10:30 -03:00
waozi ab65e5f4ca Allow args locals in kc functions 2026-07-22 23:53:55 -03:00
waozi bee3d50e71 Add Kryon platform thread primitives 2026-07-22 23:42:15 -03:00
waozi 2dbedc88d2 Support local enum blocks in kc 2026-07-22 23:35:53 -03:00
waozi fa6611ab7b Support bitwise compound assignments in kc 2026-07-22 23:09:14 -03:00
waozi cda7d9c01d Guard Kry compile-time expansion recursion 2026-07-22 22:48:29 -03:00
waozi 6535737611 Add runtime asset sync API 2026-07-22 22:38:06 -03:00
waozi 233a84d9b0 Support Kry multidimensional arrays 2026-07-22 21:16:45 -03:00
waozi 48cda7e696 Raise Kry type block capacity 2026-07-22 21:14:22 -03:00
waozi c216052294 Add Kry named enum syntax 2026-07-22 21:13:16 -03:00
waozi e7559bbcf7 Add Kry switch syntax 2026-07-22 21:07:44 -03:00
waozi de87294e41 Update Kryon site goals 2026-07-22 20:49:34 -03:00
waozi 7f30dceaf8 Add Kry web intrinsics 2026-07-22 20:31:08 -03:00
waozi 1833cdfa06 Add Kry anonymous block scopes 2026-07-22 20:20:05 -03:00
waozi 92fcc105e4 Add top-level Kry extern declarations 2026-07-22 20:17:09 -03:00
waozi b911b2f646 Add Jai-style Kry defines 2026-07-22 20:05:51 -03:00
waozi 1424b39e2b Add Kry top-level macro translation 2026-07-22 19:47:34 -03:00
waozi b530d20569 Add Kry type aliases 2026-07-22 17:57:06 -03:00
waozi 73fe84a35b Allow Kry type-only modules 2026-07-22 17:49:37 -03:00
waozi 24996d139c Generate project headers from Kry files 2026-07-22 15:45:19 -03:00
waozi f4d6c2c493 Guard Kry text shorthand parsing 2026-07-22 15:29:51 -03:00
waozi d47b36bed3 Respect Kry locals when resolving function values 2026-07-22 15:11:16 -03:00
waozi cdaa8e563c Limit Kry function value rewriting 2026-07-22 15:08:03 -03:00
waozi 398e5f4153 Resolve Kry function values in expressions 2026-07-22 15:05:41 -03:00
waozi fa08ec2e04 Add exact C exports for Kry modules 2026-07-22 14:52:07 -03:00
waozi 1372267729 Make Kry modules the only import path 2026-07-22 14:30:08 -03:00
waozi 16219bd52b Support path-based Kry module use 2026-07-22 14:17:48 -03:00
waozi 8a6de43390 Fix IDE preview toolbar and text state 2026-07-22 08:41:20 -03:00
waozi d41ebf2163 Tighten leading continuation parsing 2026-07-22 04:02:08 -03:00
waozi 6501fd2f2b Support leading expression continuations in Kry 2026-07-22 04:01:10 -03:00
waozi 9402b85ae6 Add native Kry enum blocks 2026-07-21 22:51:38 -03:00
waozi 1bec42d4f2 Support break statements in Kry 2026-07-21 22:46:44 -03:00
waozi b7a553de97 Add native Kry struct declarations 2026-07-21 22:42:18 -03:00
waozi a02a7777bf Support multiline Kry function declarations 2026-07-21 22:14:08 -03:00
waozi f3fbdcc37c Rewrite nil in Kry static initializers 2026-07-21 22:06:42 -03:00
waozi 1921e413ad Add Jai-style Kry compile-time macros 2026-07-21 22:04:04 -03:00
waozi 7a57c93927 Support multiline Kry state initializers 2026-07-21 21:44:56 -03:00
waozi e7868c3d2a Use Jai-style typed Kry declarations 2026-07-21 21:22:11 -03:00
waozi ccece1bfd6 Keep postfix operators on one Kry line 2026-07-21 21:12:15 -03:00
waozi a8cab2c30b Support multiline Kry block headers 2026-07-21 21:09:22 -03:00
waozi 22c0e30469 Support operator line continuations in Kry 2026-07-21 21:06:34 -03:00
waozi 2923ed2f67 Support multiline Kry statements 2026-07-21 21:05:40 -03:00
waozi 51a284c647 Add Kry while statements 2026-07-21 20:49:27 -03:00
waozi f67136bc3f Allow app locals in Kry functions 2026-07-21 20:40:05 -03:00
waozi f0baa57880 Lift Kry function limits 2026-07-21 20:37:56 -03:00
waozi 9b01700226 Add flat Kry modules 2026-07-21 20:20:18 -03:00
waozi 5abaec74b1 Refresh Kryon site and release flow 2026-07-21 19:55:38 -03:00
waozi 1e5e61f062 Allocate Kry compiler state on heap 2026-07-21 19:30:15 -03:00
waozi bd4a4b1948 Make Kry C imports explicit 2026-07-21 19:26:09 -03:00
waozi 78ec135662 Make Kryon multi-assignment simultaneous 2026-07-21 16:45:33 -03:00
waozi 9b217cf3ce Tighten Kryon syntax and preview inspect 2026-07-21 16:41:13 -03:00
waozi 5108e22141 Recover stale Kryon app build locks 2026-07-21 15:56:44 -03:00
waozi ddd6bf99a7 Serialize Kryon app builds 2026-07-21 15:53:34 -03:00
waozi 73251ab1e3 Add Kryon app build runner 2026-07-21 15:38:11 -03:00
waozi 5a22771ab3 Tighten Kryon syntax diagnostics 2026-07-21 15:08:10 -03:00
waozi 6a79813efa Build out Kryon IDE workflow 2026-07-20 23:14:07 -03:00
waozi f6995cf42f Fold Kryon tools into runtime repo 2026-07-20 11:36:37 -03:00
waozi 137f6ac413 Rename Flint runtime to Kryon 2026-07-20 11:25:19 -03:00
waozi 2123449504 Add Kryon widget inspection lifecycle 2026-07-20 10:56:27 -03:00
waozi 97bdbe9336 Support text area range selection 2026-07-20 08:34:52 -03:00
waozi 666e597d8e Add locale dropdown widget 2026-07-20 00:50:22 -03:00
waozi 6040557388 Expose editor widget kind index 2026-07-20 00:02:58 -03:00
waozi 95a2eac3b8 Move editor overlay into Flint 2026-07-19 23:53:27 -03:00
waozi d04527acdd Tune syntax highlight colors 2026-07-19 23:43:47 -03:00
waozi 56b450bc3b Improve text area dragging and syntax colors 2026-07-19 23:40:08 -03:00
waozi 6afca6b4da Add context menus and source syntax modes 2026-07-19 23:35:21 -03:00
waozi 38e37b77dc Use classic gray default theme 2026-07-19 23:02:04 -03:00
waozi 8df1a0fad9 Add syntax highlighting to text areas 2026-07-19 18:13:53 -03:00
waozi f21568026c Make Flint source and buttons compact 2026-07-19 12:15:30 -03:00
waozi 719de9ac5e Keep scrollbar drags bound to one scroll target 2026-07-19 11:16:08 -03:00
waozi 0c17825d0d Expand Flint tree items on press 2026-07-19 11:12:28 -03:00
waozi 722ad615f3 Fix Flint tree input and theme colors 2026-07-19 11:10:17 -03:00
waozi 4d120dd04e Capture input in Flint source view 2026-07-19 10:44:26 -03:00
waozi f651980876 Add Flint source view widget 2026-07-19 10:39:35 -03:00
waozi 200ce63511 Refine cascading tree file browser 2026-07-19 09:53:21 -03:00
waozi d3d2a12a52 Show cascading tree in collections example 2026-07-19 09:46:39 -03:00
waozi 9c199d1416 Add cascading tree view widget 2026-07-19 09:44:47 -03:00
waozi e6b58a78b9 Apply UI colors from themes 2026-07-19 09:35:45 -03:00
waozi c9d1b3907b Expose editor widget actions 2026-07-19 01:41:53 -03:00
waozi 1242bc8f1b Add raylib-style app host API 2026-07-19 01:16:01 -03:00
waozi 912f18638a Add pragmatic Tk-style UI toolkit 2026-07-19 00:46:20 -03:00
waozi f77414e8dc Make Flint editor hooks weak defaults 2026-07-19 00:27:41 -03:00
waozi 4c9f46e30a Split Kryon IDE from Flint library 2026-07-19 00:15:54 -03:00
waozi ba290cdd4b Move editor command out of library sources 2026-07-19 00:00:07 -03:00
waozi 9fedd4a936 Build missing project editor hosts 2026-07-18 23:51:43 -03:00
waozi 935e8d6f60 Load app editor hosts from Flint editor 2026-07-18 23:50:27 -03:00
waozi 8c838fb35f Make Flint editor a root app 2026-07-18 23:41:39 -03:00
waozi 643c840465 Add project menu to Flint editor 2026-07-18 22:59:42 -03:00
waozi f3af5773bd Shape Flint editor as app shell 2026-07-18 19:33:15 -03:00
waozi 1cc8d26e58 Launch editor from Flint run target 2026-07-18 19:27:12 -03:00
waozi 93c9fec4bd Add Flint editor overlay prototype 2026-07-18 19:05:17 -03:00
waozi 901df7adf9 Normalize embedded font asset paths 2026-07-18 08:30:22 -03:00
waozi 83f29189d9 Make Clay include self-contained 2026-07-18 08:27:47 -03:00
waozi a462581680 Add Clay and remove fontchop 2026-07-18 07:29:00 -03:00
waozi aeedec3f26 Make text layout lines selectable 2026-07-18 07:03:31 -03:00
waozi 6d6406a68b Add UI toast and sunset default theme 2026-07-17 22:51:17 -03:00
waozi 403e5ac0b3 Respect small button fonts 2026-07-17 21:47:06 -03:00
waozi 48ce99fafc Add selectable text and tighten modal controls 2026-07-17 21:43:58 -03:00
waozi 831ae199af Add reusable Flint theme settings control 2026-07-17 17:34:35 -03:00
waozi f73557e6ac Use default theme and stable text centering 2026-07-17 00:52:59 -03:00
waozi 336e743ac7 Support per-option dropdown fonts 2026-07-17 00:50:03 -03:00
waozi 2e97c771a1 Tighten text input control metrics 2026-07-17 00:43:07 -03:00
waozi 27b155f8a0 Stabilize control text vertical alignment 2026-07-17 00:37:16 -03:00
waozi 2f17ac5bca Increase modal action label size 2026-07-17 00:26:28 -03:00
waozi 0ce98191d3 Add source-based UI font cache 2026-07-17 00:18:13 -03:00
waozi 8be2b38625 Revert "Support exact-size UI fonts"
This reverts commit 0641fbebfe.
2026-07-16 23:44:10 -03:00
waozi 0641fbebfe Support exact-size UI fonts 2026-07-16 23:43:14 -03:00
waozi 947badc40a Split Flint UI domain headers 2026-07-16 23:36:17 -03:00
waozi 4852820e9f Update AppIndicator tray status title 2026-07-16 23:30:06 -03:00
waozi 95b7c7f98b Split Flint UI core and controls 2026-07-16 23:27:10 -03:00
waozi fd3adb5de4 Add real font asset loading 2026-07-16 21:43:27 -03:00
waozi 41a5195384 Scale UI text from font base size 2026-07-16 00:27:22 -03:00
waozi 3526afee37 Align changelog with Flint releases 2026-07-15 23:41:01 -03:00
waozi d606232116 Use fontchop submodule for UI fonts 2026-07-15 23:36:23 -03:00
waozi c7200216be Use theme color for icons 2026-07-12 23:30:51 -03:00
waozi a27554e4c8 Reduce generated icon asset line count 2026-07-12 23:19:15 -03:00
waozi 183f4e6a42 Improve desktop and embedded fallbacks 2026-07-12 22:57:26 -03:00
waozi 9a1ef0653d Add pointer release helper APIs 2026-07-12 22:49:34 -03:00
waozi b763e34510 Add modal layer input capture 2026-07-12 21:54:23 -03:00
waozi aa7d1296f5 Close profile picker after selection 2026-07-12 21:37:37 -03:00
waozi 45e29839f4 Keep profile picker open after selection 2026-07-12 20:49:29 -03:00
waozi 4bc3b917bf Remove unused eye icon 2026-07-12 20:39:43 -03:00
waozi e637e50f59 Organize Flint icon assets 2026-07-12 20:35:48 -03:00
waozi 1ee815a636 Test raylib compatibility surface 2026-07-12 17:25:03 -03:00
waozi 67c4e768be Improve Flint static package 2026-07-12 17:25:03 -03:00
waozi c0c17f6c83 Add UI release consumption 2026-07-12 15:39:46 -03:00
waozi 2151faabd4 Make UI text rect clipping camera-aware 2026-07-12 02:05:49 -03:00
waozi 17afae92cb Add Markdown support and text area UI 2026-07-12 01:27:59 -03:00
waozi 1fed3f13fc Handle OTF font offsets in otfchop 2026-07-12 00:50:38 -03:00
271 changed files with 27714 additions and 20078 deletions

No files matched your search

+13 -7
View File
@@ -29,7 +29,7 @@ jobs:
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake zlib1g-dev zip
sudo apt-get install -y build-essential cmake cmark zlib1g-dev zip
- name: Set Up Emscripten
run: |
set -euo pipefail
@@ -44,14 +44,16 @@ jobs:
run: |
set -euo pipefail
make docs-site CMAKE=/usr/bin/cmake
test -f build/site/examples/02_buttons/index.html
test -f build/site/examples/02_buttons/index.js
test -f build/site/examples/02_buttons/index.wasm
test -f build/site/index.html
test -f build/site/api.html
test -f build/site/icons/kryon.png
test -f build/site/icons/c.png
test ! -f build/site/API.md
- name: Upload Site Artifact
uses: actions/upload-artifact@v4
with:
name: flint-site
name: kryon-site
path: build/site
if-no-files-found: error
@@ -65,7 +67,7 @@ jobs:
- name: Download Site Artifact
uses: actions/download-artifact@v4
with:
name: flint-site
name: kryon-site
path: build/site
- name: Install Netlify CLI
@@ -76,6 +78,8 @@ jobs:
set -euo pipefail
auth_token="$(printf '%s' "$NETLIFY_AUTH_TOKEN" | tr -d '\r\n')"
site_id="$(printf '%s' "$NETLIFY_SITE_ID" | tr -d '\r\n')"
test -n "$auth_token" || { echo "::error::NETLIFY_AUTH_TOKEN is empty or missing"; exit 1; }
test -n "$site_id" || { echo "::error::NETLIFY_SITE_ID is empty or missing; use the Netlify Site ID, not the site URL"; exit 1; }
netlify deploy \
--dir build/site \
--alias "pr-${{ github.event.pull_request.number }}" \
@@ -96,7 +100,7 @@ jobs:
- name: Download Site Artifact
uses: actions/download-artifact@v4
with:
name: flint-site
name: kryon-site
path: build/site
- name: Install Netlify CLI
@@ -107,6 +111,8 @@ jobs:
set -euo pipefail
auth_token="$(printf '%s' "$NETLIFY_AUTH_TOKEN" | tr -d '\r\n')"
site_id="$(printf '%s' "$NETLIFY_SITE_ID" | tr -d '\r\n')"
test -n "$auth_token" || { echo "::error::NETLIFY_AUTH_TOKEN is empty or missing"; exit 1; }
test -n "$site_id" || { echo "::error::NETLIFY_SITE_ID is empty or missing; use the Netlify Site ID, not the site URL"; exit 1; }
netlify deploy \
--dir build/site \
--prod \
+69 -14
View File
@@ -2,8 +2,12 @@ name: Release
on:
push:
branches:
- master
tags:
- "v*"
paths:
- "include/kryon_version.h"
workflow_dispatch:
inputs:
version:
@@ -23,7 +27,7 @@ jobs:
create-tag:
name: Create Release Tag
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/heads/')
outputs:
tag: ${{ steps.version.outputs.tag }}
@@ -34,22 +38,72 @@ jobs:
fetch-depth: 0
submodules: recursive
- name: Validate Version
- name: Resolve Version
id: version
run: |
set -euo pipefail
tag="${{ inputs.version }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="${{ inputs.version }}"
else
tag="$(sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' include/kryon_version.h)"
fi
case "$tag" in
v[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "Version must look like v0.1.0" >&2; exit 1 ;;
esac
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
echo "Tag $tag already exists" >&2
exit 1
echo "Tag $tag already exists; nothing to release."
echo "tag=" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Ensure CHANGELOG Entry
if: steps.version.outputs.tag != ''
run: |
set -euo pipefail
tag="${{ steps.version.outputs.tag }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# If the entry already exists (hand-written by a maintainer), use it as-is.
if grep -q "^## $tag " CHANGELOG.md; then
echo "CHANGELOG entry for $tag already present."
exit 0
fi
# Otherwise generate one from commits since the most recent tag.
prev_tag="$(git describe --tags --abbrev=0 2>/dev/null || true)"
date="$(date +%Y-%m-%d)"
range="${prev_tag:+$prev_tag..}HEAD"
range="${range:-HEAD}"
{
printf '## %s - %s\n\n' "$tag" "$date"
printf '### Changed\n\n'
git log "$range" --no-merges --pretty=format:'- %s' \
| sed -E 's/^- ([a-z])/- \u\1/'
printf '\n\n'
} > /tmp/new_entry.md
# Insert the generated block immediately after the "# Changelog" heading.
cp CHANGELOG.md CHANGELOG.md.bak
awk -v entry=/tmp/new_entry.md '
FNR==1 && /^# Changelog/ {
print
while ((getline line < entry) > 0) print line
next
}
{ print }
' CHANGELOG.md.bak > CHANGELOG.md
rm -f CHANGELOG.md.bak
git add CHANGELOG.md
git commit -m "Update CHANGELOG for $tag" || echo "No CHANGELOG changes to commit."
git push origin "HEAD:${GITHUB_REF_NAME}"
- name: Create And Push Tag
if: steps.version.outputs.tag != ''
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
@@ -61,14 +115,14 @@ jobs:
name: Build Release Artifacts
runs-on: ubuntu-latest
needs: create-tag
if: always() && (github.event_name == 'push' || needs.create-tag.result == 'success')
if: always() && (startsWith(github.ref, 'refs/tags/') || needs.create-tag.outputs.tag != '')
steps:
- name: Resolve Tag
id: ref
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ -n "${{ needs.create-tag.outputs.tag }}" ]; then
tag="${{ needs.create-tag.outputs.tag }}"
else
tag="${GITHUB_REF_NAME}"
@@ -86,7 +140,7 @@ jobs:
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev pkg-config zlib1g-dev
sudo apt-get install -y build-essential cmake libssl-dev pkg-config zlib1g-dev libzstd-dev libbrotli-dev libsdl2-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev
- name: Build And Test
run: |
@@ -99,21 +153,22 @@ jobs:
run: |
set -euo pipefail
make dist-static CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
archive="$(find dist -maxdepth 1 -type f -name flint-*-static.tar.gz | head -n 1)"
make check-static-package CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
archive="$(find dist -maxdepth 1 -type f -name kryon-*-static.tar.gz | head -n 1)"
test -n "$archive"
echo "FLINT_STATIC_ARCHIVE=$archive" >> "$GITHUB_ENV"
echo "KRYON_STATIC_ARCHIVE=$archive" >> "$GITHUB_ENV"
- name: Upload Static Library Artifact
uses: actions/upload-artifact@v4
with:
name: flint-static-library-${{ steps.ref.outputs.tag }}
path: ${{ env.FLINT_STATIC_ARCHIVE }}
name: kryon-static-library-${{ steps.ref.outputs.tag }}
path: ${{ env.KRYON_STATIC_ARCHIVE }}
if-no-files-found: error
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ref.outputs.tag }}
name: Flint ${{ steps.ref.outputs.tag }}
name: Kryon ${{ steps.ref.outputs.tag }}
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}
files: ${{ env.FLINT_STATIC_ARCHIVE }}
files: ${{ env.KRYON_STATIC_ARCHIVE }}
+2 -12
View File
@@ -4,21 +4,11 @@
*.dll
*~
*.tmp
.zcode
# Build output
build/
dist/
libflint.a
assets/fonts/
# Example binaries
examples/01_file_dialog
examples/02_buttons
examples/02_color
examples/03_scaling
examples/03_theme
examples/04_modal
examples/05_buttons
examples/06_theme
assets/fonts/*
tools/otfchop/otfchop
+6
View File
@@ -7,3 +7,9 @@
[submodule "vendor/curl"]
path = vendor/curl
url = https://github.com/curl/curl.git
[submodule "vendor/cmark-gfm"]
path = vendor/cmark-gfm
url = https://github.com/github/cmark-gfm.git
[submodule "vendor/clay"]
path = vendor/clay
url = https://github.com/nicbarker/clay.git
+126
View File
@@ -0,0 +1,126 @@
# Changelog
## v0.1.7 - 2026-07-26
### Changed
- Bump version to v0.1.7
- Remove native_widget_name compiler name-rewrite hack
- Finish removing Kry sugar verbs — language is now minimal
- Remove redundant Kry verbs; widgets are now a library
- Rework Platforms grid: add Windows, macOS, FreeBSD
- Make text input focus exclusive across UITextField and UITextArea
## v0.1.6 - 2026-07-25
### Changed
- Bump version to v0.1.6
- Resolve tray icon from installed hicolor paths
- Fix site card cursors, release CI, and IDE recent-projects grid
- Trigger site deploy (previous run hit GitHub internal error)
- Restyle docs site with refined modern-retro theme
- Add Kryon IDE start page and fix preview inspection
- Improve Kry language and generic APIs
- Support uninitialized C locals in kc
- Allow args locals in kc functions
- Add Kryon platform thread primitives
- Support local enum blocks in kc
- Support bitwise compound assignments in kc
- Guard Kry compile-time expansion recursion
- Add runtime asset sync API
- Support Kry multidimensional arrays
- Raise Kry type block capacity
- Add Kry named enum syntax
- Add Kry switch syntax
- Update Kryon site goals
- Add Kry web intrinsics
- Add Kry anonymous block scopes
- Add top-level Kry extern declarations
- Add Jai-style Kry defines
- Add Kry top-level macro translation
- Add Kry type aliases
- Allow Kry type-only modules
- Generate project headers from Kry files
- Guard Kry text shorthand parsing
- Respect Kry locals when resolving function values
- Limit Kry function value rewriting
- Resolve Kry function values in expressions
- Add exact C exports for Kry modules
- Make Kry modules the only import path
- Support path-based Kry module use
- Fix IDE preview toolbar and text state
- Tighten leading continuation parsing
- Support leading expression continuations in Kry
- Add native Kry enum blocks
- Support break statements in Kry
- Add native Kry struct declarations
- Support multiline Kry function declarations
- Rewrite nil in Kry static initializers
- Add Jai-style Kry compile-time macros
- Support multiline Kry state initializers
- Use Jai-style typed Kry declarations
- Keep postfix operators on one Kry line
- Support multiline Kry block headers
- Support operator line continuations in Kry
- Support multiline Kry statements
- Add Kry while statements
- Allow app locals in Kry functions
- Lift Kry function limits
- Add flat Kry modules
## v0.1.5 - 2026-07-21
### Added
- Add the Kryon logo as the site and IDE app icon.
- Add C-close Kry language direction docs.
- Add automatic release tagging when the checked-in Kryon version changes.
### Changed
- Replace Kry `include` syntax with explicit `cimport` for C headers.
- Use cleaner changelog version headings without brackets.
### Fixed
- Allocate Kry compiler state on the heap to avoid Linux runner stack crashes.
## v0.1.4 - 2026-07-18
### Changed
- Add Clay as a vendored layout dependency for future Kryon UI work.
- Remove the vendored fontchop dependency and chopped bitmap font assets.
## v0.1.3 - 2026-07-16
### Changed
- Add public Kryon version metadata for release artifacts.
- Move font atlas generation to the vendored fontchop submodule.
- Replace the single implicit UI font with a registered font selection API.
- Improve generated icon asset formatting and desktop/embedded fallbacks.
### Added
- Add Markdown support and text area UI.
- Add pointer release helper APIs and modal layer input capture.
## v0.1.2 - 2026-07-12
### Added
- Add web file dialog loading.
## v0.1.1 - 2026-07-12
### Fixed
- Fix release CI vendor builds.
## v0.1.0 - 2026-07-12
### Added
- Add Kryon release automation.
+233 -88
View File
@@ -1,32 +1,73 @@
CC ?= cc
AR ?= ar
BUILD_DIR ?= build
PREFIX ?= $(HOME)/.local
SITE_DIR ?= docs/site
SITE_BUILD_DIR ?= $(BUILD_DIR)/site
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || printf '%s' 0.0.0)
VERSION_FILE ?= include/kryon_version.h
KRYON_VERSION_STRING := $(shell sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' $(VERSION_FILE) 2>/dev/null)
VERSION ?= $(if $(strip $(KRYON_VERSION_STRING)),$(KRYON_VERSION_STRING),$(shell git describe --tags --always --dirty 2>/dev/null || printf '%s' 0.0.0))
DIST_DIR ?= dist
STATIC_DIST_ROOT := $(BUILD_DIR)/dist/flint-$(VERSION)-static
STATIC_DIST_ARCHIVE := $(DIST_DIR)/flint-$(VERSION)-static.tar.gz
STATIC_DIST_ROOT := $(BUILD_DIR)/dist/kryon-$(VERSION)-static
STATIC_DIST_ARCHIVE := $(DIST_DIR)/kryon-$(VERSION)-static.tar.gz
KC = $(BUILD_DIR)/bin/kc
KI = $(BUILD_DIR)/bin/kryon
KRYON_APP = $(BUILD_DIR)/bin/kryon-app
BINDIR ?= $(PREFIX)/bin
INSTALL ?= install
CFLAGS ?= -Wall -Wextra -O2
CPPFLAGS_BASE = -Iinclude
ICON_DIR ?= icons pfp
CPPFLAGS_BASE = -Iinclude -I$(KRYON_DIR)/vendor/clay
ICON_DIR ?= icons language payments platforms tiles pfp
ICON_FILES = $(foreach dir,$(ICON_DIR),$(wildcard $(dir)/*.png))
ICON_ASSETS_C = src/ui/ui_icon_assets.c
EMBED_ASSETS ?= themes
EMBED_ASSETS ?= themes fonts/noto
EMBED_ASSET_FILES = $(shell find $(EMBED_ASSETS) -type f 2>/dev/null)
EMBED_ASSETS_C = $(BUILD_DIR)/embedded_asset_data.c
FLINT_COMPAT_GENERATOR = tools/generate-flint-compat.sh
FLINT_BOUNDARY_CHECK = tools/check-flint-boundaries.sh
FLINT_COMPAT_HEADER = include/flint_compat.generated.h
FLINT_BACKEND_RENAME_HEADER = $(BUILD_DIR)/generated/raylib_backend_rename.h
FLINT_RAYLIB_WRAPPERS_C = $(BUILD_DIR)/generated/flint_raylib_wrappers.c
FLINT_FONT_OUT ?= assets/fonts/locales
FLINT_FONT_OUTPUTS = $(FLINT_FONT_OUT).png $(FLINT_FONT_OUT).dat
FLINT_FONT_LOCALES ?= locales/*.txt
FLINT_FONT_LOCALE_FILES = $(wildcard $(FLINT_FONT_LOCALES))
FLINT_FONT_FALLBACK_LOCALES = tools/otfchop/locales/en.txt
FLINT_FONT_SOURCE ?= tools/otfchop/unifont-17.0.04.otf
FLINT_OTFCHOP ?= tools/otfchop/otfchop
KRYON_COMPAT_GENERATOR = tools/generate-kryon-compat.sh
KRYON_BOUNDARY_CHECK = tools/check-kryon-boundaries.sh
KRYON_COMPAT_SYMBOL_CHECK = tools/check-raylib-compat-symbols.sh
KRYON_COMPAT_HEADER = include/kryon_compat.generated.h
KRYON_BACKEND_RENAME_HEADER = $(BUILD_DIR)/generated/raylib_backend_rename.h
KRYON_RAYLIB_WRAPPERS_C = $(BUILD_DIR)/generated/kryon_raylib_wrappers.c
KRYON_RAYLIB_GENERATED_PUBLIC_HEADER ?= $(KRYON_COMPAT_HEADER)
KRYON_RAYLIB_BACKEND_RENAME_HEADER ?= $(KRYON_BACKEND_RENAME_HEADER)
UNAME_S := $(shell uname -s 2>/dev/null)
UNAME_M := $(shell uname -m 2>/dev/null)
ifeq ($(UNAME_M),amd64)
KRYON_ARCH := x86_64
else
KRYON_ARCH := $(UNAME_M)
endif
ifeq ($(UNAME_S),Linux)
KRYON_PLATFORM := linux
else ifeq ($(UNAME_S),FreeBSD)
KRYON_PLATFORM := freebsd
else ifeq ($(UNAME_S),Darwin)
KRYON_PLATFORM := macos
else
KRYON_PLATFORM := $(UNAME_S)
endif
RAYLIB_DIR ?= $(KRYON_DIR)/vendor/raylib/src
RAYLIB_BUILD_DIR ?= $(BUILD_DIR)/raylib
RAYLIB_A ?= $(RAYLIB_BUILD_DIR)/libraylib.a
RAY_PKGS ?= sdl2 libdrm gbm egl glesv2
RAY_SDL_CFLAGS ?= $(shell pkg-config --cflags sdl2 2>/dev/null)
RAY_SDL_LDLIBS ?= $(shell pkg-config --libs sdl2 2>/dev/null)
RAY_GL_CFLAGS ?= $(shell pkg-config --cflags libdrm gbm egl glesv2 2>/dev/null)
RAY_GL_LDLIBS ?= $(shell pkg-config --libs libdrm gbm egl glesv2 2>/dev/null)
RAY_CFLAGS ?= $(strip $(RAY_SDL_CFLAGS) $(RAY_GL_CFLAGS))
RAY_LDLIBS ?= $(strip $(RAY_SDL_LDLIBS) $(RAY_GL_LDLIBS))
CURL_CODEC_LDLIBS ?= $(strip \
$(shell pkg-config --libs libbrotlidec 2>/dev/null) \
$(shell pkg-config --libs libbrotlicommon 2>/dev/null) \
$(shell pkg-config --libs libzstd 2>/dev/null))
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
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_STATIC_PACKAGE_EXTERNAL_LIBS ?= $(RAY_LDLIBS) $(KRYON_OPENSSL_SSL_LDLIB) $(KRYON_OPENSSL_CRYPTO_LDLIB) -lpthread -lm
KRYON_STATIC_PACKAGE_LIBS ?= -lkryon -lraylib -loqs -lcurl -lcmark-gfm-extensions -lcmark-gfm $(KRYON_STATIC_PACKAGE_EXTERNAL_LIBS)
KRYON_STATIC_PACKAGE_CFLAGS ?= -I$${includedir} -DHAS_LIBOQS=1 -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),)
@@ -35,16 +76,18 @@ endif
CPPFLAGS += $(CPPFLAGS_BASE)
ARFLAGS ?= rcs
FLINT_DIR ?= .
FLINT_VENDOR_BUILD_DIR ?= $(BUILD_DIR)/vendor
KRYON_DIR ?= .
KRYON_VENDOR_BUILD_DIR ?= $(BUILD_DIR)/vendor
include mk/vendor.mk
include mk/raylib.mk
CPPFLAGS += -DHAS_LIBOQS=1 $(FLINT_LIBOQS_INCLUDE) \
-DHAS_LIBCURL=1 $(FLINT_CURL_CFLAGS)
CPPFLAGS += -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE) \
-DHAS_LIBCURL=1 $(KRYON_CURL_CFLAGS) \
$(KRYON_MARKDOWN_CFLAGS)
SRCS := $(shell find src -type f -name '*.c' | LC_ALL=C sort)
SRCS += $(EMBED_ASSETS_C)
SRCS += $(EMBED_ASSETS_C) $(KRYON_RAYLIB_WRAPPERS_C)
SYSTEM_THEME_PKG := $(shell if pkg-config --exists gtk+-3.0 2>/dev/null; then printf '%s' gtk+-3.0; fi)
ifneq ($(strip $(SYSTEM_THEME_PKG)),)
@@ -54,145 +97,247 @@ endif
OBJS = $(patsubst src/%.c,$(BUILD_DIR)/%.o,$(filter src/%,$(SRCS))) \
$(patsubst $(BUILD_DIR)/%.c,$(BUILD_DIR)/%.o,$(filter $(BUILD_DIR)/%,$(SRCS)))
LIB = libflint.a
LIB = libkryon.a
LYRA_ACCOUNT_TEST = $(BUILD_DIR)/tests/lyra_account_test
LYRA_SYNC_TEST = $(BUILD_DIR)/tests/lyra_sync_test
TRANSITION_TEST = $(BUILD_DIR)/tests/transition_test
FILE_DIALOG_BACKEND_TEST = $(BUILD_DIR)/tests/file_dialog_backend_test
MARKDOWN_TEST = $(BUILD_DIR)/tests/markdown_test
RAYLIB_COMPAT_TEST = $(BUILD_DIR)/tests/raylib_compat_test
UI_TK_TEST = $(BUILD_DIR)/tests/ui_tk_test
PREVIEW_TEST = $(BUILD_DIR)/tests/preview_test
PLATFORM_THREAD_TEST = $(BUILD_DIR)/tests/platform_thread_test
RAYLIB_COMPAT_LDLIBS ?= $(RAY_LDLIBS) -lpthread -lm $(if $(filter linux,$(KRYON_PLATFORM)),-ldl -lrt,)
.PHONY: all clean run font-assets docs-site test bsd-check flint-compat flint-compat-check flint-boundary-check dist-static
.PHONY: all clean run tools examples-run font-assets docs-site test bsd-check kryon-compat kryon-compat-check kryon-boundary-check version release-check dist-static check-static-package install install-static
all: $(LIB)
all: $(LIB) $(KC) $(KI) $(KRYON_APP)
run:
@echo "Building Flint library..."
@$(MAKE) -C . $(LIB)
@echo ""
@echo "Launching examples system..."
run: $(KI)
@if [ -n "$(PROJECT)" ]; then \
project_path=$$(cd "$(PROJECT)" && pwd); \
KRYON_INSPECT=1 KRYON_PROJECT_ROOT="$$project_path" $(KI) "$$project_path"; \
elif [ -n "$(ARGS)" ]; then \
project_path=$$(cd "$(ARGS)" && pwd); \
KRYON_INSPECT=1 KRYON_PROJECT_ROOT="$$project_path" $(KI) "$$project_path"; \
elif [ -n "$(KRYON_PROJECT)" ]; then \
project_path=$$(cd "$(KRYON_PROJECT)" && pwd); \
KRYON_INSPECT=1 KRYON_PROJECT_ROOT="$$project_path" $(KI) "$$project_path"; \
else \
project_path=$$(pwd); \
KRYON_INSPECT=1 KRYON_PROJECT_ROOT="$$project_path" $(KI); \
fi
tools: $(KC) $(KI) $(KRYON_APP)
install: $(KI) $(KRYON_APP)
mkdir -p $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 $(KI) $(DESTDIR)$(BINDIR)/kryon
$(INSTALL) -m 755 $(KRYON_APP) $(DESTDIR)$(BINDIR)/kryon-app
examples-run:
@$(MAKE) -C examples run
clean:
rm -rf $(BUILD_DIR) $(LIB)
$(MAKE) -C tools/otfchop clean
$(MAKE) -C examples web-clean
docs-site:
rm -rf $(SITE_BUILD_DIR)
mkdir -p $(SITE_BUILD_DIR)
cp -R $(SITE_DIR)/. $(SITE_BUILD_DIR)/
$(MAKE) -C examples web EXAMPLES_WEB_SITE_DIR="$(abspath $(SITE_BUILD_DIR))/examples"
cp -R icons platforms language $(SITE_BUILD_DIR)/
cp -R $(SITE_DIR)/cursors $(SITE_BUILD_DIR)/
sh scripts/render-api-html.sh docs/API.md $(SITE_DIR)/api-template.html $(SITE_BUILD_DIR)/api.html
rm -f $(SITE_BUILD_DIR)/api-template.html
test: flint-compat-check flint-boundary-check $(LYRA_ACCOUNT_TEST) $(LYRA_SYNC_TEST) $(TRANSITION_TEST) $(FILE_DIALOG_BACKEND_TEST)
test: kryon-compat-check kryon-boundary-check $(KC) $(LYRA_ACCOUNT_TEST) $(LYRA_SYNC_TEST) $(TRANSITION_TEST) $(FILE_DIALOG_BACKEND_TEST) $(MARKDOWN_TEST) $(RAYLIB_COMPAT_TEST) $(UI_TK_TEST) $(PREVIEW_TEST) $(PLATFORM_THREAD_TEST)
sh tests/kc_syntax_test.sh $(KC)
$(LYRA_ACCOUNT_TEST)
$(LYRA_SYNC_TEST)
$(TRANSITION_TEST)
$(FILE_DIALOG_BACKEND_TEST)
$(MARKDOWN_TEST)
$(RAYLIB_COMPAT_TEST)
$(UI_TK_TEST)
$(PREVIEW_TEST)
$(PLATFORM_THREAD_TEST)
bsd-check:
$(MAKE) clean
$(MAKE) all
$(MAKE) test
flint-compat: $(FLINT_COMPAT_HEADER) $(FLINT_BACKEND_RENAME_HEADER) $(FLINT_RAYLIB_WRAPPERS_C)
kryon-compat: $(KRYON_COMPAT_HEADER) $(KRYON_BACKEND_RENAME_HEADER) $(KRYON_RAYLIB_WRAPPERS_C)
flint-compat-check: | $(BUILD_DIR)
sh $(FLINT_COMPAT_GENERATOR) vendor/raylib/src/raylib.h \
$(BUILD_DIR)/check/flint_compat.generated.h \
kryon-compat-check: | $(BUILD_DIR)
sh $(KRYON_COMPAT_GENERATOR) vendor/raylib/src/raylib.h \
$(BUILD_DIR)/check/kryon_compat.generated.h \
$(BUILD_DIR)/check/raylib_backend_rename.h \
$(BUILD_DIR)/check/flint_raylib_wrappers.c
cmp $(FLINT_COMPAT_HEADER) $(BUILD_DIR)/check/flint_compat.generated.h
$(BUILD_DIR)/check/kryon_raylib_wrappers.c
cmp $(KRYON_COMPAT_HEADER) $(BUILD_DIR)/check/kryon_compat.generated.h
sh $(KRYON_COMPAT_SYMBOL_CHECK) vendor/raylib/src/raylib.h \
$(BUILD_DIR)/check/raylib_backend_rename.h \
$(BUILD_DIR)/check/kryon_raylib_wrappers.c
flint-boundary-check:
sh $(FLINT_BOUNDARY_CHECK) .
kryon-boundary-check:
sh $(KRYON_BOUNDARY_CHECK) .
$(LIB): $(FLINT_COMPAT_HEADER) $(OBJS) | $(FLINT_LIBOQS_A) $(FLINT_CURL_PROTOCOL_CHECK)
$(AR) $(ARFLAGS) $@ $^
$(LIB): $(OBJS) | $(KRYON_COMPAT_HEADER) $(KRYON_LIBOQS_A) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
$(AR) $(ARFLAGS) $@ $(OBJS)
dist-static: $(STATIC_DIST_ARCHIVE)
KC_SRCS := cmd/kc/kc.c cmd/kc/kc_macros.c
$(STATIC_DIST_ARCHIVE): $(LIB) $(FLINT_LIBOQS_A) $(FLINT_CURL_SO) README.md LICENSE docs/API.md
$(KC): $(KC_SRCS) cmd/kc/kc_internal.h | $(BUILD_DIR)/bin
$(CC) $(CFLAGS) -o $@ $(KC_SRCS)
$(KRYON_APP): scripts/kryon-app.sh | $(BUILD_DIR)/bin
cp scripts/kryon-app.sh $@
chmod 755 $@
$(KI): cmd/ki/main.c $(LIB) $(RAYLIB_A) $(KRYON_LIBOQS_A) $(KRYON_CURL_A) $(KRYON_MARKDOWN_DEPS) | $(BUILD_DIR)/bin
$(CC) $(CFLAGS) $(CPPFLAGS) -Isrc/ui $(RAY_CFLAGS) -o $@ \
cmd/ki/main.c \
-Wl,--whole-archive $(LIB) -Wl,--no-whole-archive \
$(RAYLIB_A) $(KRYON_LIBOQS_A) $(KRYON_CURL_LDLIBS) \
$(KRYON_MARKDOWN_LDLIBS) \
-Wl,-export-dynamic $(RAY_LDLIBS) $(LDLIBS) \
$(CURL_CODEC_LDLIBS) -lz -lpthread -lm
version:
@printf '%s\n' '$(VERSION)'
release-check:
@test -n '$(VERSION)'
@grep -q '^## $(VERSION) ' CHANGELOG.md
dist-static: release-check $(STATIC_DIST_ARCHIVE)
check-static-package: $(STATIC_DIST_ARCHIVE)
sh scripts/check-static-package.sh $(STATIC_DIST_ARCHIVE)
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_LIBOQS_A) $(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)/docs $(DIST_DIR)
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) $(STATIC_DIST_ROOT)/lib/
cp $(FLINT_LIBOQS_A) $(STATIC_DIST_ROOT)/lib/
cp $(FLINT_CURL_A) $(STATIC_DIST_ROOT)/lib/
cp README.md LICENSE $(STATIC_DIST_ROOT)/
cp docs/API.md $(STATIC_DIST_ROOT)/docs/
cp $(LIB) $(RAYLIB_A) $(KRYON_LIBOQS_A) $(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/
cp CHANGELOG.md docs/API.md $(STATIC_DIST_ROOT)/share/doc/kryon/
cp examples/package/*.c $(STATIC_DIST_ROOT)/examples/
git submodule status > $(STATIC_DIST_ROOT)/SUBMODULES.txt
printf '%s\n' '$(VERSION)' > $(STATIC_DIST_ROOT)/VERSION
printf '%s\n' \
'{' \
' "name": "kryon",' \
' "version": "$(VERSION)",' \
' "target": "$(KRYON_PLATFORM)-$(KRYON_ARCH)",' \
' "compiler": "$(CC)",' \
' "static_libraries": ["libkryon.a", "libraylib.a", "liboqs.a", "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
printf '%s\n' \
'prefix=$${pcfiledir}/../..' \
'exec_prefix=$${prefix}' \
'libdir=$${prefix}/lib' \
'includedir=$${prefix}/include' \
'' \
'Name: Flint' \
'Description: Flint C support library for raylib-style applications' \
'Name: Kryon' \
'Description: Kryon C support library for raylib-style applications' \
'Version: $(VERSION)' \
'Cflags: -I$${includedir} -DHAS_LIBOQS=1 -DHAS_LIBCURL=1 -DCURL_STATICLIB' \
'Libs: -L$${libdir} -lflint -loqs -lcurl -lssl -lcrypto -lpthread -lm' \
> $(STATIC_DIST_ROOT)/lib/pkgconfig/flint.pc
tar -C $(BUILD_DIR)/dist -czf $@ flint-$(VERSION)-static
'Cflags: $(KRYON_STATIC_PACKAGE_CFLAGS)' \
'Libs: -L$${libdir} $(KRYON_STATIC_PACKAGE_LIBS)' \
> $(STATIC_DIST_ROOT)/lib/pkgconfig/kryon.pc
printf '%s\n' \
'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_LIBOQS=1;HAS_LIBCURL=1;CURL_STATICLIB;KRYON_HAS_CMARK_GFM=1")' \
'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_PACKAGE_PREFIX}/lib/liboqs.a" "$${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
tar -C $(BUILD_DIR)/dist -czf $@ kryon-$(VERSION)-static
$(FLINT_COMPAT_HEADER) $(FLINT_BACKEND_RENAME_HEADER) $(FLINT_RAYLIB_WRAPPERS_C): $(FLINT_COMPAT_GENERATOR) vendor/raylib/src/raylib.h | $(BUILD_DIR)
sh $(FLINT_COMPAT_GENERATOR) vendor/raylib/src/raylib.h \
$(FLINT_COMPAT_HEADER) $(FLINT_BACKEND_RENAME_HEADER) \
$(FLINT_RAYLIB_WRAPPERS_C)
$(LYRA_ACCOUNT_TEST): tests/lyra_account_test.c src/lyra/lyra_account.c include/lyra_account.h $(FLINT_LIBOQS_A) | $(BUILD_DIR)
$(LYRA_ACCOUNT_TEST): tests/lyra_account_test.c src/lyra/lyra_account.c include/lyra_account.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(FLINT_LIBOQS_INCLUDE) \
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE) \
tests/lyra_account_test.c src/lyra/lyra_account.c \
$(FLINT_LIBOQS_A) -lm -o $@
$(KRYON_LIBOQS_A) -lm -o $@
$(LYRA_SYNC_TEST): tests/lyra_sync_test.c src/lyra/lyra_sync.c src/lyra/lyra_account.c include/lyra_sync.h include/lyra_account.h $(FLINT_LIBOQS_A) | $(BUILD_DIR)
$(LYRA_SYNC_TEST): tests/lyra_sync_test.c src/lyra/lyra_sync.c src/lyra/lyra_account.c include/lyra_sync.h include/lyra_account.h $(KRYON_LIBOQS_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(FLINT_LIBOQS_INCLUDE) \
$(CC) $(CPPFLAGS) $(CFLAGS) -DHAS_LIBOQS=1 $(KRYON_LIBOQS_INCLUDE) \
tests/lyra_sync_test.c src/lyra/lyra_sync.c src/lyra/lyra_account.c \
$(FLINT_LIBOQS_A) -lm -o $@
$(KRYON_LIBOQS_A) -lm -o $@
$(TRANSITION_TEST): tests/transition_test.c src/ui/ui_transition.c include/ui_transition.h | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/transition_test.c src/ui/ui_transition.c -o $@
$(MARKDOWN_TEST): tests/markdown_test.c src/markdown.c include/markdown.h $(KRYON_MARKDOWN_DEPS) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) $(KRYON_MARKDOWN_CFLAGS) \
tests/markdown_test.c src/markdown.c \
$(KRYON_MARKDOWN_LDLIBS) -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 -o $@
$(RAYLIB_COMPAT_TEST): tests/raylib_compat_test.c $(LIB) $(RAYLIB_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/raylib_compat_test.c \
$(LIB) $(RAYLIB_A) $(RAYLIB_COMPAT_LDLIBS) \
-o $@
$(UI_TK_TEST): tests/ui_tk_test.c $(LIB) $(RAYLIB_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/ui_tk_test.c \
$(LIB) $(RAYLIB_A) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS) \
-o $@
$(PREVIEW_TEST): tests/preview_test.c $(LIB) $(RAYLIB_A) | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/preview_test.c \
$(LIB) $(RAYLIB_A) $(RAYLIB_COMPAT_LDLIBS) $(LDLIBS) \
-o $@
$(PLATFORM_THREAD_TEST): tests/platform_thread_test.c src/platform/platform_thread.c include/platform.h | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) tests/platform_thread_test.c \
src/platform/platform_thread.c -lpthread -o $@
$(ICON_ASSETS_C): $(ICON_FILES) scripts/embed-icons.sh include/ui_icons.h
sh scripts/embed-icons.sh "$(ICON_DIR)" $@
src/ui/ui_icon_names.c: $(ICON_FILES) scripts/embed-icons.sh include/ui_icon_types.h
@$(MAKE) --quiet $(ICON_ASSETS_C)
$(EMBED_ASSETS_C): $(EMBED_ASSET_FILES) $(FLINT_FONT_OUTPUTS) scripts/embed-assets.sh include/embedded_assets.h | $(BUILD_DIR)
sh scripts/embed-assets.sh $@ $(EMBED_ASSETS) $(FLINT_FONT_OUTPUTS)
$(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 | $(BUILD_DIR) $(FLINT_LIBOQS_A) $(FLINT_CURL_PROTOCOL_CHECK)
$(BUILD_DIR)/%.o: src/%.c | $(BUILD_DIR) $(KRYON_LIBOQS_A) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c | $(BUILD_DIR) $(FLINT_LIBOQS_A) $(FLINT_CURL_PROTOCOL_CHECK)
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c | $(BUILD_DIR) $(KRYON_LIBOQS_A) $(KRYON_CURL_PROTOCOL_CHECK) $(KRYON_MARKDOWN_DEPS)
@mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $@
$(FLINT_OTFCHOP): tools/otfchop/otfchop.c tools/otfchop/stb_truetype.h tools/otfchop/stb_image_write.h
$(MAKE) -C tools/otfchop otfchop
$(BUILD_DIR)/bin:
mkdir -p $@
font-assets: $(FLINT_FONT_OUTPUTS)
$(FLINT_FONT_OUTPUTS): $(FLINT_OTFCHOP) $(FLINT_FONT_SOURCE) $(FLINT_FONT_FALLBACK_LOCALES) $(FLINT_FONT_LOCALE_FILES)
@mkdir -p $(dir $(FLINT_FONT_OUT))
@set -- $(FLINT_FONT_LOCALES); \
case "$(FLINT_FONT_LOCALES)" in \
*\**|*\?*) \
if [ "$$1" = "$(FLINT_FONT_LOCALES)" ]; then \
set -- $(FLINT_FONT_FALLBACK_LOCALES); \
fi; \
;; \
esac; \
$(FLINT_OTFCHOP) $(FLINT_FONT_SOURCE) "$$@" $(FLINT_FONT_OUT)
font-assets:
@printf '%s\n' 'font assets are checked in or supplied by downstream apps'
+77 -22
View File
@@ -1,31 +1,31 @@
# Flint
# Kryon
Flint is a small C support library for raylib-style applications. It keeps a
raylib-compatible public surface available through `flint.h`, then adds the
pieces shared by downstream apps: UI controls, layout helpers, text rendering,
themes, embedded assets, locale loading, file dialogs, desktop tray support,
runtime asset downloads, and Lyra account/sync helpers.
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 Lyra account/sync helpers.
## Layout
- `include/` - public headers, including `flint.h` and generated raylib
- `include/` - public headers, including `kryon.h` and generated raylib
compatibility declarations
- `src/` - Flint implementation files, with reusable UI modules under `src/ui/`
- `src/` - Kryon implementation files, with reusable UI modules under `src/ui/`
- `icons/` and `pfp/` - PNG icon inputs embedded into `src/ui/ui_icon_assets.c`
- `themes/` - built-in theme files for the runtime theme loader
- `assets/fonts/` - generated locale font atlas outputs
- `fonts/noto/` - bundled Noto Sans TTF/OTF font assets
- `mk/` - Make fragments for native, web, Android, Windows, packaging, and
vendored dependency builds
- `scripts/` - asset embedding, icon embedding, raylib preparation, and boundary
check helpers
- `examples/` - small programs that exercise Flint UI features
- `examples/` - small programs that exercise Kryon UI features
- `tests/` - focused C tests for account, sync, and transition helpers
- `vendor/raylib`, `vendor/curl`, `vendor/liboqs` - source submodules used by
downstream app builds
## Building
Flint builds with the repository Makefile:
Kryon builds with the repository Makefile:
```bash
make
@@ -50,38 +50,78 @@ Build a distributable static-library archive with:
make dist-static
```
The archive contains `libflint.a`, public headers, API docs, `liboqs.a`,
`libcurl.a`, a `flint.pc` file, and the submodule revisions used to build it.
The archive is an extracted SDK layout. It contains `libkryon.a`,
`libraylib.a`, vendored static dependency libraries, public headers, API docs,
example consumers, CMake and pkg-config metadata, third-party notices, a package
manifest, and the submodule revisions used to build it. Validate it with:
```bash
make check-static-package
```
`libkryon.a` stays focused on Kryon object files. Companion libraries are shipped
beside it and linked through `lib/pkgconfig/kryon.pc`. OpenSSL is still treated
as an external system/toolchain dependency unless explicit OpenSSL static library
paths are supplied at build time.
## Releases
Flint releases are tag-driven. Run the `Release` GitHub Actions workflow with a
Kryon releases are tag-driven. Run the `Release` GitHub Actions workflow with a
version such as `v0.1.0`; the workflow validates the version, creates and pushes
the annotated tag, checks out that tag, builds and tests Flint, packages the
the annotated tag, checks out that tag, builds and tests Kryon, packages the
static-library archive, uploads it as an artifact, and attaches it to the GitHub
release. Pushing a `v*` tag manually uses the same build-and-publish path.
## Integration
To integrate Flint into your project:
To integrate Kryon into your project:
1. Add `include/` to your header search paths
2. Include `flint.h` for the raylib-compatible API plus Flint modules
3. Compile Flint sources from `src/` and `src/ui/`, or use the `mk/` fragments
to let Flint assemble source lists and platform flags
2. Include `kryon.h` for the raylib-compatible API plus Kryon modules
3. Compile Kryon sources from `src/` and `src/ui/`, or use the `mk/` fragments
to let Kryon assemble source lists and platform flags
4. Use `scripts/embed-icons.sh` and `scripts/embed-assets.sh` when your app
needs custom embedded icons, locale files, fonts, themes, or image/audio
assets
5. Include `mk/vendor.mk` when your app enables curl or liboqs-backed features
Applications should keep build artifacts in their own build directories, but
the dependency source of truth and common build recipes should live under Flint.
the dependency source of truth and common build recipes should live under Kryon.
For TLS-enabled curl builds, `mk/vendor.mk` passes the `OPENSSL_*` make
variables through to the vendored curl CMake build.
## App Builds
Kryon owns the app command surface through `kryon-app`. From an app repository:
```sh
kryon-app build native
kryon-app build web
kryon-app build android-debug
kryon-app package appimage
kryon-app preview
```
App `project.kryon` files should use `target` entries that call `kryon-app`
rather than embedding platform-specific build commands directly. Existing app
Makefiles can remain as backend glue while repeated native, web, Android, and
packaging logic moves into Kryon `mk/` fragments.
## Preview Projects
Kryon IDE can host richer project previews without requiring the project to be
rewritten as `.kry` screens. A project can add `project.kryon` metadata such as
`preview_size`, `preview_asset_root`, and `preview_scene`, then provide a
`build_live` command that builds `build/kryon/live_preview.so`. The live module
continues to expose the normal `CreateKryonLivePreview`/`AppHost` entry point,
and can optionally expose `CreateKryonPreviewHost` for future scene/layer editing
metadata. This keeps gameplay or simulation code in the app while letting Kryon
IDE select scenes, draw interactive previews, and eventually edit shared preview
layers.
## Conventions
Flint follows raylib-style C conventions where practical: lowercase module
Kryon follows raylib-style C conventions where practical: lowercase module
filenames, simple C structs, and public functions named like raylib APIs
(`InitWindow`, `DrawTexture`, `BeginUIFrame`, `DrawUIButton`). Internal helpers
stay private to `src/` unless a downstream app needs the API in `include/`.
@@ -90,5 +130,20 @@ stay private to `src/` unless a downstream app needs the API in `include/`.
- `docs/API.md` documents the public API.
- `docs/site/` contains the static documentation website.
- `docs/AGENTS.md` documents how downstream apps should use Flint, including
- `docs/AGENTS.md` documents how downstream apps should use Kryon, including
modal/input capture and submodule update rules.
## Toolkit Direction
The `ui_tk.h` layer is Kryon's pragmatic Tk replacement surface. It stays in the
raylib style: one direct struct-and-call path per widget, caller-owned state,
immediate-mode drawing, and no builder objects or scripting runtime. The numbered
examples `09_geometry` through `18_accessibility` demonstrate each toolkit
feature family.
## Kry Language Direction
`docs/KRY_LANGUAGE_PLAN.md` describes the migration path for making `.kry` a
C-close, C-transpiled app language with direct C interoperability. The goal is
for apps to move product UI and screen controllers into Kry while keeping native
platform, storage, and performance-sensitive code in C.
+16
View File
@@ -0,0 +1,16 @@
# Third-Party Notices
The Kryon static package includes third-party code built from the repository
submodules listed in `SUBMODULES.txt`.
- raylib: zlib/libpng license, see `vendor/raylib/LICENSE` in the source tree.
- liboqs: MIT license, see `vendor/liboqs/LICENSE.txt` in the source tree.
- 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.
- Clay: zlib/libpng license, see `vendor/clay/LICENSE.md` in the source tree.
- Noto fonts: SIL Open Font License 1.1, see `fonts/noto/LICENSE.txt` in the source tree.
OpenSSL is not vendored into the package by default. When `kryon.pc` lists
`-lssl -lcrypto`, those libraries are expected to come from the target system or
from paths supplied with `OPENSSL_ROOT_DIR`, `OPENSSL_SSL_LIBRARY`, and
`OPENSSL_CRYPTO_LIBRARY` at build time.
+4540
View File
File diff suppressed because it is too large. Load diff
+105
View File
@@ -0,0 +1,105 @@
#ifndef KRYON_KC_INTERNAL_H
#define KRYON_KC_INTERNAL_H
#include <stddef.h>
enum {
KC_PATH_MAX = 1024,
KC_TEXT_MAX = 1024 * 1024,
KC_NAME_MAX = 128,
KC_INCLUDE_MAX = 64,
KC_USE_MAX = 32,
KC_CALL_MAX = 64,
KC_CONST_MAX = 64,
KC_DEFINE_MAX = 64,
KC_TYPE_MAX = 256,
KC_RAW_MAX = 1024,
KC_STATE_MAX = 128,
KC_BODY_MAX = 512,
KC_BODY_LINE_MAX = 1024,
};
typedef struct KryFunction {
char screen[KC_NAME_MAX];
char args[512];
char return_type[KC_NAME_MAX];
char guard[KC_BODY_LINE_MAX];
int exact_name;
int is_public;
int global_name;
char calls[KC_CALL_MAX][512];
char body[KC_BODY_MAX][KC_BODY_LINE_MAX];
int body_line[KC_BODY_MAX];
int call_count;
int body_count;
} KryFunction;
typedef struct KryFile {
char *path;
const char *root;
char *text;
char app_title[256];
int app_width;
int app_height;
int app_fps;
int app_font_examples;
char app_theme[KC_NAME_MAX];
int app_dark_mode;
int no_main;
char raw[KC_RAW_MAX][KC_BODY_LINE_MAX];
char public_types[KC_TYPE_MAX][KC_BODY_LINE_MAX];
char private_types[KC_TYPE_MAX][KC_BODY_LINE_MAX];
char state[KC_STATE_MAX][KC_BODY_LINE_MAX];
char public_globals[KC_STATE_MAX][KC_BODY_LINE_MAX];
char globals[KC_STATE_MAX][KC_BODY_LINE_MAX];
char includes[KC_INCLUDE_MAX][KC_PATH_MAX];
char include_guards[KC_INCLUDE_MAX][KC_BODY_LINE_MAX];
char const_names[KC_CONST_MAX][KC_NAME_MAX];
char const_exprs[KC_CONST_MAX][KC_BODY_LINE_MAX];
char define_names[KC_DEFINE_MAX][KC_NAME_MAX];
char define_values[KC_DEFINE_MAX][KC_BODY_LINE_MAX];
char define_guards[KC_DEFINE_MAX][KC_BODY_LINE_MAX];
char module[KC_NAME_MAX];
char module_file[KC_NAME_MAX];
char use_aliases[KC_USE_MAX][KC_NAME_MAX];
char use_modules[KC_USE_MAX][KC_NAME_MAX];
KryFunction *functions;
int raw_count;
int public_type_count;
int private_type_count;
int state_count;
int public_global_count;
int global_count;
int include_count;
int const_count;
int define_count;
int use_count;
int function_count;
int function_cap;
int current_line;
KryFunction *current;
} KryFile;
typedef struct KryMacroFrame {
char condition[KC_BODY_LINE_MAX];
char excluded[KC_BODY_LINE_MAX];
} KryMacroFrame;
void add_raw_line(KryFile *file, const char *line);
void add_type_line(KryFile *file, int is_public, const char *fmt, ...);
void add_state_line(KryFile *file, const char *line);
void expand_compile_expr(char *dst, size_t dst_size, const KryFile *file,
const char *src);
void add_guard_line(KryFile *file, const char *guard, int is_public_type,
int is_type, int is_state);
void add_guard_end(KryFile *file, int is_public_type, int is_type,
int is_state);
void combine_compile_guards(char *dst, size_t dst_size, const char *left,
const char *right);
void current_macro_guard(char *dst, size_t dst_size,
const KryMacroFrame *macros, int macro_count);
void append_macro_excluded(char *dst, size_t dst_size, const char *current,
const char *next);
#endif
+74
View File
@@ -0,0 +1,74 @@
#include "kc_internal.h"
#include <stdio.h>
#include <string.h>
void
add_guard_line(KryFile *file, const char *guard, int is_public_type,
int is_type, int is_state)
{
char line[KC_BODY_LINE_MAX];
if(guard == NULL || guard[0] == '\0')
return;
snprintf(line, sizeof(line), "#if %s", guard);
if(is_type)
add_type_line(file, is_public_type, "%s", line);
else if(is_state)
add_state_line(file, line);
else
add_raw_line(file, line);
}
void
add_guard_end(KryFile *file, int is_public_type, int is_type, int is_state)
{
if(is_type)
add_type_line(file, is_public_type, "#endif");
else if(is_state)
add_state_line(file, "#endif");
else
add_raw_line(file, "#endif");
}
void
combine_compile_guards(char *dst, size_t dst_size, const char *left,
const char *right)
{
const char *a = left != NULL ? left : "";
const char *b = right != NULL ? right : "";
if(a[0] == '\0') {
snprintf(dst, dst_size, "%s", b);
} else if(b[0] == '\0') {
snprintf(dst, dst_size, "%s", a);
} else {
snprintf(dst, dst_size, "(%s) && (%s)", a, b);
}
}
void
current_macro_guard(char *dst, size_t dst_size, const KryMacroFrame *macros,
int macro_count)
{
char guard[KC_BODY_LINE_MAX] = "";
for(int i = 0; i < macro_count; i++) {
char next[KC_BODY_LINE_MAX];
combine_compile_guards(next, sizeof(next), guard,
macros[i].condition);
snprintf(guard, sizeof(guard), "%s", next);
}
snprintf(dst, dst_size, "%s", guard);
}
void
append_macro_excluded(char *dst, size_t dst_size, const char *current,
const char *next)
{
if(current == NULL || current[0] == '\0')
snprintf(dst, dst_size, "%s", next);
else
snprintf(dst, dst_size, "(%s) || (%s)", current, next);
}
+5429
View File
File diff suppressed because it is too large. Load diff
+28 -28
View File
@@ -1,23 +1,23 @@
# Flint Agent Guide
# Kryon Agent Guide
This document is for agents and maintainers using Flint inside applications such as
Inbe. It describes the behavior Flint owns, what application code should keep, and
This document is for agents and maintainers using Kryon inside applications such as
Inbe. It describes the behavior Kryon owns, what application code should keep, and
how to update downstream projects without editing vendored copies by hand.
## Role
Flint is a small immediate-mode UI layer on top of raylib. Applications should use
Flint for shared UI behavior instead of duplicating pointer capture, modal backdrop,
Kryon is a small immediate-mode UI layer on top of raylib. Applications should use
Kryon for shared UI behavior instead of duplicating pointer capture, modal backdrop,
button, tab, scroll, text input, theme, and DPI logic in each project.
Keep application code focused on product state and domain behavior. Move repeated UI
interaction rules into Flint when more than one screen or project needs them.
interaction rules into Kryon when more than one screen or project needs them.
## Frame Lifecycle
Call `BeginUIFrame(width, height, dpi)` once at the start of a normal
screen-space UI frame. If the application uses a transformed UI camera, call
`InitUI(width, height, dpi)` and then `SetUIFrame(camera)` instead. Flint sanitizes
`InitUI(width, height, dpi)` and then `SetUIFrame(camera)` instead. Kryon sanitizes
invalid cameras before using them; a zero-initialized `Camera2D` is treated as
`GetUIDefaultCamera()` so pointer input does not silently break.
@@ -32,14 +32,14 @@ Beginning a frame resets per-frame interaction state:
Do not persist `ui_set_input_blocked` or input clips across frames. Register them again
while rendering the UI that needs them. Modal capture is registered while drawing the
modal and Flint carries it into the next frame. Until the current frame registers the
modal bounds again, Flint captures all pointer input so controls underneath the modal
modal and Kryon carries it into the next frame. Until the current frame registers the
modal bounds again, Kryon captures all pointer input so controls underneath the modal
cannot receive clicks before the modal is drawn.
## Input Capture
Every clickable Flint control should gate pointer interaction through
`UIInputCapturesClick(point)` or the lower-level helpers already used inside Flint.
Every clickable Kryon control should gate pointer interaction through
`UIInputCapturesClick(point)` or the lower-level helpers already used inside Kryon.
That keeps scroll drags, dropdowns, modal backdrops, and explicit input blockers from
leaking clicks to the screen underneath.
@@ -56,7 +56,7 @@ Use these APIs by responsibility:
## Modal Rules
Flint modal helpers own backdrop capture:
Kryon modal helpers own backdrop capture:
- `DrawUIActionModal`
- `DrawUIModal`
@@ -83,7 +83,7 @@ inside the modal usable.
Do not manage modal click blocking in application-level route code. The application
should decide whether a modal is open and what state changes happen after a modal
button is clicked; Flint should decide whether pointer input is captured.
button is clicked; Kryon should decide whether pointer input is captured.
## Custom Modal Pattern
@@ -101,14 +101,14 @@ DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
DrawRectangle(modal_x, modal_y, modal_w, modal_h, GetThemeSurface());
```
Before this call on a frame following an active modal, Flint captures all pointer input.
After this call, normal Flint controls inside the rectangle remain clickable because
Before this call on a frame following an active modal, Kryon captures all pointer input.
After this call, normal Kryon controls inside the rectangle remain clickable because
their hit tests are inside the active modal bounds. Controls outside the rectangle see
the click as captured in the current frame and the next frame.
## What To Move Into Flint
## What To Move Into Kryon
Move behavior into Flint when it is general UI behavior rather than product behavior:
Move behavior into Kryon when it is general UI behavior rather than product behavior:
- repeated modal shell drawing or backdrop capture
- repeated button hit testing, hover, disabled, and focus handling
@@ -128,35 +128,35 @@ Keep behavior in the app when it is domain-specific:
## File Dialog Backends
Flint owns desktop file dialog backend selection. Applications should call
Kryon owns desktop file dialog backend selection. Applications should call
`LoadFileDialog`, `SaveFileDialog`, or `SelectFileDialogFolder` instead of invoking
desktop-specific picker commands directly.
The default backend order is `zenity`, then `kdialog`, then `yad`. For local
diagnostics and packaging checks, `FLINT_FILE_DIALOG_BACKEND` can be set to `auto`,
diagnostics and packaging checks, `KRYON_FILE_DIALOG_BACKEND` can be set to `auto`,
`zenity`, `kdialog`, `yad`, or `none`.
Do not add permanent app dependencies on an XFCE-specific picker. If a downstream app
needs different desktop behavior, add the backend support in Flint first, then update
needs different desktop behavior, add the backend support in Kryon first, then update
the downstream submodule pointer.
## Downstream Submodule Workflow
Applications should vendor Flint as a git submodule. Do not edit
`vendor/flint` directly for permanent changes.
Applications should vendor Kryon as a git submodule. Do not edit
`vendor/kryon` directly for permanent changes.
Use this flow:
1. Edit the real Flint repository.
2. Commit and push Flint.
3. In the downstream app, update the `vendor/flint` submodule to the pushed commit.
1. Edit the real Kryon repository.
2. Commit and push Kryon.
3. In the downstream app, update the `vendor/kryon` submodule to the pushed commit.
4. Commit the downstream app's submodule pointer and any app code needed to use the new
Flint API.
Kryon API.
This keeps Flint reusable and prevents project-local vendor edits from diverging.
This keeps Kryon reusable and prevents project-local vendor edits from diverging.
## Documentation Rules
Keep `docs/API.md` as the public API reference. Keep this guide as the operational
guidance for agents and maintainers. Documentation in Flint should describe current
guidance for agents and maintainers. Documentation in Kryon should describe current
APIs, current behavior, and the expected downstream workflow.
+66 -27
View File
@@ -1,6 +1,6 @@
# UI API Documentation
Flint is a lightweight C UI component library for embedded applications and runtime environments. It provides core UI primitives and icon asset management without external dependencies.
Kryon is a lightweight C UI component library for embedded applications and runtime environments. It provides core UI primitives and icon asset management without external dependencies.
## Table of Contents
@@ -16,7 +16,7 @@ Flint is a lightweight C UI component library for embedded applications and runt
- [Icons](#icons)
- [Theme](#theme)
- [Locale](#locale)
- [Lyra Sync](#lyra-sync)
- [Sync](#sync)
- [Transitions](#transitions)
- [Runtime Assets](#runtime-assets)
- [File Dialogs](#file-dialogs)
@@ -49,12 +49,12 @@ void InitUI(int width, int height, float dpi);
- `height` - Viewport height in pixels
- `dpi` - DPI scale factor (1.0 = 96 DPI)
### `SetUIColors`
### `SetCurrentTheme`
Set the global color scheme for UI elements.
Set the active theme. UI controls automatically use the active theme colors.
```c
void SetUIColors(Color text, Color bg, Color surface, Color circle, Color button, Color button_hover, Color icon);
void SetCurrentTheme(int theme_id, int current_dark_mode);
void SetUILinkColor(Color link);
```
@@ -277,18 +277,20 @@ void ResetUIClip(void);
#### Font Management
```c
void SetUIFont(Font font);
void SetUISmallFont(Font font);
Font GetUIFont(void);
int RegisterUIFont(const char *name, Font font);
int RegisterUISmallFont(const char *name, Font font);
int UseUIFont(const char *name);
int UIFontHasGlyph(Font font, int codepoint);
```
#### Font Loading
```c
Font LoadUIChoppedFont(const char *png_path, const char *dat_path, int base_size);
Font LoadUIChoppedFontFromMemory(const unsigned char *png_data, unsigned int png_size,
const unsigned char *dat_data, unsigned int dat_size, int base_size);
Font LoadUIFontFromMemory(const char *file_type, const unsigned char *font_data, unsigned int font_size, int base_size);
Font LoadUIFontAsset(const char *path, int base_size);
void UnloadUIFont(Font *font);
void ClearUIFonts(void);
```
#### Text Measurement
@@ -400,7 +402,7 @@ Profile-picture PNGs in `pfp/` are embedded into the same icon catalog with
`GetUIProfilePictureIconType`, and `GetUIProfilePictureIconName` to enumerate
the standard profile-picture options.
Flint also exposes stable `UI_LYRA_PROFILE_ICON_*` IDs and mapping helpers:
Kryon also exposes stable `UI_LYRA_PROFILE_ICON_*` IDs and mapping helpers:
```c
UIIconType GetUIProfilePictureIconTypeForLyraID(int lyra_id);
@@ -500,9 +502,9 @@ int GetCurrentLocaleIndex(void);
---
### Lyra Sync
### Sync
Common Lyra sync protocol helpers. Flint owns URL handling, token auth,
Lyra 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. Applications still own their local data model and provide callbacks to
build sync payloads, apply sync responses, store auth tokens, and perform
@@ -686,7 +688,7 @@ void SetRuntimeAssetDownloadBackend(RuntimeAssetDownloadBackend backend);
### File Dialogs
Open native desktop file dialogs through an external helper backend. The default
backend order is `zenity`, then `kdialog`, then `yad`. `FLINT_FILE_DIALOG_BACKEND`
backend order is `zenity`, then `kdialog`, then `yad`. `KRYON_FILE_DIALOG_BACKEND`
can force `zenity`, `kdialog`, `yad`, `auto`, or `none` for debugging and packaging
checks. Explicit forced backends fail closed when the helper is not available.
@@ -1286,7 +1288,7 @@ void EndUIFocus(void);
Normal UI code does not need to call these. `BeginUIFrame` and `SetUIFrame`
manage the focus pass automatically. Use these only for custom frame lifecycles
that do not go through Flint's normal frame entry points.
that do not go through Kryon's normal frame entry points.
### Focus Registration
@@ -1413,27 +1415,64 @@ typedef enum {
---
## Pragmatic Tk Toolkit
`ui_tk.h` adds Kryon's Tk-replacement layer. The rule is one simple way to use
each widget: prepare a plain struct, keep state in caller variables, and call the
matching immediate-mode function each frame.
```c
UIFrame frame = BeginUIFrameBox((Rectangle){40, 40, 320, 200}, 12, 12, 8);
Rectangle row = UIFramePack(&frame, UI_SIDE_TOP, 32);
int selected = 0;
DrawUIListBox((UIListBox){
.bounds = row,
.id = 10,
.items = items,
.item_count = item_count,
.selected_index = &selected,
.row_height = 30
});
```
Collection widgets use `scroll_offset` as a caller-owned pixel offset. Canvas
uses the same one-call shape: draw between `BeginUICanvas` and `EndUICanvas`;
scroll and zoom in the `UICanvas` struct are applied to canvas drawing and hit
coordinates.
Text fields and text areas use the shared `EditUIText` core. Ctrl/Cmd+C copies
the field buffer, Ctrl/Cmd+X cuts it, and Ctrl/Cmd+V pastes clipboard text
through the existing codepoint filter.
Feature families:
- Geometry: `BeginUIFrameBox`, `UIFramePack`, `UIGridCell`, `UIPlace`, `DrawUISeparator`
- Menus: `DrawUIMenuBar`, `DrawUIPopupMenu`
- Basic controls: `DrawUIRadioButton`, `DrawUIProgressBar`, `DrawUISpinbox`, `DrawUICombobox`, `DrawUILabelFrame`, `DrawUIImageBox`
- Collections: `DrawUIListBox`, `DrawUITreeView`, `DrawUITableView`
- Canvas: `BeginUICanvas`, `EndUICanvas`, `DrawUICanvasGrid`, `UICanvasHitTest`
- Containers: `DrawUINotebook`, `DrawUIPanedView`, `DrawUICollapsible`
- Dialogs/platform: `DrawUIMessageDialog`, `DrawUIConfirmDialog`, `DrawUIPromptDialog`, `DrawUIColorPicker`, `DispatchUIAccelerators`, clipboard helpers
- Accessibility/debug: `DrawUIFocusDebugOverlay`
Examples `09_geometry` through `18_accessibility` demonstrate these APIs.
---
## Integration Example
```c
#include "flint.h"
#include "kryon.h"
int main(void) {
// Initialize window with Raylib
InitWindow(320, 560, "Flint Demo");
InitWindow(320, 560, "Kryon Demo");
SetTargetFPS(60);
// Configure UI colors
// Configure UI theme
SetCurrentTheme(THEME_SKY, 0);
float dpi = 1.0f; // Get from platform
SetUIColors(
(Color){240, 240, 240, 255}, // text
(Color){40, 40, 40, 255}, // bg
(Color){60, 60, 60, 255}, // surface
(Color){80, 80, 80, 255}, // circle
(Color){160, 160, 160, 255}, // button
(Color){180, 180, 180, 255}, // button_hover
(Color){200, 200, 200, 255} // icon
);
while (!WindowShouldClose()) {
BeginDrawing();
+91
View File
@@ -0,0 +1,91 @@
# Kryon App Build Plan
Goal: Kryon owns the repeatable build and packaging flow for every Kryon app.
App repositories should provide app metadata, native sources, `.kry` sources, and
assets. Kryon should provide the compiler, runtime, dependency builds, packaging
helpers, IDE preview hooks, and diagnostics.
## App Contract
Each app should define one project file, `project.kryon`, with the portable
metadata Kryon needs:
- app id, name, title, version, license, maintainer, website, categories
- source roots for C and `.kry`
- asset roots for images, sounds, fonts, locales, and generated embedded assets
- platform knobs such as Android id/activity, Linux desktop metadata, package
names, and signing-key variables
- build feature flags such as file dialog, tray, sync, audio, and web runtime
The app repo may keep small glue files for platform entry points, but target
selection, dependency build rules, generated Kryon C output, and package layout
should come from Kryon.
## Unified Commands
Kryon should expose one command surface for all apps:
- `kryon build native`
- `kryon build web`
- `kryon build android-debug`
- `kryon build android-release`
- `kryon package linux`
- `kryon package appimage`
- `kryon package deb`
- `kryon package rpm`
- `kryon package flatpak`
- `kryon package snap`
- `kryon package click`
- `kryon package windows`
- `kryon preview`
- `kryon test`
Makefiles in app repos should become thin wrappers that call these commands.
## Build Ownership
Kryon owns:
- strict `.kry` parsing and file:line:column diagnostics
- generated C and headers under the app build directory
- runtime source selection for native, web, Windows, Click, and Android
- Raylib, curl, liboqs, and other shared vendor build rules
- embedded asset generation
- Linux desktop files, icons, metainfo, AppImage, deb, rpm, Flatpak, Snap, and
Click packaging helpers
- Android CMake, Gradle property generation, APK/AAB assembly hooks, and asset
copy helpers
- web/WASM HTML, JS, data-file generation, cache busting, and smoke-test hooks
- Podman-backed Linux packaging where host tools are missing or platform
isolation is needed
Apps own:
- product code and app-specific C modules
- `.kry` pages, widgets, and screens
- translations and media assets
- app metadata values in `project.kryon`
- optional platform-specific shims that cannot be generalized cleanly
## Migration Phases
1. Rename old build variables and paths from Flint to Kryon in every app.
`vendor/kryon` is the only runtime submodule path.
2. Keep app Makefiles working, but make them use `KRYON_DIR` and Kryon-owned
`mk/*.mk` includes exclusively.
3. Move repeated Makefile logic from Inbe into Kryon `mk/app.mk`,
`mk/android.mk`, `mk/web.mk`, and `mk/package-linux.mk`.
4. Add a Kryon CLI wrapper that reads `project.kryon` and invokes the shared
make fragments with normalized variables.
5. Convert app Makefiles to compatibility shims, then remove duplicated app-side
package/build rules.
6. Make the IDE use the same build graph for preview/run so errors from manual
build, auto preview, and package targets use one diagnostic format.
7. Add template checks so new Kryon apps start with the unified layout.
## Vendor Rule
Vendored Kryon directories are pinned dependencies. App builds must not modify
files under `vendor/kryon`. Regenerated Kryon runtime assets, generated icon
tables, and shared packaging helpers must be changed in the root Kryon
repository, committed there, and consumed by updating the app submodule pointer.
+116
View File
@@ -0,0 +1,116 @@
# Kry Language
Kry is C-close app code for Kryon. `kc` emits readable `.c` and `.h` files
that are compiled by the normal C toolchain; there is no VM, runtime package
system, or hidden ownership model.
## Style
- Small files, clear names, and plain data flow.
- Explicit module prefixes for generated C symbols.
- Direct C-compatible pointers, field access, labels, and cleanup `goto`.
- Compile-time modules only.
- Raw C escape hatches only for platform or third-party edges.
## Declarations
```kry
#module "practice.session"
#output "session_impl"
#import "app.h"
#import <stddef.h>
#import "private_dep.h" #private
#pragma "GCC diagnostic push"
SessionTimer :: struct {
elapsed: float
running: bool
}
SessionMode :: enum {
SESSION_IDLE,
SESSION_ACTIVE,
}
#enum {
SESSION_FLAG_DIRTY = 1,
}
#enum #private {
SESSION_LOCAL_FLAG = 1,
}
TickCallback :: int (*)(float) #type
LocalSize :: unsigned long #type #private
session_count :: int #global #export
local_counter :: int = 7 #global
platform_ping :: (value: int, tag: const char*) -> int #extern
platform_log :: (level: int, text: const char*, ...) -> void #extern
win_entry :: (hwnd: void*) -> int #extern #storage "__declspec(dllimport)" #abi "__stdcall"
weak_hook :: () -> void #extern #attr "__attribute__((weak))"
session_update :: (app: InbeApp*, dt: float) -> int {
if !app->session.running {
return 0
}
result := breath_step(&app->breath, dt)
if result.done {
goto done
}
done:
return 1
}
session_entry :: (app: InbeApp*) #export {
session_update(app, 0.0f)
}
```
## Rules
- `#module "name"` sets the compile-time module name and generated C symbol
prefix. Dots become underscores.
- `#output "basename"` changes only the generated file basename.
- `#import "path.h"` emits a public include in the generated header.
- `#import <system.h>` and `#import "path.h" #private` emit source-only
includes.
- `alias :: #import "module/path"` imports another Kry module and binds a
compile-time alias for qualified calls.
- `name :: (...) -> Ret { ... }` defines a function. Inside a module, the
generated C symbol is module-prefixed by default.
- `#export` keeps the exact C ABI name and emits the declaration publicly.
- `#private` keeps a function or type alias source-local.
- `#global` creates a file-level variable; add `#export` for a public `extern`.
- `#extern` declares an external C function without defining it.
- External declarations accept precise interop tags when the platform ABI needs
them: `#storage "..."` before the return type, `#abi "..."` before the
function name, and `#attr "..."` after the parameter list.
- `...` is allowed as the final parameter of an external declaration.
- `#intrinsic "web"` emits a Kryon-owned platform wrapper for supported web
operations.
- `#pragma "text"` and `#error "message"` emit guarded C preprocessor
directives for compiler and platform integration.
Kry statements are deliberately minimal — declarations, assignments, calls,
and control flow. There are no widget keywords and no bespoke sugar verbs:
- `name := expr` for inferred locals.
- `name: Type = expr` or `name: Type` for typed locals.
- `name = expr` assignments (including compound `+=`, `%=`, `&=`, ...).
- plain function calls (any call used as a statement is a draw call and is
automatically wrapped with source-inspection metadata for click-to-source).
- `if`, `else if`, `else`, `while`, `for`, `switch`, `case`, `default`,
labels, `goto`, `break`, `continue`, `guard`, and `return`.
- `c line` for raw C glue and `unused expr` to silence unused-value warnings.
Widgets are ordinary library functions (WidgetText, WidgetRect, WidgetLine,
WidgetBackground, WidgetButton) declared in `ui_widgets.h`; the compiler
treats them exactly like any other call. Input handling is plain control
flow: `if (UIKeyPressed(KEY_A)) { ... }`, `if (UIKeyDown(KEY_A)) { ... }`.
Event-style blocks (`button ... {`, `on key ... {`, `event ... {`) and
arithmetic/declaration sugar (`advance x by N`, `clamp_min`, `c_rect`,
`texture`, `set_theme`) were removed in favor of their direct equivalents.
+38
View File
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kryon API Reference</title>
<meta name="description" content="Kryon runtime and UI API reference rendered from the canonical markdown documentation.">
<meta name="theme-color" content="#f3f1ea">
<link rel="icon" type="image/png" sizes="16x16" href="icons/kryon.png">
<link rel="apple-touch-icon" href="icons/kryon.png">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="content">
<header class="hero compact">
<img class="hero-icon" src="icons/kryon.png" width="96" height="96" alt="Kryon">
<h1>API</h1>
<p class="tagline">Runtime and widget reference</p>
</header>
<nav class="site-nav" aria-label="Primary">
<a href="index.html">Home</a>
<a href="index.html#features">Features</a>
<a href="index.html#start">Start</a>
<a href="api.html">API</a>
</nav>
<main class="api-reference">
{{ API_BODY }}
</main>
<footer>
<p>&copy; 2026 Kryon Labs | <a href="https://waozi.xyz" target="_blank" rel="noopener">Made by Waozi</a></p>
</footer>
</div>
<script src="highlight.js"></script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

-61
View File
@@ -1,61 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flint Examples</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="topbar">
<div class="wrap nav">
<strong><a href="index.html">Flint</a></strong>
<nav>
<a href="index.html#start">Start</a>
<a href="index.html#frame">Frame</a>
<a href="examples.html">Examples</a>
</nav>
</div>
</header>
<main class="wrap section">
<h1 class="page-title">Live Examples</h1>
<p class="lede">
These examples are built from the C sources with Emscripten and published
with the docs site. Open one to test the same controls in the browser.
</p>
<div class="example-grid">
<a class="example-card" href="examples/01_file_dialog/index.html">
<span>01</span>
<strong>File Dialog</strong>
</a>
<a class="example-card" href="examples/02_buttons/index.html">
<span>02</span>
<strong>Buttons</strong>
</a>
<a class="example-card" href="examples/03_theme/index.html">
<span>03</span>
<strong>Theme</strong>
</a>
<a class="example-card" href="examples/04_modal/index.html">
<span>04</span>
<strong>Modal</strong>
</a>
<a class="example-card" href="examples/05_color/index.html">
<span>05</span>
<strong>Color</strong>
</a>
<a class="example-card" href="examples/06_scaling/index.html">
<span>06</span>
<strong>Scaling</strong>
</a>
<a class="example-card" href="examples/07_layout/index.html">
<span>07</span>
<strong>Layout</strong>
</a>
</div>
</main>
<script src="highlight.js"></script>
</body>
</html>
+10 -8
View File
@@ -1,5 +1,5 @@
(function() {
var keywords = /\b(return|if|else|while|for|int|float|void|const|static|typedef|struct|enum|include|define)\b/g;
var keywords = /\b(return|if|else|while|for|int|float|void|const|static|typedef|struct|enum|include|define|draw|native)\b|#\b(module|output|import|enum|global|export|private|extern|intrinsic|type)\b/g;
var types = /\b(Color|Rectangle|Texture2D|Camera2D|UIPanelFrame|UITextField|UILabelTextField|Font)\b/g;
var functions = /\b([A-Za-z_][A-Za-z0-9_]*)\s*(?=\()/g;
var strings = /("([^"\\]|\\.)*"|'([^'\\]|\\.)*')/g;
@@ -20,16 +20,18 @@
function highlight(text) {
var placeholders = [];
function keep(html) {
var id = placeholders.length;
placeholders.push(html);
return "\u0000P" + id + "X\u0000";
}
text = escapeHtml(text);
text = text.replace(comments, function(match) {
var id = placeholders.length;
placeholders.push(span("tok-com", match));
return "\u0000" + id + "\u0000";
return keep(span("tok-com", match));
});
text = text.replace(strings, function(match) {
var id = placeholders.length;
placeholders.push(span("tok-str", match));
return "\u0000" + id + "\u0000";
return keep(span("tok-str", match));
});
text = text
.replace(types, function(match) { return span("tok-type", match); })
@@ -39,7 +41,7 @@
return span("tok-fn", name);
});
return text.replace(/\u0000(\d+)\u0000/g, function(_, id) {
return text.replace(/\u0000P(\d+)X\u0000/g, function(_, id) {
return placeholders[Number(id)];
});
}
+160 -187
View File
@@ -3,205 +3,178 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flint</title>
<title>Kryon - Native Cross-Platform App and Game Development</title>
<meta name="description" content="Native cross-platform app and game development with .kry, human-readable C99 output, a full native widget toolkit, and an interactive AI-native IDE.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://kryonlabs.com/">
<meta property="og:title" content="Kryon - Native Cross-Platform App and Game Development">
<meta property="og:description" content="Native cross-platform app and game development with .kry, human-readable C99 output, a full native widget toolkit, and an interactive AI-native IDE.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:url" content="https://kryonlabs.com/">
<meta name="twitter:title" content="Kryon - Native Cross-Platform App and Game Development">
<meta name="twitter:description" content="Native cross-platform app and game development in .kry with readable C99 output.">
<meta name="twitter:site" content="@kryonlabs">
<meta name="twitter:creator" content="@kryonlabs">
<meta name="theme-color" content="#f3f1ea">
<link rel="icon" type="image/png" sizes="16x16" href="icons/kryon.png">
<link rel="apple-touch-icon" href="icons/kryon.png">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="topbar">
<div class="wrap nav">
<strong>Flint</strong>
<nav>
<a href="#start">Start</a>
<a href="#frame">Frame</a>
<a href="#modals">Modals</a>
<a href="#controls">Controls</a>
<a href="#app">App Support</a>
<a href="#fonts">Fonts</a>
<a href="examples.html">Examples</a>
</nav>
</div>
</header>
<div class="content">
<header class="hero">
<img class="hero-icon" src="icons/kryon.png" width="128" height="128" alt="Kryon">
<h1>KRYON</h1>
<p class="tagline">Native cross-platform app and game development</p>
<p class="tagline-detail">Write .kry &bull; Translate to readable C99 &bull; Build visually with an AI-native IDE</p>
</header>
<main>
<section class="hero">
<div class="wrap hero-grid">
<div>
<p class="eyebrow">C support library for raylib-style apps</p>
<h1>Small native UI with shared app plumbing.</h1>
<p class="lede">
Flint keeps a raylib-compatible public surface available through
<code>flint.h</code>, then adds UI controls, layout helpers, text
rendering, themes, embedded assets, locale loading, file dialogs,
runtime asset downloads, and Lyra account/sync helpers.
</p>
<nav class="site-nav" aria-label="Primary">
<a href="#about">About</a>
<a href="#goals">Goals</a>
<a href="#features">Features</a>
<a href="#philosophy">Philosophy</a>
<a href="#platforms">Platforms</a>
<a href="#start">Start</a>
<a href="api.html">API</a>
</nav>
<main>
<section id="about">
<h2>What is Kryon?</h2>
<p>Kryon is a native app and game development stack built around .kry source files, a small runtime, and clean translation to human-readable C99.</p>
<p>The Kryon IDE is built around the same source model: open a project or file path, edit .kry directly, see a live preview, and click a widget to jump back to the source line that generated it.</p>
</section>
<section id="goals">
<h2>Goals</h2>
<div class="goal-list">
<article class="goal">
<h3>Native Cross-Platform</h3>
<p>One source model for desktop, mobile, browser, and embedded targets, with platform behavior exposed as first-class Kryon features.</p>
</article>
<article class="goal">
<h3>Readable C99</h3>
<p>.kry translates to plain, inspectable C99 that can be built, debugged, and shipped by normal C toolchains.</p>
</article>
<article class="goal">
<h3>Full Native UI</h3>
<p>The widget toolkit should cover real product interfaces: layout, text, inputs, navigation, overlays, inspection, themes, and runtime assets.</p>
</article>
<article class="goal">
<h3>AI-Native IDE</h3>
<p>The IDE should make visual app and game development direct: live preview, source-aware inspection, diagnostics, and agent-assisted edits in one loop.</p>
</article>
</div>
<pre><code>BeginUIFrame(
GetScreenWidth(),
GetScreenHeight(),
GetUIScale());
</section>
SetUIColors(text, bg, surface,
circle, button,
hover, icon);</code></pre>
</div>
<div class="wrap dependency-strip" aria-label="Shared app support">
<span>UI Core</span>
<span>Lyra Accounts</span>
<span>liboqs</span>
<span>curl + LibreSSL</span>
</div>
</section>
<section id="features">
<h2>Core Features</h2>
<div class="grid">
<article class="feature">
<img src="icons/text.png" width="48" height="48" alt="">
<h3>Widget-Focused .kry</h3>
<p>Pages and reusable widgets stay in concise source files with explicit typed variables and direct compiler errors for unknown syntax.</p>
</article>
<article class="feature">
<img src="icons/c.png" width="48" height="48" alt="">
<h3>Clean C Output</h3>
<p>The compiler emits normal C and generated headers. Kry-to-Kry calls use compile-time modules, while C interop stays explicit.</p>
</article>
<article class="feature">
<img src="icons/globe.png" width="48" height="48" alt="">
<h3>Live Preview</h3>
<p>Hot reload rebuilds real .kry output, keeps the last good state during compilation, and shows diagnostics when the build fails.</p>
</article>
<article class="feature">
<img src="icons/wrench.png" width="48" height="48" alt="">
<h3>Source-Aware Inspection</h3>
<p>Preview widgets carry source metadata, so inspection clicks select the generated UI element and open the exact .kry line.</p>
</article>
</div>
</section>
<section id="philosophy">
<h2>Philosophy</h2>
<ul class="philosophy-list">
<li><strong>Everything visible is a widget</strong> - source, bounds, state, and inspection all belong to the widget tree.</li>
<li><strong>Source stays primary</strong> - .kry files own screens and reusable UI pieces; C is the generated interop target.</li>
<li><strong>The IDE is source-aware</strong> - file browser, source editor, live preview, inspector, diagnostics, and search stay tied to .kry files.</li>
<li><strong>Default private API</strong> - only exported functions enter generated headers, keeping build boundaries small.</li>
<li><strong>Native first</strong> - direct C, raylib-style calls, and predictable runtime behavior across targets.</li>
</ul>
</section>
<section id="start" class="wrap section">
<h2>Start</h2>
<div class="cards">
<article>
<h3>Build Flint</h3>
<pre><code>make</code></pre>
<p>Include <code>flint.h</code> or specific headers from <code>include/</code>.</p>
</article>
<article>
<h3>Link</h3>
<pre><code>-Lvendor/flint -lflint -lraylib -lGL -lm -lpthread -ldl -lrt -lX11</code></pre>
<p>Use your platform's raylib/OpenGL flags as needed.</p>
</article>
</div>
</section>
<section id="platforms">
<h2>Platforms</h2>
<p>Kryon targets the same interface source at the environments apps actually ship to.</p>
<div class="platform-grid">
<article class="platform">
<img src="platforms/tux.png" width="32" height="32" alt="">
<h3>Linux</h3>
<p>Native desktop builds.</p>
</article>
<article class="platform">
<img src="platforms/win.png" width="32" height="32" alt="">
<h3>Windows</h3>
<p>Native desktop and WinINet assets.</p>
</article>
<article class="platform">
<img src="platforms/macos.png" width="32" height="32" alt="">
<h3>macOS</h3>
<p>Native desktop builds.</p>
</article>
<article class="platform">
<img src="platforms/droid.png" width="32" height="32" alt="">
<h3>Android</h3>
<p>Mobile runtime support.</p>
</article>
<article class="platform">
<img src="language/wasm.png" width="32" height="32" alt="">
<h3>Browser</h3>
<p>WebAssembly runtime and previews.</p>
</article>
<article class="platform">
<img src="platforms/freebsd.png" width="32" height="32" alt="">
<h3>FreeBSD</h3>
<p>Native desktop and embedded targets.</p>
</article>
</div>
</section>
<section class="wrap section">
<h2>Try The Examples</h2>
<p>
The GitHub Pages workflow builds the C examples with Emscripten and
publishes them alongside this static site.
</p>
<p><a class="button-link" href="examples.html">Open live examples</a></p>
</section>
<section id="start">
<h2>Get Started</h2>
<p>Build the runtime and tools:</p>
<pre><code>git clone https://github.com/kryonlabs/kryon.git
cd kryon
make
make install</code></pre>
<p>A simple .kry shape:</p>
<pre><code>#import "kryon.h"
<section id="frame" class="wrap section">
<h2>Frame Lifecycle</h2>
<p>
For normal screen-space UI, call <code>BeginUIFrame</code> once
per frame. It updates the layout viewport, UI viewport, DPI scale, and
frame state with a safe default camera.
</p>
<pre><code>BeginDrawing();
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(),
GetThemeSurface(), GetThemeCircle(),
GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());</code></pre>
<p>
If you need a transformed UI camera, call <code>InitUI</code> and
<code>SetUIFrame(camera)</code>. Flint normalizes invalid cameras, so a
zeroed camera no longer breaks pointer input.
</p>
</section>
AppHome :: (app: InbeApp*) {
y: int = ScaleUIPx(24)
<section id="modals" class="wrap section">
<h2>Modals</h2>
<p>
Use <code>DrawUIActionModal</code> for title, message, and action-button
dialogs. It measures labels, fits button text, wraps long action rows,
and registers modal input capture so background controls cannot receive
clicks.
</p>
<pre><code>UIModalAction actions[2] = {
{ "Keep running", UI_BUTTON_STYLE_PRIMARY, 0 },
{ "Quit", UI_BUTTON_STYLE_DANGER, 0 }
};
WidgetText("Inner Breeze", ScaleUIPx(20), y, UI_TEXT_24, GetThemeText())
app_draw_bottom_nav(app)
}</code></pre>
<p>Open a project or a single .kry file in the IDE:</p>
<pre><code>kryon .
kryon path/to/app.kry</code></pre>
</section>
int result = DrawUIActionModal((UIModalSpec){
.title = "Close app?",
.message = "Choose what the app should do next.",
.actions = actions,
.action_count = 2,
.close_icon = close_icon
});</code></pre>
<p>
Use <code>DrawUIModalFrame</code> when a dialog needs custom controls
such as text fields, sliders, or scrollable content.
</p>
</section>
<section id="docs">
<h2>Documentation</h2>
<ul class="link-list">
<li><a href="api.html">API reference</a> - runtime and widget surface</li>
<li><a href="https://github.com/kryonlabs/kryon" target="_blank" rel="noopener">Source repository</a> - code, issues, and releases</li>
</ul>
</section>
</main>
<section id="controls" class="wrap section">
<h2>Controls</h2>
<div class="cards">
<article>
<h3>Text Input</h3>
<code>DrawUITextField</code>
<code>DrawUILabelTextField</code>
</article>
<article>
<h3>Choices</h3>
<code>DrawUICheckboxToggle</code>
<code>DrawUIToggleSwitch</code>
<code>DrawUIDropdownButton</code>
</article>
<article>
<h3>Actions</h3>
<code>DrawUIButton</code>
<code>DrawUIGenericButton</code>
<code>DrawUIIconButton</code>
</article>
</div>
</section>
<section id="app" class="wrap section app-section">
<div>
<h2>App Support</h2>
<p>
Flint is the source owner for shared application plumbing. Apps keep
their build outputs local, while common dependency source and build
recipes live under Flint so account management and network builds stay
consistent.
</p>
</div>
<div class="cards">
<article>
<h3>Lyra Account</h3>
<p>
<code>LyraAccount</code> creates, imports, exports, signs,
and verifies generic account keys without app-specific key names.
</p>
</article>
<article>
<h3>liboqs</h3>
<p>
<code>vendor/liboqs</code> is the shared source for post-quantum
signing support. Downstream builds can enable it with
<code>HAS_LIBOQS</code>.
</p>
</article>
<article>
<h3>curl + LibreSSL</h3>
<p>
<code>vendor/curl</code> is the shared source for app networking.
TLS builds use curl's OpenSSL-compatible options through the
<code>OPENSSL_*</code> make variables.
</p>
</article>
</div>
</section>
<section id="fonts" class="wrap section">
<h2>Fonts</h2>
<p>
Flint ships <code>tools/otfchop</code> for generating bitmap font
atlases and metadata. Load generated assets with
<code>LoadUIChoppedFont</code>, then install the font with
<code>SetUIFont</code> and <code>SetUISmallFont</code>.
</p>
<pre><code>Font font = LoadUIChoppedFont(
"assets/fonts/locales.png",
"assets/fonts/locales.dat",
UI_TEXT_BASE_SIZE);
SetUIFont(font);</code></pre>
</section>
</main>
<footer class="wrap footer">
<p>Flint is documented in <code>docs/API.md</code>. This page is static and ready for Netlify.</p>
</footer>
<footer>
<p>&copy; 2026 Kryon Labs | <a href="https://waozi.xyz" target="_blank" rel="noopener">Made by Waozi</a></p>
</footer>
</div>
<script src="highlight.js"></script>
</body>
</html>
+439 -215
View File
@@ -1,297 +1,521 @@
/* Kryon site theme — refined modern-retro */
:root {
color-scheme: light;
--bg: #f7f7f4;
--ink: #171717;
--muted: #5c625f;
--line: #d9ddd6;
--panel: #ffffff;
--accent: #176b5b;
--accent-2: #7a4d13;
--accent-3: #334b8f;
--code: #10201d;
/* surfaces */
--bg: #f3f1ea; /* warm off-white page */
--surface: #fdfcf8; /* panel */
--control: #eae6da; /* button base */
--control-hi: #ffffff; /* bevel highlight */
/* ink */
--ink-strong: #2a3b40; /* near-slate headings/body */
--ink-soft: #5d6f74; /* muted secondary text */
/* lines */
--line: rgba(42, 59, 64, 0.20);
--line-strong: rgba(42, 59, 64, 0.30);
/* accent */
--accent: #2f6f86; /* teal links/headings pop */
--accent-deep: #1f5366; /* teal hover */
/* cards */
--card-bg: #f7f4ec;
--card-hover-bg: #fbf9f2;
--card-active-bg: #efeadd;
/* aliases (kept for compatibility with api.html) */
--page-bg: var(--bg);
--panel-bg: var(--surface);
--ink: var(--ink-strong);
--muted: var(--ink-soft);
--dark: var(--line);
--shadow: var(--line-strong);
--light: #ffffff;
--panel-shadow: rgba(0, 0, 0, 0.10);
--button-bg: var(--control);
--button-highlight: var(--control-hi);
--button-inset: var(--control-hi);
--link: var(--accent);
--link-hover: var(--accent-deep);
--font-main: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
--radius: 10px;
--radius-sm: 6px;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
background: var(--bg);
padding: 0;
}
body {
min-height: 100vh;
width: 100%;
position: relative;
background-color: var(--page-bg);
color: var(--ink);
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
line-height: 1.55;
font-family: var(--font-main);
font-size: 15px;
line-height: 1.6;
cursor: url("cursors/arrow.png") 0 0, default;
-webkit-font-smoothing: antialiased;
}
/* pixel dither texture — fine, low-opacity paper grain */
body::before {
content: "";
position: fixed;
inset: 0;
z-index: 0;
background-image:
linear-gradient(45deg, rgba(42, 59, 64, 0.10) 25%, transparent 25%),
linear-gradient(-45deg, rgba(42, 59, 64, 0.10) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, rgba(42, 59, 64, 0.10) 75%),
linear-gradient(-45deg, transparent 75%, rgba(42, 59, 64, 0.10) 75%);
background-position: 0 0, 0 16px, 16px -16px, -16px 0;
background-size: 32px 32px;
image-rendering: pixelated;
opacity: 0.55;
pointer-events: none;
}
.content {
position: relative;
z-index: 1;
max-width: 900px;
margin: 32px auto;
padding: 40px 44px;
background-color: var(--panel-bg);
border: 1px solid var(--dark);
border-radius: var(--radius);
box-shadow:
inset 1px 1px 0 0 var(--button-highlight),
0 18px 48px var(--panel-shadow);
}
a {
color: inherit;
color: var(--link);
text-decoration: none;
font-weight: 700;
cursor: url("cursors/hand.png") 6 1, pointer;
transition: color 0.12s ease;
}
a:hover {
color: var(--link-hover);
}
a:active {
position: relative;
top: 1px;
left: 1px;
}
img {
display: block;
max-width: 100%;
height: auto;
image-rendering: pixelated;
}
code,
pre {
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
pre {
margin: 0;
overflow: auto;
border: 1px solid var(--line);
background: var(--code);
color: #edf7f2;
padding: 16px;
border-radius: 8px;
font-family: var(--font-main);
}
code {
background: rgba(23, 107, 91, 0.1);
padding: 2px 5px;
background-color: rgba(47, 111, 134, 0.10);
padding: 2px 6px;
border-radius: 4px;
font-size: 0.92em;
}
pre {
margin: 16px 0;
overflow-x: auto;
background-color: var(--card-bg);
color: var(--ink-strong);
padding: 16px 18px;
border: 1px solid var(--dark);
border-radius: var(--radius-sm);
box-shadow:
inset 1px 1px 2px rgba(0, 0, 0, 0.06),
0 1px 0 0 var(--button-highlight);
cursor: url("cursors/ibeam.png") 15 16, text;
}
pre code {
background: transparent;
padding: 0;
border-radius: 0;
font-size: 13.5px;
}
.tok-key {
color: #8bd0ff;
}
.tok-type {
color: #a7e0a3;
}
.tok-fn {
color: #f2d17b;
}
.tok-str {
color: #f0a97f;
}
.tok-num {
color: #c7b7ff;
}
.tok-com {
color: #7f958f;
}
.wrap {
width: min(1100px, calc(100% - 32px));
margin: 0 auto;
}
.topbar {
position: sticky;
top: 0;
z-index: 10;
background: rgba(247, 247, 244, 0.92);
border-bottom: 1px solid var(--line);
backdrop-filter: blur(10px);
}
.nav {
min-height: 56px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
}
.nav nav {
display: flex;
gap: 18px;
color: var(--muted);
font-size: 14px;
}
/* ---- hero ---- */
.hero {
border-bottom: 1px solid var(--line);
background:
linear-gradient(135deg, rgba(23, 107, 91, 0.08), rgba(122, 77, 19, 0.08)),
#f2f4ef;
}
.hero-grid {
min-height: 390px;
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
gap: 40px;
align-items: center;
padding: 56px 0;
}
.dependency-strip {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
padding: 0 0 28px;
}
.dependency-strip span {
display: grid;
min-height: 48px;
align-items: center;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.72);
color: var(--ink);
font-size: 14px;
font-weight: 700;
text-align: center;
padding: 8px 0 24px;
margin-bottom: 32px;
}
.eyebrow {
margin: 0 0 10px;
color: var(--accent);
font-weight: 700;
text-transform: uppercase;
font-size: 13px;
letter-spacing: 0;
.hero.compact {
padding: 0 0 16px;
margin-bottom: 24px;
}
.hero-icon {
margin: 0 auto 18px;
}
h1 {
margin: 0;
font-size: 46px;
line-height: 1.05;
letter-spacing: 0;
max-width: 760px;
margin: 12px 0;
color: var(--ink-strong);
font-size: 30px;
line-height: 1.18;
letter-spacing: -0.01em;
}
.tagline {
margin: 8px 0;
color: var(--accent);
font-size: 17px;
font-weight: 700;
}
.tagline-detail {
margin: 8px auto 0;
max-width: 64ch;
color: var(--muted);
font-size: 13.5px;
font-weight: 400;
}
/* ---- nav ---- */
.site-nav {
display: flex;
flex-wrap: wrap;
gap: 8px 22px;
justify-content: center;
padding: 14px 0;
margin-bottom: 36px;
border-top: 1px solid var(--dark);
border-bottom: 1px solid var(--dark);
}
.site-nav a {
font-size: 13px;
font-weight: 700;
color: var(--ink-soft);
}
.site-nav a:hover {
color: var(--accent);
}
/* ---- sections ---- */
section {
margin-bottom: 52px;
}
section:last-of-type {
margin-bottom: 40px;
}
h2 {
margin: 0 0 16px;
font-size: 28px;
letter-spacing: 0;
padding-bottom: 10px;
color: var(--ink-strong);
border-bottom: 1px solid var(--dark);
font-size: 19px;
letter-spacing: -0.01em;
line-height: 1.18;
}
h3 {
margin: 0 0 10px;
font-size: 18px;
margin: 6px 0;
color: var(--accent);
font-size: 14.5px;
}
.lede {
max-width: 700px;
color: var(--muted);
font-size: 18px;
p {
max-width: 72ch;
margin: 0 0 14px;
}
.section {
padding: 42px 0;
p:last-child {
margin-bottom: 0;
}
.section > p {
max-width: 760px;
section > p {
color: var(--muted);
}
.page-title {
font-size: 40px;
margin-bottom: 12px;
/* ---- goals ---- */
.goal-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
margin-top: 20px;
}
.button-link {
display: inline-flex;
.goal {
padding: 20px 22px;
background-color: var(--card-bg);
border: 1px solid var(--dark);
border-radius: var(--radius);
box-shadow:
0 1px 0 var(--button-highlight),
inset 1px 1px 0 var(--button-inset),
0 2px 10px rgba(0, 0, 0, 0.04);
cursor: url("cursors/hand.png") 6 1, pointer;
transition: background-color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}
.goal:hover {
background-color: var(--card-hover-bg);
box-shadow:
0 1px 0 var(--button-highlight),
inset 1px 1px 0 var(--button-inset),
0 8px 22px rgba(0, 0, 0, 0.07);
}
.goal h3 {
margin-top: 0;
margin-bottom: 8px;
}
.goal p {
margin-bottom: 0;
color: var(--muted);
}
/* ---- features / platforms ---- */
.grid,
.platform-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
margin-top: 20px;
}
.feature,
.platform {
display: flex;
flex-direction: column;
align-items: center;
min-height: 40px;
padding: 0 14px;
background: var(--accent);
color: white;
border-radius: 6px;
justify-content: flex-start;
text-align: center;
padding: 18px 14px;
background-color: var(--card-bg);
border: 1px solid var(--dark);
border-radius: var(--radius);
box-shadow:
0 1px 0 var(--button-highlight),
inset 1px 1px 0 var(--button-inset),
0 2px 10px rgba(0, 0, 0, 0.04);
color: inherit;
text-decoration: none;
box-sizing: border-box;
cursor: url("cursors/hand.png") 6 1, pointer;
transition: background-color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}
.feature:hover,
.platform:hover {
background-color: var(--card-hover-bg);
transform: translateY(-1px);
box-shadow:
0 1px 0 var(--button-highlight),
inset 1px 1px 0 var(--button-inset),
0 8px 22px rgba(0, 0, 0, 0.07);
}
.feature:active,
.platform:active {
background-color: var(--card-active-bg);
transform: translate(1px, 1px);
box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.12);
}
.feature img {
margin-bottom: 14px;
}
.feature p {
margin: 0;
font-size: 12.5px;
line-height: 1.5;
color: var(--muted);
}
.platform {
padding: 16px 12px;
}
.platform img {
margin-bottom: 8px;
}
.platform h3 {
margin: 6px 0 4px;
font-size: 14px;
}
.platform p {
margin: 0;
font-size: 12px;
}
/* ---- philosophy / link lists ---- */
.philosophy-list,
.link-list {
list-style: none;
margin: 20px 0;
padding: 0;
}
.philosophy-list li,
.link-list li {
margin-bottom: 10px;
padding: 12px 16px;
background-color: rgba(47, 111, 134, 0.06);
border-left: 3px solid var(--accent);
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
color: var(--muted);
}
.philosophy-list strong,
.link-list strong {
color: var(--ink-strong);
}
.link-list a {
font-weight: 700;
}
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 16px;
/* ---- misc layout helpers ---- */
.row {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
}
.app-section {
display: grid;
grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
gap: 24px;
align-items: start;
}
/* ---- api reference ---- */
.app-section > div > p {
color: var(--muted);
}
.example-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
gap: 14px;
.api-reference h1,
.api-reference h2,
.api-reference h3,
.api-reference h4 {
margin-top: 28px;
}
.example-card {
min-height: 112px;
display: grid;
align-content: space-between;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
padding: 18px;
.api-reference h1 {
margin-top: 0;
font-size: 22px;
}
.example-card span {
.api-reference h2 {
font-size: 18px;
}
.api-reference h3 {
color: var(--accent);
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
font-size: 15px;
}
.api-reference p,
.api-reference li {
max-width: 82ch;
}
/* ---- footer ---- */
footer {
margin-top: 48px;
padding-top: 22px;
border-top: 1px solid var(--dark);
text-align: center;
font-size: 13px;
font-weight: 700;
}
.example-card strong {
font-size: 20px;
}
article {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
padding: 18px;
}
article code {
display: inline-block;
margin: 4px 4px 0 0;
}
.footer {
padding: 32px 0 48px;
color: var(--muted);
border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
.nav {
align-items: flex-start;
flex-direction: column;
padding: 14px 0;
footer p {
margin: 8px auto;
max-width: none;
}
/* ---- syntax tokens ---- */
.tok-key {
color: var(--accent-deep);
}
.tok-type {
color: #4a6b73;
}
.tok-fn {
color: #8a4a55;
}
.tok-str {
color: #8a5a1f;
}
.tok-num {
color: #5a5577;
}
.tok-com {
color: #8a9498;
font-style: italic;
}
/* ---- responsive ---- */
@media (max-width: 768px) {
body {
font-size: 14px;
}
.nav nav {
flex-wrap: wrap;
.content {
margin: 12px;
padding: 24px 20px;
}
.hero-grid {
grid-template-columns: 1fr;
min-height: 0;
padding: 42px 0;
}
.dependency-strip {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.app-section {
grid-template-columns: 1fr;
.hero {
padding: 4px 0 18px;
margin-bottom: 24px;
}
h1 {
font-size: 34px;
font-size: 25px;
}
.tagline {
font-size: 15px;
}
.site-nav {
gap: 8px 18px;
margin-bottom: 28px;
}
section {
margin-bottom: 36px;
}
}
-125
View File
@@ -1,125 +0,0 @@
#include "example_ui_font.h"
#include "file_dialog.h"
#include "theme.h"
#include "theme_meta.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Flint File Dialog Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
SetFileDialogThemeScope(GetThemeScopeName(THEME_SKY, false));
FileDialog dlg;
InitFileDialog(&dlg);
printf("Flint File Dialog Example\n");
printf("Click the buttons to test load, save, and folder dialogs\n\n");
char last_path[512] = {0};
char status[256] = "Choose an action.";
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(), GetThemeSurface(),
GetThemeCircle(), GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());
int x = ScaleUIPx(32);
int y = ScaleUIPx(28);
int button_w = ScaleUIPx(180);
int button_h = ScaleUIPx(42);
int gap = ScaleUIPx(12);
int hover = 0;
char backend_text[160];
snprintf(backend_text, sizeof(backend_text), "Backend: %s", GetFileDialogBackendName());
DrawUIText("Flint File Dialog", x, y, 24, GetThemeText());
y += ScaleUIPx(38);
DrawUIText(backend_text, x, y, 15, GetThemeText());
y += ScaleUIPx(40);
if(DrawUIGenericButton(x, y, button_w, button_h, "Open File",
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
printf("Opening load dialog...\n");
if(LoadFileDialog(&dlg, "Load File")) {
const char *path = GetFileDialogPath(&dlg);
if(path) {
printf("Selected file: %s\n", path);
snprintf(last_path, sizeof(last_path), "%s", path);
snprintf(status, sizeof(status), "Selected file.");
}
} else {
snprintf(status, sizeof(status), "Open file cancelled or unavailable.");
printf("%s\n", status);
}
}
hover = 0;
if(DrawUIGenericButton(x + button_w + gap, y, button_w, button_h, "Save File",
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
printf("Opening save dialog...\n");
if(SaveFileDialog(&dlg, "Save File", "example.txt")) {
const char *path = GetFileDialogPath(&dlg);
if(path) {
printf("Save to: %s\n", path);
snprintf(last_path, sizeof(last_path), "%s", path);
snprintf(status, sizeof(status), "Selected save path.");
}
} else {
snprintf(status, sizeof(status), "Save file cancelled or unavailable.");
printf("%s\n", status);
}
}
hover = 0;
if(DrawUIGenericButton(x + (button_w + gap) * 2, y, button_w, button_h,
"Select Folder", UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
printf("Opening folder dialog...\n");
if(SelectFileDialogFolder(&dlg, "Select Folder")) {
const char *path = GetFileDialogPath(&dlg);
if(path) {
printf("Selected folder: %s\n", path);
snprintf(last_path, sizeof(last_path), "%s", path);
snprintf(status, sizeof(status), "Selected folder.");
}
} else {
snprintf(status, sizeof(status), "Folder dialog cancelled or unavailable.");
printf("%s\n", status);
}
}
y += button_h + ScaleUIPx(36);
DrawUIText("Status", x, y, 18, GetThemeText());
y += ScaleUIPx(28);
DrawUIText(status, x, y, 16, GetThemeText());
if(last_path[0] != '\0') {
y += ScaleUIPx(34);
DrawUIText("Last selected path", x, y, 18, GetThemeText());
y += ScaleUIPx(28);
DrawUIText(last_path, x, y, 14, GetThemeText());
}
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
CloseFileDialog(&dlg);
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+50
View File
@@ -0,0 +1,50 @@
#import "kryon.h"
#import "file_dialog.h"
#import "stdio.h"
app "Kryon File Dialog Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
dlg: FileDialog = {0}
status: [256] char = "Choose an action."
last_path: [512] char = ""
dlg_ready: int = 0
}
screen FileDialogExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
if dlg_ready == 0 {
InitFileDialog(&dlg)
dlg_ready = 1
}
WidgetText("Kryon File Dialog", ScaleUIPx(32), ScaleUIPx(28), UI_TEXT_24, GetThemeText())
WidgetText("Dialog backend and result state", ScaleUIPx(32), ScaleUIPx(66), UI_TEXT_16, GetThemeIcon())
if WidgetButton(ScaleUIPx(32), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42), "Open File", UI_BUTTON_STYLE_PRIMARY) {
BeginLoadFileDialog(&dlg,"Open File")
snprintf(status,sizeof(status),"Open file requested.")
}
if WidgetButton(ScaleUIPx(226), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42), "Save File", UI_BUTTON_STYLE_SECONDARY) {
BeginSaveFileDialog(&dlg,"Save File","untitled.kry")
snprintf(status,sizeof(status),"Save file requested.")
}
if WidgetButton(ScaleUIPx(420), ScaleUIPx(116), ScaleUIPx(180), ScaleUIPx(42), "Select Folder", UI_BUTTON_STYLE_SECONDARY) {
BeginSelectFileDialogFolder(&dlg,"Select Folder")
snprintf(status,sizeof(status),"Folder selection requested.")
}
dialog_result: int = UpdateFileDialog(&dlg)
if dialog_result == 1 {
snprintf(last_path,sizeof(last_path),"%s",GetFileDialogPath(&dlg))
snprintf(status,sizeof(status),"Selected: %s",last_path)
}
if dialog_result < 0 {
snprintf(status,sizeof(status),"Dialog cancelled.")
}
WidgetText("Status", ScaleUIPx(32), ScaleUIPx(210), 18, GetThemeText())
WidgetText(status, ScaleUIPx(32), ScaleUIPx(242), UI_TEXT_16, GetThemeText())
WidgetText(last_path, ScaleUIPx(32), ScaleUIPx(274), UI_TEXT_16, GetThemeIcon())
}
-90
View File
@@ -1,90 +0,0 @@
#include "example_ui_font.h"
#include "theme.h"
#include "theme_meta.h"
#include "ui.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "UI Buttons Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
printf("UI Buttons Example\n");
printf("======================\n\n");
printf("This example demonstrates Flint's unified button component:\n");
printf(" - DrawUIGenericButton() - Single function for all button styles\n");
printf(" - Automatic hover detection and click handling\n");
printf(" - Theme integration with consistent styling\n");
printf("Click buttons to see momentary actions\n");
printf("Press ESC to exit\n\n");
int click_count = 0;
char last_action[128] = "No button clicked yet.";
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(), GetThemeSurface(),
GetThemeCircle(), GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());
// Draw title
DrawUIText("UI Buttons Example", ScaleUIPx(20), ScaleUIPx(20), 24, GetThemeText());
// Draw instructions
DrawUIText("Click the buttons below to test interactions", ScaleUIPx(20), ScaleUIPx(50), 16, GetThemeText());
DrawUIText("Buttons return a one-frame click event.", ScaleUIPx(20), ScaleUIPx(70), 14, GetThemeIcon());
// Button 1 - Primary style (using Flint utility)
int btn1_hover = 0;
if(DrawUIGenericButton(ScaleUIPx(20), ScaleUIPx(100), ScaleUIPx(200), ScaleUIPx(40),
"Primary Button", UI_BUTTON_STYLE_PRIMARY, 0, &btn1_hover)) {
click_count++;
snprintf(last_action, sizeof(last_action), "Primary Button clicked.");
}
// Button 2 - Secondary style
int btn2_hover = 0;
if(DrawUIGenericButton(ScaleUIPx(20), ScaleUIPx(150), ScaleUIPx(200), ScaleUIPx(40),
"Secondary Button", UI_BUTTON_STYLE_SECONDARY, 0, &btn2_hover)) {
click_count++;
snprintf(last_action, sizeof(last_action), "Secondary Button clicked.");
}
// Button 3 - Danger style
int btn3_hover = 0;
if(DrawUIGenericButton(ScaleUIPx(20), ScaleUIPx(200), ScaleUIPx(200), ScaleUIPx(40),
"Danger Button", UI_BUTTON_STYLE_DANGER, 0, &btn3_hover)) {
click_count++;
snprintf(last_action, sizeof(last_action), "Danger Button clicked.");
}
// Show click status
char status[128];
snprintf(status, sizeof(status), "Clicks: %d", click_count);
DrawUIText(status, ScaleUIPx(20), ScaleUIPx(260), 16, GetThemeText());
DrawUIText(last_action, ScaleUIPx(20), ScaleUIPx(285), 16, GetThemeText());
// Show button info
DrawUIText("Button Styles:", ScaleUIPx(300), ScaleUIPx(100), 18, GetThemeText());
DrawUIText("- Primary: theme button color", ScaleUIPx(300), ScaleUIPx(120), 14, GetThemeText());
DrawUIText("- Secondary: theme surface color", ScaleUIPx(300), ScaleUIPx(135), 14, GetThemeText());
DrawUIText("- Danger: destructive action color", ScaleUIPx(300), ScaleUIPx(150), 14, GetThemeText());
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
#import "kryon.h"
app "UI Buttons Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
click_count: int = 0
last_action: [128] char = "No button clicked yet."
}
screen ButtonsExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
WidgetText("UI Buttons Example", ScaleUIPx(20), ScaleUIPx(20), UI_TEXT_24, GetThemeText())
WidgetText("Click the buttons below to test interactions", ScaleUIPx(20), ScaleUIPx(54), UI_TEXT_16, GetThemeText())
if WidgetButton(ScaleUIPx(20), ScaleUIPx(100), ScaleUIPx(200), ScaleUIPx(40), "Primary Button", UI_BUTTON_STYLE_PRIMARY) {
click_count++
snprintf(last_action,sizeof(last_action),"Primary Button clicked.")
}
if WidgetButton(ScaleUIPx(20), ScaleUIPx(150), ScaleUIPx(200), ScaleUIPx(40), "Secondary Button", UI_BUTTON_STYLE_SECONDARY) {
click_count++
snprintf(last_action,sizeof(last_action),"Secondary Button clicked.")
}
if WidgetButton(ScaleUIPx(20), ScaleUIPx(200), ScaleUIPx(200), ScaleUIPx(40), "Danger Button", UI_BUTTON_STYLE_DANGER) {
click_count++
snprintf(last_action,sizeof(last_action),"Danger Button clicked.")
}
WidgetText(TextFormat("Clicks:%d",click_count), ScaleUIPx(20), ScaleUIPx(260), UI_TEXT_16, GetThemeText())
WidgetText(last_action, ScaleUIPx(20), ScaleUIPx(290), UI_TEXT_16, GetThemeText())
WidgetText("Button Styles", ScaleUIPx(300), ScaleUIPx(100), 18, GetThemeText())
WidgetText("Primary,secondary,and danger styles use the active theme.", ScaleUIPx(300), ScaleUIPx(130), 14, GetThemeIcon())
}
-151
View File
@@ -1,151 +0,0 @@
#include "example_ui_font.h"
#include "theme_meta.h"
#include "ui_scaling.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Flint Theme Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
printf("Flint Theme System Example\n");
printf("=========================\n\n");
printf("This example demonstrates Flint theme catalog:\n");
printf(" - GetThemeCatalogColor() - Get theme colors\n");
printf(" - GetThemeScopeName() - Get theme scope name\n");
printf(" - ThemeId enum - All available themes\n\n");
printf("Press SPACE to cycle through themes\n");
printf("Press D to toggle light/dark mode\n");
printf("Press ESC to exit\n\n");
// Available themes
ThemeId themes[] = {
THEME_SKY,
THEME_OCEAN,
THEME_FOREST,
THEME_SUNSET,
THEME_LAVENDER,
THEME_CHERRY,
};
int num_themes = 6;
int theme_index = 0;
int dark_mode = 0;
while(!WindowShouldClose()) {
BeginDrawing();
ThemeId current_theme = themes[theme_index];
SetCurrentTheme(current_theme, dark_mode);
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
// Get theme scope for proper color access
const char* scope = GetThemeScopeName(current_theme, dark_mode);
// Get theme colors using catalog (works without theme files)
Color background, text, button, button_hover, circle;
GetThemeCatalogColor(current_theme, dark_mode, "background", &background);
GetThemeCatalogColor(current_theme, dark_mode, "text", &text);
GetThemeCatalogColor(current_theme, dark_mode, "button", &button);
GetThemeCatalogColor(current_theme, dark_mode, "button_hover", &button_hover);
GetThemeCatalogColor(current_theme, dark_mode, "circle", &circle);
SetUIColors(text, background, GetThemeSurface(), circle, button, button_hover,
GetThemeIcon());
// Fill background with theme color
ClearBackground(background);
// Draw title with theme text color
const char *theme_name = GetThemeLabel(current_theme);
char title[128];
snprintf(title, sizeof(title), "Theme: %s (%s mode)", theme_name, dark_mode ? "Dark" : "Light");
DrawUIText(title, ScaleUIPx(20), ScaleUIPx(20), 24, text);
// Draw color swatches
int y = ScaleUIPx(70);
int x = ScaleUIPx(20);
int swatch_size = ScaleUIPx(60);
// Background
DrawRectangleRec((Rectangle){x, y, swatch_size, swatch_size}, background);
DrawRectangleLinesEx((Rectangle){x, y, swatch_size, swatch_size}, 1, text);
DrawUIText("Background", x + swatch_size + 10, y + 10, 16, text);
// Text
y += swatch_size + ScaleUIPx(20);
DrawRectangleRec((Rectangle){x, y, swatch_size, swatch_size}, text);
DrawUIText("Text", x + swatch_size + 10, y + 10, 16, text);
// Button
y += swatch_size + ScaleUIPx(20);
DrawRectangleRec((Rectangle){x, y, swatch_size, swatch_size}, button);
DrawUIText("Button", x + swatch_size + 10, y + 10, 16, text);
// Button Hover
y += swatch_size + ScaleUIPx(20);
DrawRectangleRec((Rectangle){x, y, swatch_size, swatch_size}, button_hover);
DrawUIText("Button Hover", x + swatch_size + 10, y + 10, 16, text);
// Circle
y += swatch_size + ScaleUIPx(20);
DrawRectangleRec((Rectangle){x, y, swatch_size, swatch_size}, circle);
DrawUIText("Circle", x + swatch_size + 10, y + 10, 16, text);
// Draw theme info
y += swatch_size + ScaleUIPx(40);
char info[128];
snprintf(info, sizeof(info), "Scope: %s", scope);
DrawUIText(info, x, y, 16, text);
y += ScaleUIPx(30);
snprintf(info, sizeof(info), "Theme ID: %d", current_theme);
DrawUIText(info, x, y, 16, text);
// Draw RGB values
y += ScaleUIPx(40);
DrawUIText("Color Values (R,G,B):", x, y, 18, text);
y += ScaleUIPx(25);
snprintf(info, sizeof(info), "Background: %d,%d,%d", background.r, background.g, background.b);
DrawUIText(info, x, y, 14, text);
y += ScaleUIPx(20);
snprintf(info, sizeof(info), "Text: %d,%d,%d", text.r, text.g, text.b);
DrawUIText(info, x, y, 14, text);
y += ScaleUIPx(20);
snprintf(info, sizeof(info), "Button: %d,%d,%d", button.r, button.g, button.b);
DrawUIText(info, x, y, 14, text);
// Instructions
y = ScaleUIPx(20);
x = ScaleUIPx(400);
DrawUIText("Controls:", x, y, 18, text);
y += ScaleUIPx(30);
DrawUIText("SPACE - Next theme", x, y, 16, text);
y += ScaleUIPx(25);
DrawUIText("D - Toggle dark/light mode", x, y, 16, text);
y += ScaleUIPx(25);
DrawUIText("ESC - Exit", x, y, 16, text);
// Handle input
if(IsKeyPressed(KEY_SPACE)) {
theme_index = (theme_index + 1) % num_themes;
}
if(IsKeyPressed(KEY_D)) {
dark_mode = !dark_mode;
}
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+127
View File
@@ -0,0 +1,127 @@
#import "kryon.h"
app "Kryon Theme Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
theme_index: int = 0
dark_mode: int = 0
}
ThemeAt :: (index: int) -> ThemeId {
if index == 0 {
return THEME_SKY
}
if index == 1 {
return THEME_OCEAN
}
if index == 2 {
return THEME_FOREST
}
if index == 3 {
return THEME_SUNSET
}
if index == 4 {
return THEME_LAVENDER
}
if index == 5 {
return THEME_CHERRY
}
if index == 6 {
return THEME_DAWN
}
if index == 7 {
return THEME_SAGE
}
if index == 8 {
return THEME_INK
}
if index == 9 {
return THEME_MONO
}
if index == 10 {
return THEME_MINT
}
return THEME_COBALT
}
ThemeSwatch :: (label: const char *, y: int, value: Color, label_color: Color) {
x: int = ScaleUIPx(20)
size: int = ScaleUIPx(56)
WidgetRect(x, y, size, size, value, BLANK)
WidgetRect(x, y, size, size, BLANK, label_color)
WidgetText(label, x+size+ScaleUIPx(10), y+ScaleUIPx(10), UI_TEXT_16, label_color)
}
ThemeButton :: (label: const char *, x: int, y: int, w: int) -> int {
h: int = ScaleUIPx(38)
return DrawUIGenericButton(x,y,w,h,label,UI_BUTTON_STYLE_SECONDARY,0,NULL)
}
ThemeLabel :: (label: const char *, value: const char *, y: int, size: int, text_color: Color) {
WidgetText(TextFormat("%s%s",label,value), ScaleUIPx(20), y, size, text_color)
}
ThemeSideLabel :: (label: const char *, value: const char *, y: int, text_color: Color) {
WidgetText(TextFormat("%s%s",label,value), ScaleUIPx(320), y, UI_TEXT_16, text_color)
}
ThemeSideInt :: (label: const char *, y: int, value: int, text_color: Color) {
WidgetText(TextFormat("%s%d",label,value), ScaleUIPx(320), y, UI_TEXT_16, text_color)
}
ThemeRGB :: (label: const char *, y: int, value: Color, text_color: Color) {
rgb_text: const char * = TextFormat("%s RGB:%d,%d,%d",label,value.r,value.g,value.b)
WidgetText(rgb_text, ScaleUIPx(320), y, 14, text_color)
}
screen ThemeExample(viewport: Rectangle) {
current_theme: ThemeId = ThemeAt(theme_index)
left_x: int = ScaleUIPx(300)
right_x: int = ScaleUIPx(420)
button_w: int = ScaleUIPx(112)
mode_w: int = ScaleUIPx(232)
SetCurrentTheme(current_theme, dark_mode)
background: Color
text_color: Color
button: Color
button_hover: Color
circle: Color
GetThemeCatalogColor(current_theme,dark_mode,"background",&background)
GetThemeCatalogColor(current_theme,dark_mode,"text",&text_color)
GetThemeCatalogColor(current_theme,dark_mode,"button",&button)
GetThemeCatalogColor(current_theme,dark_mode,"button_hover",&button_hover)
GetThemeCatalogColor(current_theme,dark_mode,"circle",&circle)
WidgetBackground(background)
ThemeLabel("Theme: ",GetThemeLabel(current_theme),ScaleUIPx(20),UI_TEXT_24,text_color)
ThemeLabel("Mode:",dark_mode?"Dark":"Light",ScaleUIPx(50),UI_TEXT_16,text_color)
if ThemeButton("Prev Theme", left_x, ScaleUIPx(18), button_w) {
theme_index = (theme_index + 11) % 12
}
if ThemeButton("Next Theme", right_x, ScaleUIPx(18), button_w) {
theme_index = (theme_index + 1) % 12
}
if dark_mode {
if ThemeButton("Light Mode", left_x, ScaleUIPx(64), mode_w) {
dark_mode = 0
}
} else {
if ThemeButton("Dark Mode", left_x, ScaleUIPx(64), mode_w) {
dark_mode = 1
}
}
ThemeSwatch("Background", ScaleUIPx(90), background, text_color)
ThemeSwatch("Text", ScaleUIPx(160), text_color, text_color)
ThemeSwatch("Button", ScaleUIPx(230), button, text_color)
ThemeSwatch("Button Hover", ScaleUIPx(300), button_hover, text_color)
ThemeSwatch("Circle", ScaleUIPx(370), circle, text_color)
scope: const char * = GetThemeScopeName(current_theme,dark_mode)
ThemeSideLabel("Scope:", scope, ScaleUIPx(120), text_color)
ThemeSideInt("Theme ID:", ScaleUIPx(152), current_theme, text_color)
ThemeRGB("Background", ScaleUIPx(200), background, text_color)
ThemeRGB("Text", ScaleUIPx(224), text_color, text_color)
}
-108
View File
@@ -1,108 +0,0 @@
#include "example_ui_font.h"
#include "ui_scaling.h"
#include "theme.h"
#include "theme_meta.h"
#include "ui.h"
#include "flint.h"
#include <stdio.h>
static void
load_theme(void)
{
SetCurrentTheme(THEME_SKY, 0);
}
static void
apply_ui_theme(void)
{
SetUIColors(GetThemeText(),
GetThemeBackground(),
GetThemeSurface(),
GetThemeCircle(),
GetThemeButton(),
GetThemeButtonHover(),
GetThemeIcon());
}
int
main(void)
{
int modal_open = 0;
int background_clicks = 0;
int last_result = 0;
const char *last_label = "none";
InitWindow(800, 600, "Flint Modal Example");
SetTargetFPS(60);
LoadExampleUIFont();
load_theme();
InitUI(GetScreenWidth(), GetScreenHeight(), 1.0f);
apply_ui_theme();
printf("Flint Modal Example\n");
printf("Click Open Modal. While it is open, background clicks are blocked.\n");
while(!WindowShouldClose()) {
int hover = 0;
BeginDrawing();
ClearBackground(GetThemeBackground());
apply_ui_theme();
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
DrawUIText("Modal capture example", 32, 32, 28, GetThemeText());
DrawUIText("Try clicking the background counter while the modal is open.",
32, 72, 18, DarkenUIColor(GetThemeText(), 30));
if(DrawUIGenericButton(32, 120, 220, 42, "Background Button",
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
background_clicks++;
}
DrawUIText(TextFormat("Background clicks: %d", background_clicks),
32, 176, 18, GetThemeText());
DrawUIText(TextFormat("Last modal result: %s", last_label),
32, 204, 18, GetThemeText());
if(DrawUIGenericButton(32, 230, 220, 42, "Open Modal",
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
modal_open = 1;
}
if(modal_open) {
UIModalAction actions[3] = {
{ "Cancel", UI_BUTTON_STYLE_SECONDARY, 0 },
{ "Confirm and continue with a longer label", UI_BUTTON_STYLE_PRIMARY, 0 },
{ "Delete", UI_BUTTON_STYLE_DANGER, 0 }
};
last_result = DrawUIActionModal((UIModalSpec){
.title = "Adaptive Action Modal",
.message = "Flint measures action labels, fits text inside buttons, and wraps the action row when the dialog is narrow.",
.actions = actions,
.action_count = 3,
.max_width = 420
});
if(last_result == 1) {
modal_open = 0;
last_label = "cancel";
} else if(last_result == 2) {
modal_open = 0;
last_label = "confirm";
printf("Modal confirmed\n");
} else if(last_result == 3) {
modal_open = 0;
last_label = "delete";
printf("Modal delete action\n");
}
}
if(IsKeyPressed(KEY_ESCAPE))
break;
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+44
View File
@@ -0,0 +1,44 @@
#import "kryon.h"
app "Kryon Modal Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
modal_open: int = 0
background_clicks: int = 0
last_label: [64] char = "none"
}
screen ModalExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
WidgetText("Modal capture example", 32, 32, UI_TEXT_24, GetThemeText())
WidgetText("Open the modal and background clicks are blocked.", 32, 72, UI_TEXT_16, GetThemeIcon())
if WidgetButton(32, 120, 220, 42, "Background Button", UI_BUTTON_STYLE_SECONDARY) {
background_clicks++
}
WidgetText(TextFormat("Background clicks:%d",background_clicks), 32, 176, UI_TEXT_16, GetThemeText())
WidgetText(TextFormat("Last modal result:%s",last_label), 32, 204, UI_TEXT_16, GetThemeText())
if WidgetButton(32, 240, 220, 42, "Open Modal", UI_BUTTON_STYLE_PRIMARY) {
modal_open = 1
}
if modal_open {
actions: [3] UIModalAction = {{"Cancel",UI_BUTTON_STYLE_SECONDARY,0},{"Confirm",UI_BUTTON_STYLE_PRIMARY,0},{"Delete",UI_BUTTON_STYLE_DANGER,0}}
result: int = DrawUIActionModal((UIModalSpec){"Adaptive Action Modal","Kryon measures action labels and blocks background clicks.",actions,3,420})
if result == 1 {
modal_open = 0
snprintf(last_label,sizeof(last_label),"cancel")
}
if result == 2 {
modal_open = 0
snprintf(last_label,sizeof(last_label),"confirm")
}
if result == 3 {
modal_open = 0
snprintf(last_label,sizeof(last_label),"delete")
}
}
}
-92
View File
@@ -1,92 +0,0 @@
#include "example_ui_font.h"
#include "theme.h"
#include "theme_meta.h"
#include "ui_color.h"
#include "ui_scaling.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Flint Color Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
printf("Flint Color Utilities Example\n");
printf("===========================\n\n");
printf("This example demonstrates Flint color manipulation functions:\n");
printf(" - LightenUIColor(color, amount)\n");
printf(" - DarkenUIColor(color, amount)\n\n");
printf("Press SPACE to cycle through color examples\n");
printf("Press ESC to exit\n\n");
int color_index = 0;
int num_colors = 5;
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(), GetThemeSurface(),
GetThemeCircle(), GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());
Color test_colors[] = {
GetThemeButton(),
GetThemeButtonHover(),
GetThemeCircle(),
GetThemeSurface(),
GetThemeLink(),
};
Color base = test_colors[color_index];
// Display original color
DrawRectangleRec((Rectangle){50, 50, 200, 50}, base);
DrawUIText("Original", 55, 55, 16, GetThemeText());
// Display lightened color
Color light = LightenUIColor(base, 40);
DrawRectangleRec((Rectangle){300, 50, 200, 50}, light);
DrawUIText("Lightened (+40)", 305, 55, 16, GetThemeText());
// Display darkened color
Color dark = DarkenUIColor(base, 40);
DrawRectangleRec((Rectangle){550, 50, 200, 50}, dark);
DrawUIText("Darkened (-40)", 555, 55, 16, GetThemeText());
// Show current color index
char info[64];
snprintf(info, sizeof(info), "Color %d/%d (Press SPACE to cycle)", color_index + 1, num_colors);
DrawUIText(info, 50, 120, 20, GetThemeText());
// Instructions
DrawUIText("Top row: Original theme color", 50, 150, 16, GetThemeText());
DrawUIText("Middle: Lightened by 40", 50, 170, 16, GetThemeText());
DrawUIText("Bottom: Darkened by 40", 50, 190, 16, GetThemeText());
DrawUIText("", 50, 220, 16, GetThemeText());
DrawUIText("Color RGB values:", 50, 250, 20, GetThemeText());
char rgb[64];
snprintf(rgb, sizeof(rgb), "R:%d G:%d B:%d", base.r, base.g, base.b);
DrawUIText(rgb, 50, 270, 16, GetThemeText());
// Handle input
if(IsKeyPressed(KEY_SPACE)) {
color_index = (color_index + 1) % num_colors;
WaitTime(0.2);
}
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
#import "kryon.h"
app "Kryon Color Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
color_index: int = 0
}
screen ColorExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
colors: [5] Color = {GetThemeButton(),GetThemeButtonHover(),GetThemeCircle(),GetThemeSurface(),GetThemeLink()}
base: Color = colors[color_index]
light: Color = LightenUIColor(base,40)
dark: Color = DarkenUIColor(base,40)
WidgetText("Color Utilities", 50, 20, UI_TEXT_24, GetThemeText())
WidgetRect(50, 70, 70, 70, base, BLANK)
WidgetRect(50, 70, 70, 70, BLANK, GetThemeText())
WidgetText("Original", 50+70+ScaleUIPx(10), 70+ScaleUIPx(10), UI_TEXT_16, GetThemeText())
WidgetRect(50, 160, 70, 70, light, BLANK)
WidgetRect(50, 160, 70, 70, BLANK, GetThemeText())
WidgetText("Lightened", 50+70+ScaleUIPx(10), 160+ScaleUIPx(10), UI_TEXT_16, GetThemeText())
WidgetRect(50, 250, 70, 70, dark, BLANK)
WidgetRect(50, 250, 70, 70, BLANK, GetThemeText())
WidgetText("Darkened", 50+70+ScaleUIPx(10), 250+ScaleUIPx(10), UI_TEXT_16, GetThemeText())
WidgetText(TextFormat("Color %d/5 - SPACE cycles",color_index+1), 320, 82, 18, GetThemeText())
WidgetText(TextFormat("RGB:%d,%d,%d",base.r,base.g,base.b), 320, 116, UI_TEXT_16, GetThemeText())
if (UIKeyPressed(KEY_SPACE)) {
color_index = (color_index + 1) % 5
}
}
-88
View File
@@ -1,88 +0,0 @@
#include "example_ui_font.h"
#include "theme.h"
#include "theme_meta.h"
#include "ui_scaling.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Flint Scaling Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
// Test different DPI scales
float scales[] = {1.0f, 1.5f, 2.0f, 2.5f};
int num_scales = 4;
int scale_index = 0;
printf("Flint DPI Scaling Example\n");
printf("=======================\n\n");
printf("This example demonstrates Flint DPI scaling functions:\n");
printf(" - ScaleUIPx(value) - Scale pixels by DPI factor\n");
printf(" - ClampUIPx(value, min, max) - Scale and clamp pixels\n\n");
printf("Press SPACE to cycle DPI scales\n");
printf("Use arrow keys to move test box\n");
printf("Press ESC to exit\n\n");
Vector2 box_pos = {100, 100};
int box_size_base = 100;
while(!WindowShouldClose()) {
// Set current DPI scale
SetUIScale(scales[scale_index]);
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(), GetThemeSurface(),
GetThemeCircle(), GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());
// Scale box size
int box_size = ScaleUIPx(box_size_base);
// Draw info
char info[128];
snprintf(info, sizeof(info), "DPI Scale: %.1f (Press SPACE to cycle)", scales[scale_index]);
DrawUIText(info, 50, 20, 20, GetThemeText());
// Draw box with scaled size
DrawRectangleRec((Rectangle){box_pos.x, box_pos.y, box_size, box_size}, GetThemeButton());
DrawUIText("Scaled Box", box_pos.x + 10, box_pos.y + 10, 16, GetThemeText());
// Show base vs scaled
char size_info[128];
snprintf(size_info, sizeof(size_info), "Base: %dpx, Scaled: %dpx", box_size_base, box_size);
DrawUIText(size_info, 50, 60, 16, GetThemeText());
// Instructions
DrawUIText("Arrow keys to move box", 50, 90, 16, GetThemeText());
DrawUIText("Box size scales with DPI", 50, 110, 16, GetThemeText());
// Handle box movement
if(IsKeyDown(KEY_RIGHT)) box_pos.x += 3;
if(IsKeyDown(KEY_LEFT)) box_pos.x -= 3;
if(IsKeyDown(KEY_DOWN)) box_pos.y += 3;
if(IsKeyDown(KEY_UP)) box_pos.y -= 3;
// Handle DPI scale changes
if(IsKeyPressed(KEY_SPACE)) {
scale_index = (scale_index + 1) % num_scales;
WaitTime(0.2);
}
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+41
View File
@@ -0,0 +1,41 @@
#import "kryon.h"
app "Kryon Scaling Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
scale_index: int = 0
scales: [4] float = {1.0f,1.5f,2.0f,2.5f}
box_x: int = 100
box_y: int = 100
}
screen ScalingExample(viewport: Rectangle) {
SetUIScale(scales[scale_index])
WidgetBackground(GetThemeBackground())
box_size: int = ScaleUIPx(100)
WidgetText(TextFormat("DPI Scale:%.1f",scales[scale_index]), 50, 20, 20, GetThemeText())
WidgetRect(box_x, box_y, box_size, box_size, GetThemeButton(), GetThemeIcon())
WidgetText("Scaled Box", box_x + 10, box_y + 10, UI_TEXT_16, GetThemeText())
WidgetText(TextFormat("Base:100px Scaled:%dpx",box_size), 50, 60, UI_TEXT_16, GetThemeText())
WidgetText("SPACE cycles DPI,arrows move box", 50, 90, UI_TEXT_16, GetThemeIcon())
if (UIKeyDown(KEY_RIGHT)) {
box_x += 3
}
if (UIKeyDown(KEY_LEFT)) {
box_x -= 3
}
if (UIKeyDown(KEY_DOWN)) {
box_y += 3
}
if (UIKeyDown(KEY_UP)) {
box_y -= 3
}
if (UIKeyPressed(KEY_SPACE)) {
scale_index = (scale_index + 1) % 4
}
}
-98
View File
@@ -1,98 +0,0 @@
#include "example_ui_font.h"
#include "theme.h"
#include "theme_meta.h"
#include "ui_layout.h"
#include "ui_scaling.h"
#include <stdio.h>
#include "flint.h"
int main(void) {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Flint Layout Example");
SetTargetFPS(60);
LoadExampleUIFont();
InitUI(screenWidth, screenHeight, GetUIScale());
SetCurrentTheme(THEME_SKY, 0);
// Initialize view size
SetUIViewSize(screenWidth, screenHeight);
printf("Flint Layout Utilities Example\n");
printf("==============================\n\n");
printf("This example demonstrates Flint layout functions:\n");
printf(" - GetUIPageSidePadding() - Get side padding for content\n");
printf(" - GetUICenteredColumn() - Calculate centered column\n");
printf(" - GetUIViewWidth() - Get available content width\n\n");
printf("Press SPACE to show layout guides\n");
printf("Press ESC to exit\n\n");
int show_guides = 0;
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale());
SetUIColors(GetThemeText(), GetThemeBackground(), GetThemeSurface(),
GetThemeCircle(), GetThemeButton(), GetThemeButtonHover(),
GetThemeIcon());
int screen_w = GetScreenWidth();
int screen_h = GetScreenHeight();
// Calculate layout
int side_padding = GetUIPageSidePadding();
int content_x = side_padding;
int content_w = GetUIViewWidth();
int content_h = screen_h - ScaleUIPx(64);
// Draw main content area
Rectangle content_area = {content_x, ScaleUIPx(32), content_w, content_h};
DrawRectangleRec(content_area, GetThemeSurface());
DrawRectangleLinesEx(content_area, 1, GetThemeIcon());
// Draw centered column example
int col_x, col_w;
GetUICenteredColumn(200, side_padding, &col_x, &col_w);
DrawRectangle(col_x, ScaleUIPx(32), col_w, content_h, GetThemeButton());
if(show_guides) {
// Draw layout guides
DrawLine(side_padding, 0, side_padding, screen_h, GetThemeLink());
DrawLine(screen_w - side_padding, 0, screen_w - side_padding, screen_h, GetThemeLink());
char label[64];
snprintf(label, sizeof(label), "Side padding: %d", side_padding);
DrawUIText(label, side_padding + 10, 10, 12, GetThemeLink());
snprintf(label, sizeof(label), "Content width: %d", content_w);
DrawUIText(label, content_x + 10, content_area.y - 20, 12, GetThemeLink());
snprintf(label, sizeof(label), "Center column X: %d, W: %d", col_x, col_w);
DrawUIText(label, col_x + 10, content_area.y - 20, 12, GetThemeButton());
// Draw center line
int center_x = screen_w / 2;
DrawLine(center_x, 0, center_x, screen_h, GetThemeCircle());
}
// Draw title
DrawUIText("Flint Layout Example", side_padding, ScaleUIPx(20), 24, GetThemeText());
DrawUIText("Press SPACE for layout guides", side_padding, ScaleUIPx(48), 16, GetThemeText());
// Handle input
if(IsKeyPressed(KEY_SPACE)) {
show_guides = !show_guides;
}
if(IsKeyPressed(KEY_ESCAPE)) {
break;
}
EndDrawing();
}
UnloadExampleUIFont();
CloseWindow();
return 0;
}
+69
View File
@@ -0,0 +1,69 @@
#import "kryon.h"
app "Kryon Layout Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
max_width: int = 560
}
LayoutInfo :: (label: const char *, value: int, x: int, y: int) {
info: const char * = TextFormat("%s:%d",label,value)
WidgetText(info, x, y, UI_TEXT_16, GetThemeText())
}
WidthButton :: (label: const char *, x: int, y: int, value: int) -> int {
style: int = UI_BUTTON_STYLE_SECONDARY
if max_width == value {
style = UI_BUTTON_STYLE_PRIMARY
}
return DrawUIGenericButton(x,y,ScaleUIPx(110),ScaleUIPx(34),label,style,0,NULL)
}
LayoutNote :: (label: const char *, x: int, y: int, color: Color) {
WidgetText(label, x, y, UI_TEXT_16, color)
}
screen LayoutExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
side_padding: int = GetUIPageSidePadding()
page_x: int = side_padding
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)
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)
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)
WidgetText("Responsive layout", page_x, ScaleUIPx(16), UI_TEXT_24, GetThemeText())
WidgetRect(page_x, y, page_w, guide_h, GetThemeSurface(), GetThemeIcon())
WidgetLine(side_padding, y, side_padding, y+guide_h, GetThemeLink())
WidgetLine(right_edge, y, right_edge, y+guide_h, GetThemeLink())
WidgetRect(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))
if WidthButton("Narrow", btn0_x, btn_y, 360) {
max_width = 360
}
if WidthButton("Medium", btn1_x, btn_y, 560) {
max_width = 560
}
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())
}
+51
View File
@@ -0,0 +1,51 @@
#import "kryon.h"
app "Kryon Geometry" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
screen GeometryExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
SetUIViewSize(GetScreenWidth(),GetScreenHeight())
shell: Rectangle = {40,42,GetUIViewWidth()-80,GetUIViewHeight()-84}
frame: UIFrame = BeginUIFrameBox(shell,16,16,12)
header: Rectangle = UIFramePack(&frame,UI_SIDE_TOP,54)
footer: Rectangle = UIFramePack(&frame,UI_SIDE_BOTTOM,46)
rail: Rectangle = UIFramePack(&frame,UI_SIDE_LEFT,150)
body: Rectangle = frame.bounds
grid: UIGrid = {body,2,3,10,10,16,16}
card0: Rectangle = UIGridCell(grid,0,0,1,2)
card1: Rectangle = UIGridCell(grid,0,2,1,1)
card2: Rectangle = UIGridCell(grid,1,0,1,1)
card3: Rectangle = UIGridCell(grid,1,1,1,2)
badge: Rectangle = UIPlace(card1,14,42,92,28)
action: Rectangle = UIPlace(footer,16,7,150,32)
WidgetText("Geometry helpers", 40, 14, UI_TEXT_24, GetThemeText())
DrawRectangleRec(shell,GetThemeSurface())
DrawRectangleLinesEx(shell,1,GetThemeIcon())
DrawRectangleRec(header,GetThemeButton())
DrawRectangleRec(rail,DarkenUIColor(GetThemeSurface(),8))
DrawUISeparator((Rectangle){rail.x+rail.width+6,rail.y,1,rail.height},1)
WidgetText("Packed header", header.x+16, header.y+16, UI_TEXT_16, GetThemeText())
WidgetText("Left rail", rail.x+16, rail.y+16, UI_TEXT_16, GetThemeText())
DrawRectangleRec(card0,DarkenUIColor(GetThemeSurface(),12))
DrawRectangleLinesEx(card0,1,GetThemeButton())
DrawRectangleRec(card1,DarkenUIColor(GetThemeSurface(),16))
DrawRectangleLinesEx(card1,1,GetThemeButton())
DrawRectangleRec(card2,DarkenUIColor(GetThemeSurface(),18))
DrawRectangleLinesEx(card2,1,GetThemeButton())
DrawRectangleRec(card3,DarkenUIColor(GetThemeSurface(),22))
DrawRectangleLinesEx(card3,1,GetThemeButton())
WidgetText("UIGridCell 2-column span", card0.x+14, card0.y+18, UI_TEXT_16, GetThemeText())
WidgetText("UIPlace badge", card1.x+14, card1.y+18, UI_TEXT_16, GetThemeText())
DrawRectangleRec(badge,GetThemeButtonHover())
WidgetText("badge", badge.x+18, badge.y+7, UI_TEXT_12, GetThemeText())
WidgetText("cell 1,0", card2.x+14, card2.y+18, UI_TEXT_16, GetThemeText())
WidgetText("wide footer cell", card3.x+14, card3.y+18, UI_TEXT_16, GetThemeText())
DrawUISeparator((Rectangle){footer.x,footer.y-7,footer.width,1},0)
DrawRectangleRec(action,GetThemeButton())
WidgetText("placed action", action.x+14, action.y+9, UI_TEXT_12, GetThemeText())
}
+25
View File
@@ -0,0 +1,25 @@
#import "kryon.h"
app "Kryon Menus" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
open_menu: int = -1
status: [64] char = "No menu command"
}
screen MenusExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
file_items: [4] UIMenuItem = {{UI_MENU_COMMAND,"New","Ctrl+N",1,0,0,NULL,0},{UI_MENU_COMMAND,"Open","Ctrl+O",2,0,0,NULL,0},{UI_MENU_SEPARATOR,NULL,NULL,0,0,0,NULL,0},{UI_MENU_COMMAND,"Quit","Esc",3,0,0,NULL,0}}
view_items: [3] UIMenuItem = {{UI_MENU_CHECK,"Show Grid","G",4,0,1,NULL,0},{UI_MENU_RADIO,"Compact",NULL,5,0,0,NULL,0},{UI_MENU_RADIO,"Comfortable",NULL,6,0,1,NULL,0}}
menus: [2] UIMenu = {{{0},"File",file_items,4},{{0},"View",view_items,3}}
result: UIMenuBarResult = DrawUIMenuBar(100,(Rectangle){0,0,GetScreenWidth(),34},menus,2,&open_menu)
if result.activated_id != 0 {
snprintf(status,sizeof(status),"Command %d",result.activated_id)
}
WidgetText(status, 40, 80, 20, GetThemeText())
}
+42
View File
@@ -0,0 +1,42 @@
#import "kryon.h"
app "Kryon Basic Controls" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
radio: int = 1
spin: int = 4
combo: int = 0
progress: int = 45
choices: [3] const char * = {"Alpha","Beta","Gamma"}
}
screen BasicControlsExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
WidgetText("Basic controls", 40, 40, UI_TEXT_24, GetThemeText())
picked: int = DrawUIRadioButton((UIRadioButton){{40,90,160,28},"Choice A",1,radio==1,0})
if picked {
radio = picked
}
picked = DrawUIRadioButton((UIRadioButton){{40,124,160,28},"Choice B",2,radio==2,0})
if picked {
radio = picked
}
DrawUISpinbox((UISpinbox){{240,90,140,34},201,0,10,1,&spin,0})
DrawUICombobox((UICombobox){{240,140,180,34},202,choices,3,&combo,0})
DrawUIProgressBar((UIProgressBar){{40,210,380,28},0,100,progress,"Progress"})
if (UIKeyPressed(KEY_RIGHT)) {
if progress < 100 {
progress += 5
}
}
if (UIKeyPressed(KEY_LEFT)) {
if progress > 0 {
progress -= 5
}
}
}
+32
View File
@@ -0,0 +1,32 @@
#import "kryon.h"
app "Kryon Collections" {
size 900 620
fps 60
font examples
theme THEME_SKY light
}
state {
list_sel: int = 0
tree_sel: int = 1
row_sel: int = 0
sort_col: int = 0
list_scroll: int = 0
tree_scroll: int = 0
table_scroll: int = 0
items: [4] const char * = {"One","Two","Three","Four"}
}
screen CollectionsExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
tree: [4] UITreeItem = {{"Project",0,1,1,1},{"src",1,2,1,1},{"main.kry",2,3,0,1},{"README.md",1,4,0,1}}
cols: [2] const char * = {"Name","Kind"}
row0: [2] const char * = {"main.kry","Kry source"}
row1: [2] const char * = {"README.md","Markdown"}
rows: [2] UITableRow = {{row0,2},{row1,2}}
DrawUIListBox((UIListBox){{40,60,180,180},301,items,4,&list_sel,&list_scroll,30})
DrawUITreeView((UITreeView){{260,60,220,180},302,tree,4,&tree_sel,&tree_scroll,28})
DrawUITableView((UITableView){{520,60,320,180},303,cols,2,rows,2,NULL,&row_sel,&sort_col,&table_scroll,28})
WidgetText("Collections: list,tree,and table", 40, 280, 18, GetThemeText())
}
+28
View File
@@ -0,0 +1,28 @@
#import "kryon.h"
app "Kryon Text Editor" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
text_value: [512] char = "Edit this text."
cursor: int = 15
focused: int = 0
scroll: int = 0
}
screen TextEditorExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
DrawUITextArea((UITextArea){{40,70,520,180},text_value,sizeof(text_value),&cursor,&focused,&scroll,500,UI_TEXT_16,6,401,"Write here",UI_SYNTAX_NONE,{0},NULL,NULL})
WidgetText("Ctrl/Cmd+C,X,and V work in the text area.", 40, 260, UI_TEXT_16, GetThemeText())
if WidgetButton(40, 300, 110, 34, "Copy", UI_BUTTON_STYLE_SECONDARY) {
SetUIClipboardTextValue(text_value)
}
if WidgetButton(170, 300, 110, 34, "Paste", UI_BUTTON_STYLE_SECONDARY) {
clip: const char * = GetUIClipboardTextValue()
snprintf(text_value,sizeof(text_value),"%s",clip)
}
}
+30
View File
@@ -0,0 +1,30 @@
#import "kryon.h"
app "Kryon Canvas" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
selected: int = -1
sx: int = 0
sy: int = 0
zoom: float = 1.0f
shapes: [2] Rectangle = {{100,100,90,60},{260,140,120,80}}
}
screen CanvasExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
canvas: UICanvasResult = BeginUICanvas((UICanvas){{40,50,620,420},&sx,&sy,&zoom})
DrawUICanvasGrid((Rectangle){40,50,620,420},24,GetThemeButton())
for i in 0..2 {
DrawRectangleRec(shapes[i],i==selected?GetThemeButtonHover():GetThemeSurface())
DrawRectangleLinesEx(shapes[i],2.0f,GetThemeIcon())
}
if canvas.active && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) {
selected = UICanvasHitTest(canvas.world,shapes,2)
}
EndUICanvas((UICanvas){{40,50,620,420},&sx,&sy,&zoom})
}
+25
View File
@@ -0,0 +1,25 @@
#import "kryon.h"
app "Kryon Containers" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
tab: int = 0
split: int = 260
open: int = 1
tabs: [3] const char * = {"Files","Search","Output"}
}
screen ContainersExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
DrawUINotebook((UINotebook){{40,50,680,400},tabs,3,&tab})
DrawUIPanedView((UIPanedView){{40,100,680,280},501,1,&split,120,160})
DrawUICollapsible((UICollapsible){{60,410,320,120},"Details",&open})
if open {
WidgetText("Collapsible content", 80, 455, UI_TEXT_16, GetThemeText())
}
}
+39
View File
@@ -0,0 +1,39 @@
#import "kryon.h"
app "Kryon Dialogs" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
dialog: int = 0
prompt: [128] char = "value"
cursor: int = 5
focused: int = 0
color: Color = {120,160,220,255}
}
screen DialogsExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
if WidgetButton(40, 60, 150, 34, "Message", UI_BUTTON_STYLE_PRIMARY) {
dialog = 1
}
if WidgetButton(40, 104, 150, 34, "Confirm", UI_BUTTON_STYLE_PRIMARY) {
dialog = 2
}
if WidgetButton(40, 148, 150, 34, "Prompt", UI_BUTTON_STYLE_PRIMARY) {
dialog = 3
}
DrawUIColorPicker((Rectangle){240,60,320,160},&color)
if dialog == 1 && DrawUIMessageDialog((UIMessageDialog){"Message","Hello from Kryon.","OK"}) > 0 {
dialog = 0
}
if dialog == 2 && DrawUIConfirmDialog((UIConfirmDialog){"Confirm","Continue?","No","Yes"}) != 0 {
dialog = 0
}
if dialog == 3 && DrawUIPromptDialog((UIPromptDialog){"Prompt",prompt,sizeof(prompt),&cursor,&focused,"Cancel","Save"}) != 0 {
dialog = 0
}
}
+27
View File
@@ -0,0 +1,27 @@
#import "kryon.h"
app "Kryon Keyboard Platform" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
copied: int = 0
message: [128] char = "Press Ctrl/Cmd+C to copy text."
}
screen KeyboardPlatformExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
WidgetText("Keyboard and clipboard", 40, 40, UI_TEXT_24, GetThemeText())
WidgetText(message, 40, 90, UI_TEXT_16, GetThemeText())
if UIAcceleratorPressed((UIAccelerator){KEY_C,1,0,0,1}) {
SetUIClipboardTextValue("Copied from Kryon")
snprintf(message,sizeof(message),"Copied to clipboard")
copied = 1
}
if copied {
WidgetText("Clipboard updated.", 40, 130, UI_TEXT_16, GetThemeLink())
}
}
+24
View File
@@ -0,0 +1,24 @@
#import "kryon.h"
app "Kryon Accessibility" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
enabled: int = 1
}
screen AccessibilityExample(viewport: Rectangle) {
WidgetBackground(GetThemeBackground())
WidgetText("Accessibility overlay", 40, 40, UI_TEXT_24, GetThemeText())
DrawUICheckboxToggle(40,90,"Show focus/debug overlay",&enabled)
if WidgetButton(40, 140, 200, 40, "Focusable Button", UI_BUTTON_STYLE_PRIMARY) {
enabled = !enabled
}
if enabled {
DrawUIFocus((Rectangle){36,136,208,48})
}
}
+80 -37
View File
@@ -2,74 +2,98 @@
CC ?= cc
CFLAGS_BASE ?= -Wall -Wextra -O2
CFLAGS = $(CFLAGS_BASE) -I../include
LDFLAGS = -L.. -lflint
CFLAGS = $(CFLAGS_BASE) -I. -I../include
LDFLAGS = -L.. -lkryon
UNAME_S := $(shell uname -s)
RAYLIB_PKG_LIBS := $(shell pkg-config --libs raylib 2>/dev/null || printf '%s' '-L/usr/local/lib -lraylib')
GL_X11_PKG_LIBS := $(shell pkg-config --libs gl x11 2>/dev/null || printf '%s' '-L/usr/local/lib -lGL -lX11')
GTK_PKG_CFLAGS := $(shell pkg-config --cflags gtk+-3.0 2>/dev/null)
GTK_PKG_LIBS := $(shell pkg-config --libs gtk+-3.0 2>/dev/null)
EXAMPLE_SYSTEM_LDLIBS := $(RAYLIB_PKG_LIBS) $(GL_X11_PKG_LIBS) $(GTK_PKG_LIBS) -lm -lpthread
RAY_PKGS ?= sdl2 libdrm gbm egl glesv2
RAY_SDL_CFLAGS ?= $(shell pkg-config --cflags sdl2 2>/dev/null)
RAY_SDL_LDLIBS ?= $(shell pkg-config --libs sdl2 2>/dev/null)
RAY_GL_CFLAGS ?= $(shell pkg-config --cflags libdrm gbm egl glesv2 2>/dev/null)
RAY_GL_LDLIBS ?= $(shell pkg-config --libs libdrm gbm egl glesv2 2>/dev/null)
RAY_CFLAGS ?= $(strip $(RAY_SDL_CFLAGS) $(RAY_GL_CFLAGS))
RAY_LDLIBS ?= $(strip $(RAY_SDL_LDLIBS) $(RAY_GL_LDLIBS))
RAY_SDL_INCLUDE_DIR ?= $(shell pkg-config --variable=includedir sdl2 2>/dev/null | sed 's,/SDL2$$,,')
EXAMPLE_SYSTEM_LDLIBS := $(RAY_LDLIBS) $(GL_X11_PKG_LIBS) $(GTK_PKG_LIBS) -lm -lpthread
ifeq ($(UNAME_S),Linux)
EXAMPLE_SYSTEM_LDLIBS += -ldl -lrt
endif
FLINT_DIR := ..
FONT_OUTPUT := assets/fonts/locales
FONT_OUTPUTS := $(FONT_OUTPUT).png $(FONT_OUTPUT).dat
FONT_LOCALES := $(wildcard locales/*.txt)
FONT_TOOL := ../tools/otfchop/otfchop
FONT_SOURCE := ../tools/otfchop/unifont-17.0.04.otf
KRYON_DIR := ..
FONT_OUTPUTS := $(wildcard ../fonts/noto/*.ttf ../fonts/noto/*.otf)
BUILD_DIR ?= ../build/examples
KC ?= ../build/bin/kc
CODEGEN_DIR := $(BUILD_DIR)/codegen
BIN_DIR := $(BUILD_DIR)/bin
RAYLIB_BUILD_DIR := $(BUILD_DIR)/raylib-native
RAYLIB_LIB_NAME := raylib
RAYLIB_A := $(RAYLIB_BUILD_DIR)/lib$(RAYLIB_LIB_NAME).a
WEB_EMBED_ASSETS_C := $(BUILD_DIR)/embedded_asset_data.c
WEB_EMBED_ASSET_FILES := $(shell find ../themes -type f 2>/dev/null)
WEB_RAYLIB_BUILD_DIR := $(BUILD_DIR)/raylib-web
WEB_RAYLIB_A := $(WEB_RAYLIB_BUILD_DIR)/libraylib.web.a
FLINT_VENDOR_BUILD_DIR ?= $(BUILD_DIR)/vendor
FLINT_WEB_LIBOQS_BUILD_DIR ?= $(FLINT_VENDOR_BUILD_DIR)/web-liboqs
KRYON_VENDOR_BUILD_DIR ?= $(BUILD_DIR)/vendor
KRYON_WEB_LIBOQS_BUILD_DIR ?= $(KRYON_VENDOR_BUILD_DIR)/web-liboqs
include ../mk/vendor.mk
WEB_CC ?= emcc
WEB_AR ?= emar
EMSCRIPTEN_FILE_PACKAGER ?= /usr/local/lib/emscripten/tools/file_packager
WEB_SHELL := web_shell.html
EXAMPLES_WEB_SITE_DIR ?= ../build/site/examples
include ../mk/raylib.mk
FLINT_LIBRARY_SRCS := $(shell find ../src -type f -name '*.c' | LC_ALL=C sort)
FLINT_WEB_SRCS := $(filter-out ../src/file_dialog/file_dialog.c,$(FLINT_LIBRARY_SRCS)) $(WEB_EMBED_ASSETS_C) $(FLINT_RAYLIB_WRAPPERS_C)
FLINT_ALL_WEB_SRCS := $(FLINT_LIBRARY_SRCS) $(WEB_EMBED_ASSETS_C) $(FLINT_RAYLIB_WRAPPERS_C)
WEB_CFLAGS := -Wall -Wextra -std=gnu99 -O0 -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 -DHAS_LIBOQS=1 -I$(FLINT_WEB_LIBOQS_BUILD_DIR)/include
KRYON_LIBRARY_SRCS := $(shell find ../src -type f -name '*.c' | LC_ALL=C sort)
KRYON_WEB_SRCS := $(filter-out ../src/file_dialog/file_dialog.c,$(KRYON_LIBRARY_SRCS)) $(WEB_EMBED_ASSETS_C) $(KRYON_RAYLIB_WRAPPERS_C)
KRYON_ALL_WEB_SRCS := $(KRYON_LIBRARY_SRCS) $(WEB_EMBED_ASSETS_C) $(KRYON_RAYLIB_WRAPPERS_C)
WEB_CFLAGS := -Wall -Wextra -std=gnu99 -O0 -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 -DHAS_LIBOQS=1 -I$(KRYON_WEB_LIBOQS_BUILD_DIR)/include
WEB_LDFLAGS := -sUSE_GLFW=3 -sALLOW_MEMORY_GROWTH=1 -sASYNCIFY -sINITIAL_MEMORY=134217728 -sSTACK_SIZE=8388608 -sGLOBAL_BASE=16777216
WEB_PRELOAD_FLAGS ?= $(if $(wildcard $(EMSCRIPTEN_FILE_PACKAGER)),--preload-file ../fonts/noto@fonts/noto,)
WEB_OUTPUTS = $(addprefix $(EXAMPLES_WEB_SITE_DIR)/,$(addsuffix /index.html,$(EXAMPLES)))
# Check if we're in nix-shell and use its flags
CFLAGS += $(GTK_PKG_CFLAGS)
CFLAGS += $(GTK_PKG_CFLAGS) -I$(CODEGEN_DIR)
ifneq ($(NIX_CFLAGS_COMPILE),)
CFLAGS += $(NIX_CFLAGS_COMPILE)
endif
LDFLAGS += $(EXAMPLE_SYSTEM_LDLIBS)
LDFLAGS += $(RAYLIB_A) $(EXAMPLE_SYSTEM_LDLIBS)
EXAMPLES = 01_file_dialog 02_buttons 03_theme 04_modal 05_color 06_scaling 07_layout
EXAMPLES = 01_file_dialog 02_buttons 03_theme 04_modal 05_color 06_scaling 07_layout \
09_geometry 10_menus 11_basic_controls 12_collections 13_text_editor \
14_canvas 15_containers 16_dialogs 17_keyboard_platform 18_accessibility
EXAMPLE_BINS := $(addprefix $(BIN_DIR)/,$(EXAMPLES))
.PHONY: all clean run list font-assets web web-clean
.SECONDARY: $(addprefix $(CODEGEN_DIR)/,$(addsuffix .c,$(EXAMPLES))) $(addprefix $(CODEGEN_DIR)/,$(addsuffix .h,$(EXAMPLES)))
all: ../libflint.a $(EXAMPLES)
all: ../libkryon.a $(KC) $(EXAMPLE_BINS)
../libflint.a:
../libkryon.a:
@$(MAKE) -C ..
$(FONT_TOOL):
@$(MAKE) -C ../tools/otfchop otfchop
$(KC):
@$(MAKE) -C .. build/bin/kc
font-assets: $(FONT_OUTPUTS)
font-assets:
@printf '%s\n' 'font assets are checked in'
$(FONT_OUTPUTS): $(FONT_LOCALES) $(FONT_TOOL) $(FONT_SOURCE)
@mkdir -p assets/fonts
@$(FONT_TOOL) $(FONT_SOURCE) $(FONT_LOCALES) $(FONT_OUTPUT)
$(CODEGEN_DIR):
@mkdir -p $@
%: %.c $(FONT_OUTPUTS)
$(BIN_DIR):
@mkdir -p $@
$(CODEGEN_DIR)/%.c $(CODEGEN_DIR)/%.h: %.kry $(KC) | $(CODEGEN_DIR)
@echo "Generating $*..."
@$(KC) --root . -o $(CODEGEN_DIR) $<
$(BIN_DIR)/%: $(CODEGEN_DIR)/%.c ../libkryon.a $(RAYLIB_A) $(FONT_OUTPUTS) | $(BIN_DIR)
@echo "Building $@..."
@$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
@echo "Built: $@"
$(EXAMPLES): %: $(BIN_DIR)/%
web: $(WEB_OUTPUTS)
$(BUILD_DIR):
@@ -78,18 +102,18 @@ $(BUILD_DIR):
$(WEB_EMBED_ASSETS_C): $(WEB_EMBED_ASSET_FILES) ../scripts/embed-assets.sh ../include/embedded_assets.h | $(BUILD_DIR)
sh ../scripts/embed-assets.sh $@ ../themes
$(EXAMPLES_WEB_SITE_DIR)/%/index.html: %.c $(FONT_OUTPUTS) $(WEB_RAYLIB_A) $(FLINT_WEB_LIBOQS_A) $(WEB_EMBED_ASSETS_C) $(WEB_SHELL)
$(EXAMPLES_WEB_SITE_DIR)/%/index.html: $(CODEGEN_DIR)/%.c $(FONT_OUTPUTS) $(WEB_RAYLIB_A) $(KRYON_WEB_LIBOQS_A) $(WEB_EMBED_ASSETS_C) $(WEB_SHELL)
@echo "Building web example $*..."
@mkdir -p $(dir $@)
$(WEB_CC) $(WEB_CFLAGS) \
-I../include \
-I. -I../include -I$(CODEGEN_DIR) \
-o $(dir $@)/index.js \
$< \
$(if $(filter 01_file_dialog,$*),$(FLINT_ALL_WEB_SRCS),$(FLINT_WEB_SRCS)) \
$(if $(filter 01_file_dialog,$*),$(KRYON_ALL_WEB_SRCS),$(KRYON_WEB_SRCS)) \
$(WEB_RAYLIB_A) \
$(FLINT_WEB_LIBOQS_A) \
$(KRYON_WEB_LIBOQS_A) \
$(WEB_LDFLAGS) \
--preload-file assets/fonts@assets/fonts
$(WEB_PRELOAD_FLAGS)
perl -0pe 's#\{\{\{ SCRIPT \}\}\}#<script async src="index.js"></script>#g' $(WEB_SHELL) > $@
web-clean:
@@ -97,7 +121,6 @@ web-clean:
clean:
rm -f $(EXAMPLES)
rm -rf assets/fonts
rm -rf $(BUILD_DIR)
list:
@@ -118,6 +141,16 @@ run:
@echo " 5) color"
@echo " 6) scaling"
@echo " 7) layout"
@echo " 8) geometry"
@echo " 9) menus"
@echo " 10) basic_controls"
@echo " 11) collections"
@echo " 12) text_editor"
@echo " 13) canvas"
@echo " 14) containers"
@echo " 15) dialogs"
@echo " 16) keyboard_platform"
@echo " 17) accessibility"
@echo ""
@read -p "Enter example number: " num; \
case "$$num" in \
@@ -128,14 +161,24 @@ run:
5) example="05_color";; \
6) example="06_scaling";; \
7) example="07_layout";; \
8) example="09_geometry";; \
9) example="10_menus";; \
10) example="11_basic_controls";; \
11) example="12_collections";; \
12) example="13_text_editor";; \
13) example="14_canvas";; \
14) example="15_containers";; \
15) example="16_dialogs";; \
16) example="17_keyboard_platform";; \
17) example="18_accessibility";; \
*) example=;; \
esac; \
if [ -n "$$example" ]; then \
$(MAKE) $$example; \
if [ -f "$$example" ]; then \
$(MAKE) $(BIN_DIR)/$$example; \
if [ -f "$(BIN_DIR)/$$example" ]; then \
echo ""; \
echo "Running $$example..."; \
./$$example; \
$(BIN_DIR)/$$example; \
else \
echo "Failed to build $$example"; \
fi; \
+46 -13
View File
@@ -1,15 +1,33 @@
# Flint Examples
# Kryon Examples
This directory contains example programs demonstrating Flint library components.
This directory contains `.kry` example programs demonstrating Kryon library
components. The C files used for native and web builds are generated into
`../build/examples/codegen` and are not source files.
## Available Examples
1. **01_file_dialog** - File dialog component with theme integration
2. **02_buttons** - Button styles and click handling
3. **03_theme** - Theme switching
4. **04_modal** - Modal dialogs
5. **05_color** - Color helpers
6. **06_scaling** - UI scaling
7. **07_layout** - Existing layout helpers
8. **09_geometry** - Packed frames, grid cells, placement, separators
9. **10_menus** - Menubar and menu items
10. **11_basic_controls** - Radio, progress, spinbox, combobox, label frame
11. **12_collections** - Listbox, tree view, table view
12. **13_text_editor** - Text area plus clipboard helpers
13. **14_canvas** - Canvas clipping, grid, and hit testing
14. **15_containers** - Notebook, paned view, collapsible section
15. **16_dialogs** - Message, confirm, prompt, and color picker
16. **17_keyboard_platform** - Accelerators and clipboard
17. **18_accessibility** - Accessibility/debug node overlay
## Requirements
- Flint library must be built (`make` in parent directory)
- Include Flint with `#include "flint.h"`; Flint provides the Raylib-compatible public API surface
- Kryon library must be built (`make` in parent directory)
- Edit the `.kry` files; generated C/H in `../build/examples/codegen` is disposable
- X11 libraries (Linux): `-lGL -lm -lpthread -ldl -lrt -lX11`
## Building Examples
@@ -19,12 +37,16 @@ This directory contains example programs demonstrating Flint library components.
make
# Build specific example
make 01_file_dialog
make ../build/examples/bin/01_file_dialog
# Clean examples
make clean
```
Each build transpiles `NN_name.kry` with `kc`, writes generated C/H under
`../build/examples/codegen`, then compiles the standalone example binary under
`../build/examples/bin`.
## Running Examples
```bash
@@ -32,18 +54,29 @@ make clean
make run
# Run directly (after building)
./01_file_dialog
../build/examples/bin/01_file_dialog
```
## IDE Preview
Open this directory with Kryon:
```bash
kryon .
```
The IDE automatically discovers `.kry` screens, builds a live preview host under
`build/kryon`, and reloads when `.kry` sources change. A `project.kryon` file is
only needed for full projects that want custom build or run targets.
## Example Features
### 01_file_dialog
- Demonstrates Flint file dialog component
- Theme integration with all 6 Flint themes
- Load and save dialog modes
- Hidden files filtering (checkbox)
- Full keyboard/mouse interaction
- Direct component testing without full application
### Toolkit Examples
The toolkit examples use one direct API shape per widget: fill the struct that
describes the widget state and call the matching `DrawUI...` function. Geometry
uses `BeginUIFrameBox`, `UIFramePack`, `UIGridCell`, and `UIPlace`; canvas uses
`BeginUICanvas` / `EndUICanvas`.
## Usage
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

+1 -1
View File
@@ -1 +1 @@
#include "flint_example_font.h"
#include "kryon_example_font.h"
-34
View File
@@ -1,34 +0,0 @@
#ifndef EXAMPLE_UI_FONT_H
#define EXAMPLE_UI_FONT_H
#include "ui_text.h"
#include "flint.h"
#include <stdio.h>
static Font example_ui_font = {0};
static void
LoadExampleUIFont(void)
{
example_ui_font = LoadUIChoppedFont("assets/fonts/locales.png",
"assets/fonts/locales.dat",
UI_TEXT_BASE_SIZE);
if(example_ui_font.texture.id != 0) {
SetTextureFilter(example_ui_font.texture, TEXTURE_FILTER_POINT);
SetUIFont(example_ui_font);
SetUISmallFont(example_ui_font);
} else {
fprintf(stderr, "warning: failed to load chopped example font assets\n");
}
}
static void
UnloadExampleUIFont(void)
{
SetUIFont((Font){0});
SetUISmallFont((Font){0});
UnloadUIFont(&example_ui_font);
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef EXAMPLE_UI_FONT_H
#define EXAMPLE_UI_FONT_H
#include "ui_text.h"
#include "kryon.h"
static void
LoadExampleUIFont(void)
{
Font font = LoadUIFontAsset("../fonts/noto/NotoSans-Regular.ttf",
UI_TEXT_BASE_SIZE);
if(font.texture.id == 0)
font = LoadUIFontAsset("fonts/noto/NotoSans-Regular.ttf",
UI_TEXT_BASE_SIZE);
if(font.texture.id != 0) {
RegisterUIFont("default", font);
UseUIFont("default");
}
}
static void
UnloadExampleUIFont(void)
{
ClearUIFonts();
}
#endif
+1 -1
View File
@@ -1,4 +1,4 @@
Flint examples use chopped locale fonts.
Kryon examples use Noto font assets.
English ASCII: The quick brown fox jumps over 1234567890.
Accents: Réglages, Cvičení, Respiração, Océano.
Chinese: 设置 中文
+18
View File
@@ -0,0 +1,18 @@
#include "kryon.h"
#include <stdio.h>
#include <string.h>
int main(void) {
const char *markdown = "# Kryon\n\n- [x] packaged\n";
char *html = KryonMarkdownToHTML(markdown, strlen(markdown), KRYON_MARKDOWN_GFM);
if (!html) {
return 1;
}
int ok = strstr(html, "<h1") != NULL && strstr(html, "<input") != NULL;
if (!ok) {
fputs(html, stderr);
}
KryonMarkdownFree(html);
return ok ? 0 : 1;
}
+7
View File
@@ -0,0 +1,7 @@
#include "kryon.h"
int main(void) {
Vector2 origin = {0.0f, 0.0f};
SetTraceLogLevel(LOG_NONE);
return (int)origin.x;
}
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flint Example</title>
<title>Kryon Example</title>
<style>
html,
body {
+94
View File
@@ -0,0 +1,94 @@
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/)
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File
File renamed without changes.

Before

Width:  |  Height:  |  Size: 996 B

After

Width:  |  Height:  |  Size: 996 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 379 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 408 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1019 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Loaded 100 of 271 files, more files were not shown because too many files have changed in this diff. Show more