- <input type="number" min max step>: typed digits replace its value (a minus when min allows one, a point when step has a fraction), Enter or leaving the field commits them held between min and max, the left and right arrows step it. - <input type="key">: Enter or a click starts it listening and the next key is its value, Tab, the arrows and Enter included; Esc stops it listening, Backspace clears it, `shown` names the value, and ui_capturing() tells the host to leave its keys alone (through the frame that ended it). - note="..." under any control's label (.ui-labels > .ui-label + .ui-note); a range's (or number's) value with decimals, format="percent" and a unit. - A popover with `anchor="id"` (the nearest element of that id) or a bare `anchor` (the element before it) sits beside it by `placement` (right, left, bottom, top), its margin the gap, opens to the other side where it would leave the screen, and is kept on it. - A tooltip's title splits into lines at a newline or a written \n. - text-shadow, inherited, drawn sharp under the text. - ui_opacity(): the group opacity a native's draw is at. - border-image is drawn as painted with no background colour, tinted by one, and not at all when that colour is transparent (it drew a white nine-slice). - A picture file is drawn untinted, as a browser draws one; an atlas cell (prefix:name) still takes the color around it, and an <img> with its own color is tinted by it. - The render3d backend loads a picture again when its file changes or appears (a failed load was kept for ever), and at once after ui_image_reload(path); takes a path with a drive letter (C:/...) as a path rather than an atlas; and slices a nine-slice by its texture's own width and height. - ui_inputs.ludic and ui_look.ludic; LANGUAGE.md and the changeset say all of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
2.5 KiB
Text
80 lines
2.5 KiB
Text
# 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
|
|
|
|
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)
|
|
pp_draw_top()
|
|
tt_draw(root)
|
|
}
|
|
dv_after(screen, root)
|
|
lc_run(screen)
|
|
nt_fired_run()
|
|
}
|
|
# the screen's nodes for this frame, not yet laid out - for a test, or a host that places them
|
|
export function ui_nodes(screen: string, view: UiView) -> UiNode {
|
|
let si = lib_find(lib_screen_names, screen)
|
|
let cls = uc_find(screen)
|
|
if si < 0 and cls != null { return fr_class_nodes(cls) }
|
|
if si < 0 {
|
|
ui_err(`there is no screen {screen} - ui_load the file that has it`)
|
|
return null
|
|
}
|
|
let t = lib_screens[si]
|
|
lc_begin()
|
|
ui_view = view
|
|
let e = env_new(null)
|
|
if view != null and view.model != null { e.model = view.model() } else { e.model = Value.object() }
|
|
e.state = st_for(screen, t, e)
|
|
let root = new UiNode
|
|
root.key = screen
|
|
root.children = new []UiNode
|
|
root.env = e
|
|
root.sheet = t.sheet
|
|
root.classes = new []string
|
|
root.akeys = new []string
|
|
root.avals = new []string
|
|
root.vals = new []Val
|
|
root.tag = "screen"
|
|
for i in 0 .. len(t.keys) {
|
|
if t.keys[i] != "name" { el_keep(root, t.keys[i], ui_eval(t.vals[i], e)) }
|
|
}
|
|
bd_kids(t.kids, e, screen, root.children)
|
|
cs_tree(root)
|
|
return root
|
|
}
|
|
# the room vw, vh and @media measure against; ui_show sets it to the screen's rectangle
|
|
export function ui_viewport(w: float, h: float) -> void {
|
|
ly_vp_w = w
|
|
ly_vp_h = h
|
|
}
|
|
export function ui_place(root: UiNode, x: float, y: float, w: float, h: float) -> void {
|
|
ly_vp_x = x
|
|
ly_vp_y = y
|
|
root.w = UI_FILL
|
|
root.h = UI_FILL
|
|
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)
|
|
pp_anchor_all(root)
|
|
}
|
|
# a press, as if the pointer had made it
|
|
export function ui_press(n: UiNode) -> void {
|
|
if n.act != null and n.enabled { act_run(n.act, n.env) }
|
|
}
|
|
# any event, as if the element had fired it - for a test
|
|
export function ui_event(n: UiNode, name: string, value: Val) -> void { nt_run(n, name, value) }
|