wip(0.S3): packages and examples migrated in one run - ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:02:45 +03:00
parent d490d4f9f1
commit 3eda72e8c2
172 changed files with 3094 additions and 2966 deletions

View file

@ -1,26 +1,26 @@
# attr_more.ludic - width and height (where 0 is 0 and calc() may hold a percentage), the flex
# shorthand, flex-shrink, order, text-shadow, pointer-events, text-fit and line-height (text_fit.ludic)
function el_more(n: UiNode, key: string, v: Val) -> bool {
function el_more(ui_st: mut UiState, n: UiNode, key: string, v: Val) -> bool {
let s = vl_text(v)
if key == "shrink" { nx(n).shrink = Math.max(el_num(s), 0.0) } else if key == "order" { nx(n).order = int(el_num(s)) } else if key == "text-shadow" { el_text_shadow(n, s) } else if key == "pointer-events" { nx(n).no_pointer = tpl_words(s) == "none" } else if key == "text-fit" { el_text_fit(n, s) } else if key == "line-height" { el_line_h(n, s) } else { return el_fit_props(n, key, s) }
if key == "shrink" { nx(n).shrink = Math.max(el_num(s), 0.0) } else if key == "order" { nx(n).order = int(el_num(s)) } else if key == "text-shadow" { el_text_shadow(ui_st, n, s) } else if key == "pointer-events" { nx(n).no_pointer = tpl_words(s) == "none" } else if key == "text-fit" { el_text_fit(ui_st, n, s) } else if key == "line-height" { el_line_h(ui_st, n, s) } else { return el_fit_props(ui_st, n, key, s) }
return true
}
# width or height: a length (0 included), fill, a percentage, calc(), or auto/fit (none)
function el_dim(n: UiNode, wide: bool, v: Val) -> void {
function el_dim(ui_st: mut UiState, n: UiNode, wide: bool, v: Val) -> void {
let s = vl_text(v)
var fixed = UI_AUTO
var pct = 0.0
var off = 0.0
if ca_is(s) {
if ca_eval(s) {
pct = ca_pct
off = ca_px
if pct <= 0.0 { fixed = Math.max(ca_px, 0.0) }
if ca_eval(ui_st, s) {
pct = ui_st.ca_pct
off = ui_st.ca_px
if pct <= 0.0 { fixed = Math.max(ui_st.ca_px, 0.0) }
}
} else if s == "fill" { fixed = UI_FILL } else if len(s) > 1 and s[len(s) - 1] == 37 {
pct = el_num(s)
if pct <= 0.0 { fixed = 0.0 }
} else if s != "auto" and s != "fit" and s != "" { fixed = el_len(v) }
} else if s != "auto" and s != "fit" and s != "" { fixed = el_len(ui_st, v) }
if pct <= 0.0 { off = 0.0 }
if n.ex != null or off != 0.0 {
if wide { nx(n).w_off = off } else { nx(n).h_off = off }
@ -34,10 +34,10 @@ function el_dim(n: UiNode, wide: bool, v: Val) -> void {
}
}
# a length out of calc(); a percentage has nothing to be a share of here
function el_calc_len(s: string) -> float {
if not ca_eval(s) { return 0.0 }
if ca_pct != 0.0 { ui_err(`{el_key}: {s} - a percentage in calc() is for a width or a height`) }
return ca_px
function el_calc_len(ui_st: mut UiState, s: string) -> float {
if not ca_eval(ui_st, s) { return 0.0 }
if ui_st.ca_pct != 0.0 { ui_err(ui_st, `{ui_st.el_key}: {s} - a percentage in calc() is for a width or a height`) }
return ui_st.ca_px
}
# flex: 1 | flex: 1 0 | flex: 2 1 auto | flex: none - the grow, then the shrink
function el_flex_short(n: UiNode, s: string) -> void {
@ -67,7 +67,7 @@ function el_words(s: string) -> []string {
return out
}
# text-shadow: 1px 2px 3px rgba(0, 0, 0, 0.6) - x, y, a blur drawn sharp, the colour; or none
function el_text_shadow(n: UiNode, s: string) -> void {
function el_text_shadow(ui_st: mut UiState, n: UiNode, s: string) -> void {
let x = nx(n)
x.tsh_set = true
x.tsh_c = -2
@ -78,17 +78,17 @@ function el_text_shadow(n: UiNode, s: string) -> void {
for i in 0 .. len(parts) {
let p = parts[i]
if col == "" and ((p[0] >= 48 and p[0] <= 57) or p[0] == 45 or p[0] == 46) {
if nums == 0 { x.tsh_x = el_unit(p) }
if nums == 1 { x.tsh_y = el_unit(p) }
if nums == 0 { x.tsh_x = el_unit(ui_st, p) }
if nums == 1 { x.tsh_y = el_unit(ui_st, p) }
nums += 1
} else if col == "" { col = p } else { col = col + " " + p }
}
if col == "" { col = "rgba(0,0,0,0.6)" }
x.tsh_c = ui_color(col)
x.tsh_a = cl_alpha
x.tsh_c = ui_color(ui_st, col)
x.tsh_a = ui_st.cl_alpha
}
# one word of a list of lengths (padding: calc(1em / 4) 2px)
function el_word_len(w: string) -> float {
if ca_is(w) { return el_calc_len(w) }
return el_unit(w)
function el_word_len(ui_st: mut UiState, w: string) -> float {
if ca_is(w) { return el_calc_len(ui_st, w) }
return el_unit(ui_st, w)
}