ludic.ui, runtime: the last per-frame allocations in the interface - the top popover found without a list, the popover draw list and the clip stack kept, a select's options in a list the node keeps (and matched to its value without writing the index), a number's text kept on its Value until it changes (value_num_set / Value.num_text), a key's label kept per key code until the layout changes it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3915af34c2
commit
50f255eea4
10 changed files with 98 additions and 40 deletions
|
|
@ -67,8 +67,11 @@ function ct_build_range(ui_st: mut UiState, n: UiNode) -> void {
|
|||
push(n.children, ct_part(ui_st, n, "ui-value", ct_value_text(n)))
|
||||
}
|
||||
function ct_build_select(ui_st: mut UiState, n: UiNode) -> void {
|
||||
let opts = n.children
|
||||
n.children = new []UiNode
|
||||
if n.opts == null { n.opts = new []UiNode } # its options moved to a list the node keeps, not a new one
|
||||
let opts = n.opts
|
||||
List.clear(opts)
|
||||
for i in 0 .. len(n.children) { push(opts, n.children[i]) }
|
||||
List.clear(n.children)
|
||||
ct_label(ui_st, n)
|
||||
var shown = ""
|
||||
let at = ct_option_at(n, opts)
|
||||
|
|
@ -76,14 +79,13 @@ function ct_build_select(ui_st: mut UiState, n: UiNode) -> void {
|
|||
push(n.children, ct_part(ui_st, n, "ui-prev", "<"))
|
||||
push(n.children, ct_part(ui_st, n, "ui-value", shown))
|
||||
push(n.children, ct_part(ui_st, n, "ui-next", ">"))
|
||||
n.opts = opts
|
||||
}
|
||||
# which option the select's value names: an option's value="...", else its place
|
||||
function ct_option_at(n: UiNode, opts: []UiNode) -> int {
|
||||
let v = ui_attr_text(n, "value")
|
||||
for i in 0 .. len(opts) {
|
||||
let ov = ui_attr_text(opts[i], "value")
|
||||
if ov == v or (ov == "" and string(i) == v) { return i }
|
||||
if ov == v or (ov == "" and ct_is_int(v, i)) { return i }
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue