diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-02-10 16:56:06 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-02-10 16:56:06 -0500 |
| commit | 430f97bed9d758de90a72b0c06b2be1989ba2b1d (patch) | |
| tree | 057a578389bfafe595ba415797908979c3d09add /layout/mux.go | |
| parent | 3ce04a4d3dc8d174b520d85804e5c8dce8c5d08f (diff) | |
| download | gui-430f97bed9d758de90a72b0c06b2be1989ba2b1d.zip | |
add rows layout
Diffstat (limited to 'layout/mux.go')
| -rw-r--r-- | layout/mux.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/layout/mux.go b/layout/mux.go new file mode 100644 index 0000000..680e984 --- /dev/null +++ b/layout/mux.go @@ -0,0 +1,29 @@ +package layout + +import ( + "image" + "image/draw" +) + +// TaggedDrawCall is a draw function tagged with the index of a child Env within a layout. +type taggedDrawCall struct { + f func(draw.Image) image.Rectangle + idx uint +} + +// MuxDrawCalls tags draw functions with the index of a child Env, and forwards them to an output channel. +// When the input channel is closed, it decrements the waitgroup counter. +// It does NOT close the output channel. +func muxDrawCalls(in <-chan func(draw.Image) image.Rectangle, idx uint, out chan<- taggedDrawCall, wg waitgroup) { + for f := range in { + out <- taggedDrawCall{f, idx} + } + wg.Done() +} + +// Multicast sends a message to multiple recipients. +func multicast[T any](msg T, recipients []chan T) { + for _, c := range recipients { + c <- msg + } +} |