From ebc5d96f0614ab3b4f2073eadf22fbe554b0ec8f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 10 Feb 2026 17:20:34 -0500 Subject: remove layout options --- layout/options.go | 34 ---------------------------------- layout/region.go | 7 +++---- layout/rows.go | 8 +------- 3 files changed, 4 insertions(+), 45 deletions(-) delete mode 100644 layout/options.go (limited to 'layout') diff --git a/layout/options.go b/layout/options.go deleted file mode 100644 index 2ea0c81..0000000 --- a/layout/options.go +++ /dev/null @@ -1,34 +0,0 @@ -package layout - -import ( - "image/color" -) - -var ( - defaultBg = color.Transparent -) - -// Option is a function option for layout constructors. -type Option func(*options) - -type options struct { - bg color.Color // background color -} - -// Background sets the background color of a layout. -func Background(bg color.Color) Option { - return func(o *options) { - o.bg = bg - } -} - -// EvalOptions evaluates a list of option functions, returning the final set. -func evalOptions(o ...Option) options { - opts := options{ - bg: defaultBg, - } - for i := range o { - o[i](&opts) - } - return opts -} diff --git a/layout/region.go b/layout/region.go index 93d930a..1e4d4b1 100644 --- a/layout/region.go +++ b/layout/region.go @@ -2,6 +2,7 @@ package layout import ( "image" + "image/color" "image/draw" "github.com/faiface/gui" @@ -16,9 +17,7 @@ type Region struct { // NewRegion creates a region layout that occupies part of the parent env's area, as determined by the resize function. // Resize takes the area of the parent and returns the area of the region. // It returns the child Env. -func NewRegion(env gui.Env, resize func(image.Rectangle) image.Rectangle, o ...Option) gui.Env { - opts := evalOptions(o...) - +func NewRegion(env gui.Env, clr color.Color, resize func(image.Rectangle) image.Rectangle) gui.Env { events := make(chan gui.Event) // to child drw := make(chan func(draw.Image) image.Rectangle) // from child @@ -30,7 +29,7 @@ func NewRegion(env gui.Env, resize func(image.Rectangle) image.Rectangle, o ...O // Draw background redrawBg := func(area image.Rectangle) func(draw.Image) image.Rectangle { - return drawSubImage(drawBackground(opts.bg), area) + return drawSubImage(drawBackground(clr), area) } env.Draw() <- redrawBg(area) diff --git a/layout/rows.go b/layout/rows.go index 3912878..603eddc 100644 --- a/layout/rows.go +++ b/layout/rows.go @@ -10,9 +10,7 @@ import ( // NewRows creates layout with nrows children arranged in rows. // It returns a slice containing an Env for each row. // The height of each row is determined by the draw calls received from that row. -func NewRows(env gui.Env, nrows uint, o ...Option) []gui.Env { - opts := evalOptions(o...) - +func NewRows(env gui.Env, nrows uint) []gui.Env { // Create event and draw channels for each row eventss := make([]chan gui.Event, nrows) // to children drawss := make([]chan func(draw.Image) image.Rectangle, nrows) // from children @@ -27,10 +25,6 @@ func NewRows(env gui.Env, nrows uint, o ...Option) []gui.Env { defer closeAll(eventss) resize := func(area image.Rectangle, rowHeights []uint) { - // Redraw background - env.Draw() <- drawSubImage(drawBackground(opts.bg), area) - - // Send resize events to rows off := area.Min // vertical offset from parent area origin var i uint for i = 0; i < nrows; i++ { -- cgit v1.2.3