ludic/examples/library/ui_popover_align.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

20 lines
1 KiB
Text

# ui_popover_align.ludic — anchored popovers aligned along their side (start, center, end), kept
# within a named container (within="panel") and, by default, within the scroll box they are in,
# flipping to the other side against it rather than against the screen.
import "ludic.ui"
import "ui_popover_align_parts/Menus.ludic"
program UiPopoverAlign {
numbers float
function at(n: UiNode, base: UiNode) -> string { return `{int(n.x - base.x)},{int(n.y - base.y)}` }
entry (ui_st: mut UiState) {
ui_backend(ui_st, new UiBackend)
ui_show(ui_st, "Menus", null, 0.0, 0.0, 400.0, 400.0)
let root: UiNode = ui_nodes(ui_st, "Menus", null)
ui_place(ui_st, root, 0.0, 0.0, 400.0, 400.0)
let panel = root.children[0].children[0]
let list = root.children[0].children[1]
let b = list.children[1]
let p3 = list.children[2]
print(`centred, flipped in the panel {at(panel.children[1], panel)} | end below {at(panel.children[2], panel)} | above b in the list {int(p3.y + p3.ch - b.y)} inside {p3.y >= list.y}`)
}
}