aboutsummaryrefslogtreecommitdiffstats
path: root/layout/box.go
diff options
context:
space:
mode:
authorClement Benard <contact@clementbenard.com>2019-07-12 17:23:28 +0200
committerClement Benard <contact@clementbenard.com>2019-07-12 17:23:28 +0200
commit0cc6367a881ab7dba48ace7b111e0eb1151c10bb (patch)
treeeabadd10783b857271f12797f1a505efec85630c /layout/box.go
parent009f865bc5484e54f09d2173b2b3dbbf3838d391 (diff)
downloadgui-0cc6367a881ab7dba48ace7b111e0eb1151c10bb.zip
Better separation between Layout and Mux
Diffstat (limited to 'layout/box.go')
-rw-r--r--layout/box.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/layout/box.go b/layout/box.go
index 01a1143..13c7b2b 100644
--- a/layout/box.go
+++ b/layout/box.go
@@ -19,7 +19,7 @@ type box struct {
// NewBox creates a familiar flexbox-like list layout.
// It can be horizontal or vertical.
-func NewBox(env gui.Env, contents []*gui.Env, options ...func(*box)) gui.Env {
+func NewBox(contents []*gui.Env, options ...func(*box)) Layout {
ret := &box{
Background: image.Black,
Contents: contents,
@@ -28,12 +28,7 @@ func NewBox(env gui.Env, contents []*gui.Env, options ...func(*box)) gui.Env {
for _, f := range options {
f(ret)
}
-
- mux, env := NewMux(env, ret)
- for _, item := range contents {
- *item = mux.MakeEnv()
- }
- return env
+ return ret
}
// BoxVertical changes the otherwise horizontal Box to be vertical.
@@ -67,6 +62,10 @@ func (g *box) Redraw(drw draw.Image, bounds image.Rectangle) {
draw.Draw(drw, bounds, image.NewUniform(g.Background), image.ZP, draw.Src)
}
+func (g *box) Items() []*gui.Env {
+ return g.Contents
+}
+
func (g *box) Lay(bounds image.Rectangle) []image.Rectangle {
items := len(g.Contents)
ret := make([]image.Rectangle, 0, items)