ludic.ui: ui_attr's miss is the node's own kept null (made with the pooled node), not a new one per ask - every control asking min/max/step/value per frame made one; a select's options without a value matched by index without asking
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2b02c0a931
commit
1786e144bb
3 changed files with 7 additions and 2 deletions
|
|
@ -105,6 +105,10 @@ function ct_numeric(v: Val) -> bool { return Value.kind(v) == 1 or Value.kind(v)
|
|||
function ct_option_num(nv: Val, opts: []UiNode) -> int {
|
||||
let x = Value.as_float(nv)
|
||||
for i in 0 .. len(opts) {
|
||||
if not ui_attr_has(opts[i], "value") {
|
||||
if x == float(i) { return i }
|
||||
continue
|
||||
}
|
||||
let ov = ui_attr(opts[i], "value")
|
||||
if Value.kind(ov) == 0 and x == float(i) { return i }
|
||||
if ct_numeric(ov) and Value.as_float(ov) == x { return i }
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ function nt_run(ui_st: mut UiState, n: UiNode, name: string, value: Val) -> void
|
|||
}
|
||||
# an attribute of an element, as the template gave it (null when it has none) - for a native
|
||||
export function ui_attr(n: UiNode, key: string) -> Val {
|
||||
if n.akeys == null { return Value.null() }
|
||||
if n.akeys == null { return n.none }
|
||||
for i in 0 .. len(n.akeys) {
|
||||
if n.akeys[i] == key { return n.vals[i] }
|
||||
}
|
||||
return Value.null()
|
||||
return n.none
|
||||
}
|
||||
# whether an element has the attribute at all: ui_attr's miss is a new null, so a question asked
|
||||
# every frame asks this first
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ export property UiNode {
|
|||
nowrap: bool = false # white-space: nowrap
|
||||
ellipsis: bool = false # text-overflow: ellipsis
|
||||
lines: []string = null # a wrapped text's lines
|
||||
none: Val = Value.null() # what ui_attr answers for an attribute it lacks: made with the node, read only
|
||||
var_names: []string = null # its custom properties (--name), which its descendants inherit
|
||||
var_vals: []string = null
|
||||
fg: int = -1 # a colour is 0xRRGGBB with its alpha beside it; -1 inherits
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue