ludic.ui: nothing a frame on the pack screen - a key's down/up carry one kept null, scroll asks filtered in place, a shadow's colour joined through the memo, numbers to 65536 made once each

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:22:21 +03:00
parent 8dfcccad41
commit 0f534731a6
5 changed files with 24 additions and 14 deletions

View file

@ -55,7 +55,7 @@ function el_shadow(ui_st: mut UiState, n: UiNode, s: string) -> void {
if nums == 0 { n.sh_x = el_unit(ui_st, p) }
if nums == 1 { n.sh_y = el_unit(ui_st, p) }
nums += 1
} else if col == "" { col = p } else { col = col + " " + p }
} else if col == "" { col = p } else { col = mm_join(ui_st, col, " ", p) }
}
if col == "" { col = "rgba(0,0,0,0.5)" }
n.sh_c = ui_color(ui_st, col)

View file

@ -39,6 +39,7 @@ export state UiState {
uv_false: Val = null
mm: UiMemo = null # memo.ludic: splits, gradients and keys by their text
mm_ints: []string = null
fc_none: Val = Value.null() # focus.ludic: the value a key's down and up carry, made once
mm_ivals: []Val = null
ev_depth: int = 0 # eval.ludic: a call's arguments, in lists kept one a depth
ev_args: []Val = new []Val

View file

@ -49,12 +49,12 @@ function fc_keys(ui_st: mut UiState, root: UiNode) -> void {
function fc_hold(ui_st: mut UiState, root: UiNode, n: UiNode) -> void {
if ui_st.fr_key_press != "" and (ui_st.in_act_up or n.key != ui_st.fr_key_press) {
let was = fr_node(root, ui_st.fr_key_press)
if was != null { ui_fire(ui_st, was, "up", Value.null()) }
if was != null { ui_fire(ui_st, was, "up", ui_st.fc_none) }
ui_st.fr_key_press = ""
}
if ui_st.in_act_down and n.enabled {
ui_st.fr_key_press = n.key
ui_fire(ui_st, n, "down", Value.null())
ui_fire(ui_st, n, "down", ui_st.fc_none)
}
}
export function ui_focus(ui_st: mut UiState, key: string) -> void {

View file

@ -36,14 +36,19 @@ function mm_join(ui_st: mut UiState, a: string, sep: string, b: string) -> strin
m.slots[at] = len(m.keys)
return k
}
# a small whole number's text, made once (a key's index, a loop's count)
# a whole number's text, made once (a key's index, a count, money): 0..1023 at the start, the rest up
# to MM_INT_MOST the first time each is shown; only past that is one made per call
const MM_INT_MOST: int = 65536
function mm_int(ui_st: mut UiState, i: int) -> string {
if i < 0 or i >= 1024 { return string(i) }
if i < 0 or i >= MM_INT_MOST { return string(i) }
if ui_st.mm_ints == null {
ui_st.mm_ints = new []string
for k in 0 .. 1024 { push(ui_st.mm_ints, string(k)) }
}
return ui_st.mm_ints[i]
let l = ui_st.mm_ints
while len(l) <= i { push(l, "") }
if i >= 1024 and len(l[i]) == 0 { l[i] = string(i) }
return l[i]
}
# a small whole number as a Value, made once and shared: read it, never change it (a loop's index)
function mm_ival(ui_st: mut UiState, i: int) -> Val {

View file

@ -10,16 +10,20 @@ export function ui_scroll_set(ui_st: mut UiState, key: string, px: float) -> voi
function sc_held(ui_st: mut UiState, n: UiNode, off: float, live: bool) -> float {
var at = off
if live {
let keys = new []string
let pxs = new []float
for i in 0 .. len(ui_st.sc_want_keys) {
if ui_st.sc_want_keys[i] == n.key or (n.id != "" and ui_st.sc_want_keys[i] == n.id) { at = ui_px(ui_st, ui_st.sc_want_px[i]) } else {
push(keys, ui_st.sc_want_keys[i])
push(pxs, ui_st.sc_want_px[i])
let keys = ui_st.sc_want_keys # the asks for this box taken out in place, the others kept
let pxs = ui_st.sc_want_px
var kept = 0
for i in 0 .. len(keys) {
if keys[i] == n.key or (n.id != "" and keys[i] == n.id) { at = ui_px(ui_st, pxs[i]) } else {
keys[kept] = keys[i]
pxs[kept] = pxs[i]
kept += 1
}
}
ui_st.sc_want_keys = keys
ui_st.sc_want_px = pxs
while len(keys) > kept {
List.pop(keys)
List.pop(pxs)
}
}
let v = ui_attr(n, "scroll-top")
if Value.kind(v) != 0 { at = ui_px(ui_st, el_numv(ui_st, v)) }