Commit Graph
9 Commits
Author SHA1 Message Date
waozi c9b8e27e4c Canonicalize widget API 2026-08-09 19:52:01 -03:00
waozi 0d360a0160 clean kryon app api 2026-08-09 12:44:52 -03:00
waozi d07078d2b2 Move UI runtime to declarative nodes 2026-08-06 07:15:55 -03: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 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 bd4a4b1948 Make Kry C imports explicit 2026-07-21 19:26:09 -03:00
waozi 6a79813efa Build out Kryon IDE workflow 2026-07-20 23:14:07 -03:00