From 24ebc99b92a45fdbf23198a60ad3df199c14680f Mon Sep 17 00:00:00 2001 From: vsariola <5684185+vsariola@users.noreply.github.com> Date: Sun, 14 Feb 2021 20:13:15 +0200 Subject: [PATCH] refactor(tracker): move instrument related stuff from layout.go to instruments.go the code related to handling instrument button actions definitely should be in instruments.go, not layout.go --- tracker/instruments.go | 8 ++++---- tracker/layout.go | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tracker/instruments.go b/tracker/instruments.go index 2aff3f7..2c3b6ed 100644 --- a/tracker/instruments.go +++ b/tracker/instruments.go @@ -14,15 +14,15 @@ import ( "golang.org/x/exp/shiny/materialdesign/icons" ) -func (t *Tracker) updateInstrumentScroll() { +func (t *Tracker) layoutInstruments(gtx C) D { if t.CurrentInstrument > 7 { t.InstrumentDragList.List.Position.First = t.CurrentInstrument - 7 } else { t.InstrumentDragList.List.Position.First = 0 } -} - -func (t *Tracker) layoutInstruments(gtx C) D { + for t.NewInstrumentBtn.Clicked() { + t.AddInstrument() + } btnStyle := material.IconButton(t.Theme, t.NewInstrumentBtn, widgetForIcon(icons.ContentAdd)) btnStyle.Background = transparent btnStyle.Inset = layout.UniformInset(unit.Dp(6)) diff --git a/tracker/layout.go b/tracker/layout.go index 47aad17..bca30a9 100644 --- a/tracker/layout.go +++ b/tracker/layout.go @@ -16,7 +16,6 @@ func (t *Tracker) Layout(gtx layout.Context) { t.VerticalSplit.Layout(gtx, t.layoutTop, t.layoutBottom) - t.updateInstrumentScroll() } func (t *Tracker) layoutBottom(gtx layout.Context) layout.Dimensions { @@ -31,13 +30,8 @@ func (t *Tracker) layoutBottom(gtx layout.Context) layout.Dimensions { } func (t *Tracker) layoutTop(gtx layout.Context) layout.Dimensions { - for t.NewInstrumentBtn.Clicked() { - t.AddInstrument() - } - return t.TopHorizontalSplit.Layout(gtx, t.layoutSongPanel, t.layoutInstruments, ) - }