wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -1,12 +1,13 @@
|
|||
# text_fit.ludic - text-fit: shrink 12px draws a line that does not fit its box smaller, down to that
|
||||
# size, and cuts what still does not fit with an ellipsis; line-height (a multiple of the font size,
|
||||
# px or em) spaces a text's lines. Both are inherited, as font properties are.
|
||||
function el_text_fit(ui_st: UiState, n: UiNode, s: string) -> void {
|
||||
var tf_size: float = 0.0 # the size tf_fit drew at
|
||||
function el_text_fit(n: UiNode, s: string) -> void {
|
||||
let parts = lss_split(tpl_words(s), 32)
|
||||
nx(n).fit_min = 0.0
|
||||
if len(parts) >= 2 and parts[0] == "shrink" { nx(n).fit_min = Math.max(el_unit(ui_st, parts[1]), 1.0) }
|
||||
if len(parts) >= 2 and parts[0] == "shrink" { nx(n).fit_min = Math.max(el_unit(parts[1]), 1.0) }
|
||||
}
|
||||
function el_line_h(ui_st: UiState, n: UiNode, s0: string) -> void {
|
||||
function el_line_h(n: UiNode, s0: string) -> void {
|
||||
let s = tpl_words(s0)
|
||||
let x = nx(n)
|
||||
x.lh_kind = 0
|
||||
|
|
@ -18,7 +19,7 @@ function el_line_h(ui_st: UiState, n: UiNode, s0: string) -> void {
|
|||
return
|
||||
}
|
||||
x.lh_kind = 2
|
||||
x.lh_v = el_unit(ui_st, s)
|
||||
x.lh_v = el_unit(s)
|
||||
}
|
||||
# the nearest element, out from this one, that says `what` (0 text-fit, 1 line-height), or null
|
||||
function tf_up(n: UiNode, what: int) -> UiNodeX {
|
||||
|
|
@ -38,14 +39,14 @@ function ly_line_h(n: UiNode) -> float {
|
|||
}
|
||||
# one line to fit its box: at its own size if it does, else smaller down to text-fit's least, then
|
||||
# cut; tf_size says the size it is drawn at
|
||||
function tf_fit(ui_st: mut UiState, n: UiNode, s: string) -> string {
|
||||
ui_st.tf_size = n.rsize
|
||||
function tf_fit(n: UiNode, s: string) -> string {
|
||||
tf_size = n.rsize
|
||||
let x = tf_up(n, 0)
|
||||
let room = n.cw - ly_hin(n)
|
||||
if x == null or room <= 0.0 { return s }
|
||||
let w = ly_text_w(ui_st, s, ui_st.tf_size)
|
||||
let w = ly_text_w(s, tf_size)
|
||||
if w <= room { return s }
|
||||
ui_st.tf_size = Math.max(x.fit_min, n.rsize * room / w)
|
||||
while ui_st.tf_size > x.fit_min and ly_text_w(ui_st, s, ui_st.tf_size) > room { ui_st.tf_size = Math.max(x.fit_min, ui_st.tf_size - 0.5) }
|
||||
return ly_ellipsis(ui_st, s, ui_st.tf_size, room)
|
||||
tf_size = Math.max(x.fit_min, n.rsize * room / w)
|
||||
while tf_size > x.fit_min and ly_text_w(s, tf_size) > room { tf_size = Math.max(x.fit_min, tf_size - 0.5) }
|
||||
return ly_ellipsis(s, tf_size, room)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue