feat(ui): ui_scale and ui_box, on-submit, zoom (and a length over a length in calc), on-hold
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d2a103dfb
commit
ec9a650e65
24 changed files with 323 additions and 23 deletions
21
examples/library/ui_zoom.ludic
Normal file
21
examples/library/ui_zoom.ludic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# ui_zoom.ludic — zoom scales an element and everything inside it: its lengths, its text and its
|
||||
# layout, and zooms multiply; zoom takes calc() and min(), with a length over a length a plain number,
|
||||
# so a HUD can shrink to a narrow window (zoom: min(1, calc(100vw / 800px))).
|
||||
import "ludic.ui"
|
||||
program UiZoom {
|
||||
numbers float
|
||||
const STYLE: string = "<style>.box { width: 100px; padding: 10px }\n.half { zoom: 0.5 }\n.twice { zoom: 200% }\n.fit { zoom: min(1, calc(100vw / 800px)) }\np { height: 20px }\n.em { width: 2em }</style>"
|
||||
const BODY: string = "<screen name='z'><div class='box'><p>a</p></div><div class='box half'><p>b</p><div class='twice'><div class='box'/></div></div><div class='fit'><div class='box'/><div class='em'/></div></screen>"
|
||||
entry {
|
||||
ui_backend(new UiBackend)
|
||||
ui_load_text("<ui>" + STYLE + BODY + "</ui>", "z.xml")
|
||||
ui_show("z", null, 0.0, 0.0, 400.0, 600.0)
|
||||
let r: UiNode = ui_nodes("z", null)
|
||||
ui_place(r, 0.0, 0.0, 400.0, 600.0)
|
||||
let plain = r.children[0]
|
||||
let half = r.children[1]
|
||||
let inner = half.children[1].children[0]
|
||||
let fit = r.children[2]
|
||||
print(`plain {int(plain.cw)} pad {int(plain.pt)} text {int(plain.children[0].rsize)} h {int(plain.children[0].ch)} | half {int(half.cw)} pad {int(half.pt)} text {int(half.children[0].rsize)} h {int(half.children[0].ch)} | half of twice {int(inner.cw)} | fit {int(fit.children[0].cw)} em {int(fit.children[1].cw)}`)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue