mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
refactor(go): Move everything from go4k to root package sointu
This commit is contained in:
37
tracker/run.go
Normal file
37
tracker/run.go
Normal file
@ -0,0 +1,37 @@
|
||||
package tracker
|
||||
|
||||
import (
|
||||
"gioui.org/app"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"os"
|
||||
)
|
||||
|
||||
func (t *Tracker) Run(w *app.Window) error {
|
||||
var ops op.Ops
|
||||
for {
|
||||
select {
|
||||
case <-t.ticked:
|
||||
w.Invalidate()
|
||||
case e := <-w.Events():
|
||||
switch e := e.(type) {
|
||||
case system.DestroyEvent:
|
||||
return e.Err
|
||||
case key.Event:
|
||||
if t.KeyEvent(e) {
|
||||
w.Invalidate()
|
||||
}
|
||||
case system.FrameEvent:
|
||||
gtx := layout.NewContext(&ops, e)
|
||||
if t.QuitButton.Clicked() {
|
||||
os.Exit(0)
|
||||
}
|
||||
t.Layout(gtx)
|
||||
e.Frame(gtx.Ops)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user