From 0cc6367a881ab7dba48ace7b111e0eb1151c10bb Mon Sep 17 00:00:00 2001 From: Clement Benard Date: Fri, 12 Jul 2019 17:23:28 +0200 Subject: Better separation between Layout and Mux --- layout/box.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'layout/box.go') 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) -- cgit v1.2.3