diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-02-09 22:00:33 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-02-09 22:00:33 -0500 |
| commit | 8f28d1044fb83153fde4505421b75072930d6fb9 (patch) | |
| tree | ec39000ed901dc959626fc09d8e270268c6b3d03 /layout/layout.go | |
| parent | 5fde17eafa11bf397bbf1f18864b8ee26d9a701d (diff) | |
| download | gui-8f28d1044fb83153fde4505421b75072930d6fb9.zip | |
layout: add background color option
Diffstat (limited to 'layout/layout.go')
| -rw-r--r-- | layout/layout.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/layout/layout.go b/layout/layout.go new file mode 100644 index 0000000..b04aa35 --- /dev/null +++ b/layout/layout.go @@ -0,0 +1,28 @@ +/* +Package layout provides means of partitioning screen space. + +A layout exists in a parent Env, and has one or more child Envs. It +acts as a multiplexer for the children. The parent Env may be a window, +another layout, or whatever... Several layers of layouts can be composed. + +A layout allocates screen area to its children by intercepting Resize +events from the parent Env. Upon reception by the layout, a Resize event +is transformed for each child, and forwarded to them. + +Draw calls from the children are intercepted and translated onto their +respective areas before being forwarded to the parent Env. +*/ +package layout + +import ( + "image" + "image/color" + "image/draw" +) + +func drawBackground(c color.Color) func(draw.Image) image.Rectangle { + return func(img draw.Image) image.Rectangle { + draw.Draw(img, img.Bounds(), &image.Uniform{c}, image.ZP, draw.Src) + return img.Bounds() + } +} |