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>
50 lines
2 KiB
Text
50 lines
2 KiB
Text
# link.ludic - each tag in a file that is not an element names a component: the file's own, an
|
|
# unnamed import's exported one, or `as:Name` from the import called `as`
|
|
const LK_OWN: string = " row button input select textarea spacer scroll img hr if else each slot state style component screen import let fragment template provide #text "
|
|
function lib_link(f: UiFile, t: UiTpl) -> void {
|
|
t.sheet = f.sheet
|
|
if not lk_element(t.tag) {
|
|
t.comp = lk_find(f, t.tag, false)
|
|
if t.comp == null { t.cls = uc_find(t.tag) }
|
|
if t.cls != null {
|
|
lk_kids(f, t)
|
|
return
|
|
}
|
|
if t.comp == null and lk_find(f, t.tag, true) != null { ui_err(`{t.where}: <{t.tag}>: that component is not exported - export="true" on it lets other files use it`) } else if t.comp == null { ui_err(`{t.where}: <{t.tag}>: there is no such element, and no component of that name here or exported by an import`) }
|
|
}
|
|
lk_kids(f, t)
|
|
}
|
|
function lk_kids(f: UiFile, t: UiTpl) -> void {
|
|
for i in 0 .. len(t.kids) { lib_link(f, t.kids[i]) }
|
|
}
|
|
function lk_element(tag: string) -> bool { return lk_in(LK_OWN, tag) or lk_in(EL_BOXES, tag) or lk_in(EL_TEXTS, tag) or nt_find(tag) != null }
|
|
# a word in a list of words written " a b c "
|
|
function lk_in(words: string, w: string) -> bool {
|
|
let pat = ` {w} `
|
|
let n = len(pat)
|
|
for i in 0 .. len(words) - n + 1 {
|
|
if words[i..i + n] == pat { return true }
|
|
}
|
|
return false
|
|
}
|
|
# `any` finds an unexported one too, to say why it cannot be used
|
|
function lk_find(f: UiFile, tag: string, any: bool) -> UiTpl {
|
|
var colon = -1
|
|
for i in 0 .. len(tag) {
|
|
if tag[i] == 58 { colon = i }
|
|
}
|
|
if colon < 0 {
|
|
let own = lib_find(f.names, tag)
|
|
if own >= 0 { return f.comps[own] }
|
|
}
|
|
for i in 0 .. len(f.imp) {
|
|
var want = tag
|
|
if colon >= 0 {
|
|
if f.imp_as[i] != tag[0..colon] { continue }
|
|
want = tag[colon + 1..len(tag)]
|
|
} else if f.imp_as[i] != "" { continue }
|
|
let at = lib_find(f.imp[i].names, want)
|
|
if at >= 0 and (any or f.imp[i].exported[at]) { return f.imp[i].comps[at] }
|
|
}
|
|
return null
|
|
}
|