diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-16 17:18:00 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-16 17:18:00 -0500 |
| commit | 6a2e268df7e008579d1b6a0f2ef47597fcbe4862 (patch) | |
| tree | 22ed525af378da3f176ca89c48c38406d7a50316 /gui/env.go | |
| parent | db183cf7570e0f4e448ab5ced0ae41969261a815 (diff) | |
| download | volute-6a2e268df7e008579d1b6a0f2ef47597fcbe4862.zip | |
add window focus event to gui module
Diffstat (limited to 'gui/env.go')
| -rw-r--r-- | gui/env.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gui/env.go b/gui/env.go new file mode 100644 index 0000000..2515417 --- /dev/null +++ b/gui/env.go @@ -0,0 +1,33 @@ +package gui + +import ( + "image" + "image/draw" +) + +// Env is the most important thing in this package. It is an interactive graphical +// environment, such as a window. +// +// It has two channels: Events() and Draw(). +// +// The Events() channel produces events, like mouse and keyboard presses, while the +// Draw() channel receives drawing functions. A drawing function draws onto the +// supplied draw.Image, which is the drawing area of the Env and returns a rectangle +// covering the whole part of the image that got changed. +// +// An Env guarantees to produce a "resize/<x0>/<y0>/<x1>/<y1>" event as its first event. +// +// The Events() channel must be unlimited in capacity. Use MakeEventsChan() to create +// a channel of events with an unlimited capacity. +// +// The Draw() channel may be synchronous. +// +// Drawing functions sent to the Draw() channel are not guaranteed to be executed. +// +// Closing the Draw() channel results in closing the Env. The Env will subsequently +// close the Events() channel. On the other hand, when the Events() channel gets closed +// the user of the Env should subsequently close the Draw() channel. +type Env interface { + Events() <-chan Event + Draw() chan<- func(draw.Image) image.Rectangle +} |