# 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= 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) } }