feat(ui): number and key fields, notes, anchored popovers, text-shadow, and pictures as painted

- <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>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-24 19:55:20 +03:00
parent 7d8f34de17
commit 9f59000f5b
39 changed files with 732 additions and 75 deletions

View file

@ -0,0 +1,53 @@
# controls_key.ludic - <input type="key">, a key binding: Enter or a click starts listening, and then
# the next key pressed is its value - Tab, the arrows and Enter included, which move nothing while it
# listens. Esc stops listening and keeps the value; Backspace, when it is not listening, clears it (0).
# `shown` is what it says for its value (a host's own name for the key), else the keyboard's label.
var ct_capture: string = ""
var ct_capture_at: int = -1 # the frame listening began, whose own key started it
var ct_capture_seen: int = -1 # the last frame that began listening, for ui_capturing
function ct_key_start(n: UiNode) -> void {
ct_capture = n.key
ct_capture_at = an_frame
ct_capture_seen = an_frame
}
# while it listens, the frame's keys are the field's: nothing else reads them (fc_keys)
function ct_key_listening() -> bool { return ct_capture != "" and ct_capture_at != an_frame }
# the field listening, given this frame's key; false when there is none to give it to
function ct_key_capture(list: []UiNode) -> bool {
if ct_capture == "" { return false }
ct_capture_seen = an_frame
var n: UiNode = null
for i in 0 .. len(list) {
if list[i].key == ct_capture { n = list[i] }
}
if n == null {
ct_capture = ""
return false
}
if ct_capture_at == an_frame { return true }
if in_now.escape {
ct_capture = ""
return true
}
if in_now.key != 0 {
ct_capture = ""
ct_change(n, Value.int(in_now.key))
}
return true
}
# focused, not listening: Backspace unbinds it
function ct_key_typed(n: UiNode) -> void {
if ct_capture != n.key and in_now.backspace { ct_change(n, Value.int(0)) }
}
# a press anywhere but the field stops it listening
function ct_key_pressed_away(hit: UiNode) -> void {
if ct_capture != "" and (hit == null or hit.key != ct_capture) { ct_capture = "" }
}
function ct_key_text(n: UiNode) -> string {
if ct_capture == n.key { return ui_tr("press a key...") }
if Value.kind(ui_attr(n, "shown")) != 0 { return ui_tr(ui_attr_text(n, "shown")) }
return Input.key_label(Value.as_int(ui_attr(n, "value")))
}
# a key field is listening: the host should leave the keys alone until it is done (it stays true
# for the frame in which Esc or a key ended it, so that key is not read twice)
export function ui_capturing() -> bool { return ct_capture != "" or ct_capture_seen == an_frame }