- the scrollbar is .ui-scrollbar with a .ui-thumb, styled by the default sheet or a theme; a press on the thumb holds it at the point it was taken and the pointer moves it in proportion, a press on the track jumps the thumb's middle there and holds it, and neither presses what is under the bar (it used to centre the thumb on the pointer and press the row beneath as well); - while a popover is up only scroll boxes inside it take the pointer, and a press outside it that closes it forgets any press in progress; - a transition ends exactly on its value (it stopped a rounding error short, at every frame rate). Tests: ui_popover_mouse, ui_scrollbar, ui_ease (60/120/180/240 Hz). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.2 KiB
Text
33 lines
1.2 KiB
Text
# popover.ludic - HTML's popover: `<div popover on-close="...">` sits where its position puts it
|
|
# (absolutely, in its parent) and is drawn on the top layer, over everything. While one is up the
|
|
# pointer and the keyboard are its: a press outside it, or Esc, closes it (on-close), and Tab
|
|
# walks only its own controls.
|
|
var pop_list: []UiNode = new []UiNode
|
|
function pp_find(n: UiNode, out: []UiNode) -> void {
|
|
if n.popover {
|
|
push(out, n)
|
|
return
|
|
}
|
|
for i in 0 .. len(n.children) { pp_find(n.children[i], out) }
|
|
}
|
|
# the topmost popover open in this tree, or null
|
|
function pp_top(root: UiNode) -> UiNode {
|
|
let all = new []UiNode
|
|
pp_find(root, all)
|
|
if len(all) == 0 { return null }
|
|
return all[len(all) - 1]
|
|
}
|
|
# the pointer against the popover: inside it is as usual; a press outside closes it and is spent
|
|
function pp_pointer(top: UiNode) -> bool {
|
|
let i = in_now
|
|
if not (i.down and not in_was_down) { return false }
|
|
if i.x >= top.x and i.y >= top.y and i.x < top.x + top.cw and i.y < top.y + top.ch { return false }
|
|
fr_press_key = ""
|
|
ui_fire(top, "close", Value.null())
|
|
return true
|
|
}
|
|
function pp_draw_top() -> void {
|
|
let list = pop_list
|
|
pop_list = new []UiNode
|
|
for i in 0 .. len(list) { fr_draw(list[i]) }
|
|
}
|