diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-08-28 18:59:22 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-08-28 18:59:22 -0400 |
| commit | 353e3e0ea23143773710487f67cdccc8c02b4478 (patch) | |
| tree | 6a9c03a94698789459a7e77748244df7d9c42b08 /win.go | |
| parent | 33713cb2334d8dce3e4ae2f7a7905104efa8519b (diff) | |
| download | gui-353e3e0ea23143773710487f67cdccc8c02b4478.zip | |
win: implement Envrev1
Diffstat (limited to 'win.go')
| -rw-r--r-- | win.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -75,6 +75,8 @@ type Win struct { img share.Val[*image.RGBA] ratio int + child killer + kill chan bool dead chan bool @@ -104,6 +106,7 @@ func NewWin(opts ...WinOption) (*Win, error) { draw: make(chan func(draw.Image) image.Rectangle), newSize: make(chan image.Rectangle), img: share.NewVal[*image.RGBA](), + child: newKiller(), kill: make(chan bool), dead: make(chan bool), threads: new(sync.WaitGroup), @@ -181,6 +184,12 @@ func (w *Win) Events() <-chan Event { return w.events.Dequeue } // Draw returns the draw channel of the window. func (w *Win) Draw() chan<- func(draw.Image) image.Rectangle { return w.draw } +func (w *Win) Kill() chan<- bool { return w.kill } + +func (w *Win) Dead() <-chan bool { return w.dead } + +func (w *Win) attach() chan<- victim { return w.child.attach() } + var buttons = map[glfw.MouseButton]Button{ glfw.MouseButtonLeft: ButtonLeft, glfw.MouseButtonRight: ButtonRight, @@ -270,6 +279,9 @@ func (w *Win) eventThread() { for { select { case <-w.kill: + w.child.Kill() <- true + <-w.child.Dead() + close(w.kill) close(w.events.Enqueue) close(w.draw) |