ludic.ui: var() values found by their pieces, tpl_words/url/border-image by their text, nine-slices, picking, lifecycle, focus, hover, the event queue and input without a list or record made a frame
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
edaec666d1
commit
08ac2f1125
21 changed files with 281 additions and 98 deletions
|
|
@ -8,29 +8,11 @@ function fr_in(n: UiNode, px: float, py: float) -> bool {
|
|||
if n.ex != null and n.ex.no_pointer { return false }
|
||||
return px >= n.x and py >= n.y and px < n.x + n.cw and py < n.y + n.ch
|
||||
}
|
||||
# the nearest element that wants `kind`, out from the topmost one under the point
|
||||
# the nearest element that wants `kind`, out from the topmost one under the point: the children are
|
||||
# walked the other way from how they are painted (positioned ones by z-index, highest first, then
|
||||
# the flow, last first; a popover is on the top layer, not here), with no list made for it
|
||||
function fr_pick(n: UiNode, px: float, py: float, kind: int) -> UiNode {
|
||||
let kids = fr_paint_rev(n)
|
||||
for i in 0 .. len(kids) {
|
||||
if fr_in(kids[i], px, py) {
|
||||
let r = fr_pick(kids[i], px, py, kind)
|
||||
if r != null { return r }
|
||||
return fr_wants(n, kind)
|
||||
}
|
||||
}
|
||||
return fr_wants(n, kind)
|
||||
}
|
||||
function fr_wants(n: UiNode, kind: int) -> UiNode {
|
||||
if kind == PK_CONTROL and (n.focusable or n.act != null) { return n }
|
||||
if kind == PK_POINTER and pe_wants(n, false) { return n }
|
||||
if kind == PK_WHEEL and pe_wants(n, true) { return n }
|
||||
return null
|
||||
}
|
||||
# the children the other way from how they are painted: positioned ones by z-index, highest first,
|
||||
# then the flow, last first; a popover is on the top layer, not here
|
||||
function fr_paint_rev(n: UiNode) -> []UiNode {
|
||||
let out = new []UiNode
|
||||
if n.children == null { return out }
|
||||
if n.children == null { return fr_wants(n, kind) }
|
||||
var lo = 1000000
|
||||
var hi = -1000000
|
||||
for i in 0 .. len(n.children) {
|
||||
|
|
@ -45,15 +27,27 @@ function fr_paint_rev(n: UiNode) -> []UiNode {
|
|||
var i = len(n.children) - 1
|
||||
while i >= 0 {
|
||||
let c = n.children[i]
|
||||
if c.pos != 0 and not c.popover and c.z == z { push(out, c) }
|
||||
if c.pos != 0 and not c.popover and c.z == z and fr_in(c, px, py) { return fr_pick_in(n, c, px, py, kind) }
|
||||
i -= 1
|
||||
}
|
||||
z -= 1
|
||||
}
|
||||
var k = len(n.children) - 1
|
||||
while k >= 0 {
|
||||
if n.children[k].pos == 0 and not n.children[k].popover { push(out, n.children[k]) }
|
||||
let c = n.children[k]
|
||||
if c.pos == 0 and not c.popover and fr_in(c, px, py) { return fr_pick_in(n, c, px, py, kind) }
|
||||
k -= 1
|
||||
}
|
||||
return out
|
||||
return fr_wants(n, kind)
|
||||
}
|
||||
function fr_pick_in(n: UiNode, c: UiNode, px: float, py: float, kind: int) -> UiNode {
|
||||
let r = fr_pick(c, px, py, kind)
|
||||
if r != null { return r }
|
||||
return fr_wants(n, kind)
|
||||
}
|
||||
function fr_wants(n: UiNode, kind: int) -> UiNode {
|
||||
if kind == PK_CONTROL and (n.focusable or n.act != null) { return n }
|
||||
if kind == PK_POINTER and pe_wants(n, false) { return n }
|
||||
if kind == PK_WHEEL and pe_wants(n, true) { return n }
|
||||
return null
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue