blob: c6c522f585c3c003fe98899836bfc5c127cc4aa3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package main
import (
"image"
"github.com/faiface/mainthread"
"volute/gui"
"volute/gui/widget"
"volute/gui/win"
)
func run() {
w, err := win.New(win.Title("volute"), win.Size(800, 600))
if err != nil {
panic(err)
}
mux, env := gui.NewMux(w)
var (
displacementChan = make(chan float64)
)
go widget.Input(mux.MakeEnv(), image.Rect(20, 20, 100, 40), displacementChan)
Loop:
for event := range env.Events() {
switch event := event.(type) {
case win.WiClose:
break Loop
case win.KbType:
if event.Rune == 'q' {
break Loop
}
}
select {
case _ = <-displacementChan:
default:
}
}
close(env.Draw())
close(displacementChan)
}
func main() {
mainthread.Run(run)
}
|