From 29b289d2fb9465df507ad7d95accc22c8c3c6b73 Mon Sep 17 00:00:00 2001 From: vsariola <5684185+vsariola@users.noreply.github.com> Date: Wed, 3 Feb 2021 16:34:22 +0200 Subject: [PATCH] refactor(tracker): remove Contents from PopupStyle; pass it to Layout instead --- tracker/popup.go | 8 +++----- tracker/songpanel.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tracker/popup.go b/tracker/popup.go index fe30264..286e2c8 100644 --- a/tracker/popup.go +++ b/tracker/popup.go @@ -14,7 +14,6 @@ import ( type PopupStyle struct { Visible *bool - Contents layout.Widget SurfaceColor color.NRGBA ShadowColor color.NRGBA ShadowN unit.Value @@ -24,10 +23,9 @@ type PopupStyle struct { SE, SW, NW, NE unit.Value } -func Popup(visible *bool, contents layout.Widget) PopupStyle { +func Popup(visible *bool) PopupStyle { return PopupStyle{ Visible: visible, - Contents: contents, SurfaceColor: popupSurfaceColor, ShadowColor: popupShadowColor, ShadowN: unit.Dp(2), @@ -41,7 +39,7 @@ func Popup(visible *bool, contents layout.Widget) PopupStyle { } } -func (s PopupStyle) Layout(gtx C) D { +func (s PopupStyle) Layout(gtx C, contents layout.Widget) D { if !*s.Visible { return D{} } @@ -78,7 +76,7 @@ func (s PopupStyle) Layout(gtx C) D { macro := op.Record(gtx.Ops) dims := layout.Stack{}.Layout(gtx, layout.Expanded(bg), - layout.Stacked(s.Contents), + layout.Stacked(contents), ) callop := macro.Stop() op.Defer(gtx.Ops, callop) diff --git a/tracker/songpanel.go b/tracker/songpanel.go index 910d2b6..80666b7 100644 --- a/tracker/songpanel.go +++ b/tracker/songpanel.go @@ -58,7 +58,7 @@ func (t *Tracker) layoutSongButtons(gtx C) D { ) } - fileMenu := Popup(&t.FileMenuVisible, menuContents) + fileMenu := Popup(&t.FileMenuVisible) fileMenu.NE = unit.Dp(0) fileMenu.ShadowN = unit.Dp(0) fileMenu.NW = unit.Dp(0) @@ -83,7 +83,7 @@ func (t *Tracker) layoutSongButtons(gtx C) D { op.Offset(f32.Pt(0, float32(dims.Size.Y))).Add(gtx.Ops) gtx.Constraints.Max.X = 160 gtx.Constraints.Max.Y = 300 - fileMenu.Layout(gtx) + fileMenu.Layout(gtx, menuContents) return dims }