# ui_scrollbar.ludic — a scroll box's bar held and dragged: a press on the thumb holds it where it # was taken, the pointer held moves it in proportion, letting go leaves it; a press on the track # jumps the thumb's middle there; the wheel still scrolls; and the rows under the bar are never pressed. import "ludic.ui" import "ui_scrollbar_parts/Long.ludic" program UiScrollbar { numbers float var bx: float = 0.0 var by: float = 0.0 function frame(i: UiInput) -> UiNode { ui_input(i) ui_show("Long", null, 0.0, 0.0, 400.0, 400.0) let root: UiNode = ui_nodes("Long", null) ui_place(root, 0.0, 0.0, 400.0, 400.0) return root.children[0] } # the pointer at (bx + x, by + y), held or not; how far the box is scrolled then function at(x: float, y: float, down: bool) -> int { let i = new UiInput i.x = bx + x i.y = by + y i.down = down return int(frame(i).children[0].scroll_y) } function wheel(x: float, y: float) -> int { let i = new UiInput i.x = bx + x i.y = by + y i.wheel = 1.0 frame(i) return int(frame(new UiInput).children[0].scroll_y) } entry { ui_backend(new UiBackend) let list = frame(new UiInput).children[0] bx = list.x by = list.y let grab = at(195.0, 10.0, true) let moved = at(195.0, 40.0, true) let far = at(195.0, 300.0, true) let back = at(195.0, 25.0, true) let kept = at(195.0, 25.0, false) at(0.0 - bx - 1.0, 0.0 - by - 1.0, false) let jump = at(195.0, 80.0, true) at(195.0, 80.0, false) let wheeled = wheel(50.0, 50.0) at(50.0, 20.0, true) at(50.0, 20.0, false) let page = frame(new UiInput) print(`grab {grab} moved {moved} far {far} back {back} kept {kept} | jump {jump} | wheel {wheeled} | {page.children[1].text}`) } }