ludic/packages/ludic.ui/dev.ludic
Orkuncakilkaya 19fcf60599 wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:31:34 +03:00

21 lines
1.2 KiB
Text

# dev.ludic - a developer's build: templates and stylesheets read again when they change (once a
# second), template errors drawn over the screen, and LUDIC_UI_DUMP=<screen> printing that screen's
# tree once, with every element's box and computed style
export function ui_dev(ui_st: mut UiState, on: bool) -> void { ui_st.dv_on = on }
function dv_before(ui_st: mut UiState) -> void {
if not ui_st.dv_on { return }
ui_st.dv_frames += 1
if ui_st.dv_frames % 60 == 0 { ui_reload(ui_st) }
}
function dv_after(ui_st: mut UiState, screen: string, root: UiNode) -> void {
if not ui_st.dv_on { return }
if not ui_st.dv_dumped and Os.has_env("LUDIC_UI_DUMP") and Os.env("LUDIC_UI_DUMP") == screen {
ui_st.dv_dumped = true
print(ui_dump(root, 0))
}
if len(ui_st.ui_errs) == 0 or ui_st.ui_be == null or ui_st.ui_be.rect == null { return }
let n = Math.min(len(ui_st.ui_errs), 8)
let line = ui_px(ui_st, 26.0)
ui_st.ui_be.rect(0.0, 0.0, 4000.0, line * float(n) + ui_px(ui_st, 8.0), 4194304, 0.85)
for i in 0 .. n { ui_st.ui_be.text(ui_px(ui_st, 12.0), ui_px(ui_st, 6.0) + line * float(i), ui_st.ui_errs[len(ui_st.ui_errs) - n + i], ui_px(ui_st, 18.0), 16767449, 1.0) }
}