mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
io/router,app: add support for directional focus moves
Implement support for up/down/right/left directional focus moves and map Android directional pad keys to focus moves. Fixes: https://todo.sr.ht/~eliasnaur/gio/195 References: https://github.com/tailscale/tailscale/issues/1611 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+16
-4
@@ -222,6 +222,14 @@ func (c *pointerCollector) currentArea() int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (c *pointerCollector) currentAreaBounds() f32.Rectangle {
|
||||
a := c.currentArea()
|
||||
if a == -1 {
|
||||
panic("no root area")
|
||||
}
|
||||
return c.q.areas[a].bounds()
|
||||
}
|
||||
|
||||
func (c *pointerCollector) addHitNode(n hitNode) {
|
||||
n.next = c.state.nodePlusOne - 1
|
||||
c.q.hitTree = append(c.q.hitTree, n)
|
||||
@@ -382,10 +390,7 @@ func (q *pointerQueue) appendSemanticChildren(nodes []SemanticNode, areaIdx int)
|
||||
nodes = append(nodes, SemanticNode{
|
||||
ID: semID,
|
||||
Desc: SemanticDesc{
|
||||
Bounds: f32.Rectangle{
|
||||
Min: a.trans.Transform(a.area.rect.Min),
|
||||
Max: a.trans.Transform(a.area.rect.Max),
|
||||
},
|
||||
Bounds: a.bounds(),
|
||||
Label: cnt.label,
|
||||
Description: cnt.desc,
|
||||
Class: cnt.class,
|
||||
@@ -869,6 +874,13 @@ func (op *areaOp) Hit(pos f32.Point) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *areaNode) bounds() f32.Rectangle {
|
||||
return f32.Rectangle{
|
||||
Min: a.trans.Transform(a.area.rect.Min),
|
||||
Max: a.trans.Transform(a.area.rect.Max),
|
||||
}
|
||||
}
|
||||
|
||||
func setScrollEvent(scroll float32, min, max int) (left, scrolled float32) {
|
||||
if v := float32(max); scroll > v {
|
||||
return scroll - v, v
|
||||
|
||||
Reference in New Issue
Block a user