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,6 +1,8 @@
|
|||
# layout_run.ludic - a box's children given their places: along its direction by size, grow and
|
||||
# justify, across it by align (or each child's own `self`), a wrapping row one line at a time
|
||||
function ly_place(ui_st: mut UiState, n: UiNode, x: float, y: float, w: float, h: float) -> void {
|
||||
var ly_lead: float = 0.0
|
||||
var ly_extra: float = 0.0
|
||||
function ly_place(n: UiNode, x: float, y: float, w: float, h: float) -> void {
|
||||
n.x = x
|
||||
n.y = y
|
||||
n.cw = w
|
||||
|
|
@ -10,9 +12,9 @@ function ly_place(ui_st: mut UiState, n: UiNode, x: float, y: float, w: float, h
|
|||
var inner_h = h - ly_vin(n)
|
||||
if n.kind == UI_SCROLL { inner_h = Math.max(n.content_h, h) - ly_vin(n) }
|
||||
let top = n.y + n.pt + n.bt
|
||||
if n.dir == UI_ROW and n.wrap { ly_place_wrap(ui_st, n, top, inner_w) } else if n.dir == UI_ROW { ly_place_line(ui_st, n, 0, len(n.children), top, inner_w, inner_h) } else { ly_place_line(ui_st, n, 0, len(n.children), top, inner_h, inner_w) }
|
||||
if n.dir == UI_ROW and n.wrap { ly_place_wrap(n, top, inner_w) } else if n.dir == UI_ROW { ly_place_line(n, 0, len(n.children), top, inner_w, inner_h) } else { ly_place_line(n, 0, len(n.children), top, inner_h, inner_w) }
|
||||
for i in 0 .. len(n.children) {
|
||||
if n.children[i].pos >= 2 { ly_place_abs(ui_st, n, n.children[i]) }
|
||||
if n.children[i].pos >= 2 { ly_place_abs(n, n.children[i]) }
|
||||
}
|
||||
}
|
||||
function ly_fills(c: UiNode, dir: int) -> bool {
|
||||
|
|
@ -37,7 +39,7 @@ function ly_stretches(n: UiNode, c: UiNode) -> bool {
|
|||
return a == UI_STRETCH
|
||||
}
|
||||
# children from..to along one line starting at `top`: sizes, the spare room, then each place
|
||||
function ly_place_line(ui_st: mut UiState, n: UiNode, from: int, to: int, top: float, main_room: float, cross_room: float) -> void {
|
||||
function ly_place_line(n: UiNode, from: int, to: int, top: float, main_room: float, cross_room: float) -> void {
|
||||
var used = 0.0
|
||||
var grows = 0.0
|
||||
var count = 0
|
||||
|
|
@ -53,21 +55,21 @@ function ly_place_line(ui_st: mut UiState, n: UiNode, from: int, to: int, top: f
|
|||
used = used + n.gap * float(Math.max(count - 1, 0))
|
||||
let free = main_room - used
|
||||
if free < 0.0 { ly_shrink_line(n, from, sizes, 0.0 - free) }
|
||||
ly_justify(ui_st, n, free, count, grows)
|
||||
let extra = ui_st.ly_extra
|
||||
var at = ui_st.ly_lead
|
||||
ly_justify(n, free, count, grows)
|
||||
let extra = ly_extra
|
||||
var at = ly_lead
|
||||
for i in from .. to {
|
||||
let c = n.children[i]
|
||||
if c.pos >= 2 { continue }
|
||||
var m = sizes[i - from]
|
||||
if grows > 0.0 and free > 0.0 { m = m + free * ly_grow(c, n.dir) / grows }
|
||||
ly_place_child(ui_st, n, c, at, top, m, cross_room)
|
||||
ly_place_child(n, c, at, top, m, cross_room)
|
||||
if c.pos == 1 { ly_nudge(n, c) }
|
||||
at = at + m + n.gap + extra
|
||||
}
|
||||
}
|
||||
# one child: `m` along the run and its own size (or the whole room, stretched) across, less margins
|
||||
function ly_place_child(ui_st: mut UiState, n: UiNode, c: UiNode, at: float, top: float, m: float, cross_room: float) -> void {
|
||||
function ly_place_child(n: UiNode, c: UiNode, at: float, top: float, m: float, cross_room: float) -> void {
|
||||
var cr = ly_cross(c, n.dir)
|
||||
if n.dir == UI_ROW and c.h_pct > 0.0 { cr = ly_ph(c, cross_room) + c.mt + c.mb }
|
||||
if n.dir == UI_COL and c.w_pct > 0.0 { cr = ly_pw(c, cross_room) + c.ml + c.mr }
|
||||
|
|
@ -80,9 +82,9 @@ function ly_place_child(ui_st: mut UiState, n: UiNode, c: UiNode, at: float, top
|
|||
let left = n.x + n.pl + n.bl
|
||||
if n.dir == UI_ROW {
|
||||
let cw = ly_clamp(m - c.ml - c.mr, c.min_w, c.max_w)
|
||||
ly_place(ui_st, c, left + at + c.ml, top + off + c.mt, cw, ly_clamp(cr - c.mt - c.mb, c.min_h, c.max_h))
|
||||
ly_place(c, left + at + c.ml, top + off + c.mt, cw, ly_clamp(cr - c.mt - c.mb, c.min_h, c.max_h))
|
||||
} else {
|
||||
let chh = ly_clamp(m - c.mt - c.mb, c.min_h, c.max_h)
|
||||
ly_place(ui_st, c, left + off + c.ml, top + at + c.mt, ly_clamp(cr - c.ml - c.mr, c.min_w, c.max_w), chh)
|
||||
ly_place(c, left + off + c.ml, top + at + c.mt, ly_clamp(cr - c.ml - c.mr, c.min_w, c.max_w), chh)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue