feat(ui): ludic.ui is a UI framework - input, controls, render3d backend, the CSS a game needs

A game no longer writes a host:
- The runtime reads Input itself: focus and keyboard navigation (Tab, arrows, Enter/Space,
  autofocus), the pointer (hover, :active, click on release, drag), and scroll boxes with the
  wheel, a draggable scrollbar, clipping and scroll-into-view.
- HTML's controls are built in (button, checkbox, radio, range, select, text, key capture), made
  of plain parts a stylesheet styles, each reporting with on-change and event.value.
- ludic.ui/render3d.ludic draws with render3d's overlay: textures, named atlases (icon:NAME),
  nine-slice border-image, rounded rects and rings, clipping, and a scale.
- Hooks for the program's language, sounds and clock (ui_translator, ui_sounds, ui_clock).
- ui_dev: hot reload, errors on screen, LUDIC_UI_DUMP.
- CSS:
  - colours as #rgb / #rrggbbaa / rgb() / rgba() / names;
  - border-radius and outline (following the radius), box-shadow, background-image and a tinted
    border-image;
  - group opacity, @keyframes / animation, transition;
  - :focus, :focus-visible and :focus-within.
- HTML mixed content, and boolean attributes.
- render3d gains tex_width / tex_height, and the XML reader keeps text runs in order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-24 17:26:09 +03:00
parent 20d011f8e9
commit 1dad96102a
45 changed files with 1386 additions and 218 deletions

View file

@ -1,16 +1,21 @@
# frame.ludic - a screen shown: built from the view's model, laid out, drawn, and its presses
# run once the frame is drawn, so nothing the view does can change a frame half way through it
var fr_was_down: bool = false
var fr_down_now: bool = false
export function ui_show(screen: string, view: UiView, x: float, y: float, w: float, h: float) -> void {
in_read()
dv_before()
an_frame += 1
ui_viewport(w, h)
let root = ui_nodes(screen, view)
if root == null { return }
ui_place(root, x, y, w, h)
nt_fired_clear()
sc_undo(root)
sc_update(root)
fr_pointer(root)
fc_keys(root)
if ui_be != null and ui_be.text != null { fr_draw(root) }
dv_after(screen, root)
lc_run(screen)
nt_fired_run()
}
@ -56,10 +61,11 @@ export function ui_place(root: UiNode, x: float, y: float, w: float, h: float) -
ly_vp_y = y
root.w = UI_FILL
root.h = UI_FILL
var fg = 15658734
if ui_be != null and ui_be.color != null { fg = ui_be.color("text") }
let fg = 15658734
ly_fg_a = 1.0
ly_measure(root, w, ui_px(16.0), fg)
ly_place(root, x, y, w, h)
sc_apply(root)
}
# a press, as if the pointer had made it
export function ui_press(n: UiNode) -> void {