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
+4 -6
View File
@@ -225,7 +225,7 @@ func (e *Editor) processPointer(gtx layout.Context) {
axis = gesture.Vertical
smin, smax = sbounds.Min.Y, sbounds.Max.Y
}
sdist := e.scroller.Update(gtx.Metric, gtx, gtx.Now, axis)
sdist := e.scroller.Update(gtx.Metric, gtx.Source, gtx.Now, axis)
var soff int
if e.SingleLine {
e.text.ScrollRel(sdist, 0)
@@ -305,10 +305,10 @@ func (e *Editor) processPointer(gtx layout.Context) {
func (e *Editor) clickDragEvents(gtx layout.Context) []event.Event {
var combinedEvents []event.Event
for _, evt := range e.clicker.Update(gtx) {
for _, evt := range e.clicker.Update(gtx.Source) {
combinedEvents = append(combinedEvents, evt)
}
for _, evt := range e.dragger.Update(gtx.Metric, gtx, gesture.Both) {
for _, evt := range e.dragger.Update(gtx.Metric, gtx.Source, gesture.Both) {
combinedEvents = append(combinedEvents, evt)
}
return combinedEvents
@@ -677,14 +677,12 @@ func (e *Editor) layout(gtx layout.Context, textMaterial, selectMaterial op.Call
}
e.showCaret = e.focused && (!blinking || dt%timePerBlink < timePerBlink/2)
}
disabled := gtx.Source == nil
semantic.Editor.Add(gtx.Ops)
if e.Len() > 0 {
e.paintSelection(gtx, selectMaterial)
e.paintText(gtx, textMaterial)
}
if !disabled {
if gtx.Enabled() {
e.paintCaret(gtx, textMaterial)
}
return visibleDims