io/input: [API] introduce Source, the interface between a Router and widgets

This change gets rid of the event.Queue interface by replacing it with
input.Source values. Source provides the interface to Router necessary
to implement interface widgets.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-10-08 17:56:03 -05:00
parent c319f3c214
commit 6027517949
31 changed files with 106 additions and 127 deletions
+3 -3
View File
@@ -28,14 +28,14 @@ func TestHover(t *testing.T) {
r.Queue(
pointer.Event{Kind: pointer.Move, Position: f32.Pt(30, 30)},
)
if !h.Update(r) {
if !h.Update(r.Source()) {
t.Fatal("expected hovered")
}
r.Queue(
pointer.Event{Kind: pointer.Move, Position: f32.Pt(50, 50)},
)
if h.Update(r) {
if h.Update(r.Source()) {
t.Fatal("expected not hovered")
}
}
@@ -75,7 +75,7 @@ func TestMouseClicks(t *testing.T) {
r.Frame(&ops)
r.Queue(tc.events...)
events := click.Update(&r)
events := click.Update(r.Source())
clicks := filterMouseClicks(events)
if got, want := len(clicks), len(tc.clicks); got != want {
t.Fatalf("got %d mouse clicks, expected %d", got, want)