diff --git a/tracker/gioui/instrument_editor.go b/tracker/gioui/instrument_editor.go index 772e5ea..a491e0a 100644 --- a/tracker/gioui/instrument_editor.go +++ b/tracker/gioui/instrument_editor.go @@ -146,7 +146,7 @@ func (ul *InstrumentEditor) layoutList(gtx C) D { }), ) } - return Surface{Gray: 30, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, surface) + return Surface{Height: 4, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, surface) } func (ul *InstrumentEditor) update(gtx C) { @@ -279,7 +279,7 @@ func (pe *InstrumentEditor) layoutTable(gtx C) D { if pe.searching.Value() { editorFunc = pe.layoutUnitTypeChooser } - return Surface{Gray: 24, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { + return Surface{Height: 3, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { return layout.Flex{Axis: layout.Vertical}.Layout(gtx, layout.Flexed(1, editorFunc), layout.Rigid(pe.layoutFooter), diff --git a/tracker/gioui/instrument_presets.go b/tracker/gioui/instrument_presets.go index 47d873f..e517bb5 100644 --- a/tracker/gioui/instrument_presets.go +++ b/tracker/gioui/instrument_presets.go @@ -104,7 +104,7 @@ func (ip *InstrumentPresets) layout(gtx C) D { return dims } dirSurface := func(gtx C) D { - return Surface{Gray: 36, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, dirs) + return Surface{Height: 5, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, dirs) } resultElem := func(gtx C, i int) D { gtx.Constraints.Min.X = gtx.Constraints.Max.X @@ -142,7 +142,7 @@ func (ip *InstrumentPresets) layout(gtx C) D { return dims } resultSurface := func(gtx C) D { - return Surface{Gray: 30, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, results) + return Surface{Height: 4, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, results) } bottom := func(gtx C) D { return layout.Flex{Axis: layout.Horizontal}.Layout(gtx, @@ -169,7 +169,7 @@ func (ip *InstrumentPresets) layout(gtx C) D { ) return D{Size: m} } - return Surface{Gray: 24, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, f) + return Surface{Height: 3, Focus: tr.PatchPanel.TreeFocused(gtx)}.Layout(gtx, f) } func (ip *InstrumentPresets) layoutSearch(gtx C) D { diff --git a/tracker/gioui/note_editor.go b/tracker/gioui/note_editor.go index 07f5c0d..aef442f 100644 --- a/tracker/gioui/note_editor.go +++ b/tracker/gioui/note_editor.go @@ -149,7 +149,7 @@ func (te *NoteEditor) Layout(gtx layout.Context) layout.Dimensions { defer clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Push(gtx.Ops).Pop() - return Surface{Gray: 24, Focus: te.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { + return Surface{Height: 3, Focus: te.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { return layout.Flex{Axis: layout.Vertical}.Layout(gtx, layout.Rigid(func(gtx C) D { return te.layoutButtons(gtx, t) @@ -162,7 +162,7 @@ func (te *NoteEditor) Layout(gtx layout.Context) layout.Dimensions { } func (te *NoteEditor) layoutButtons(gtx C, t *Tracker) D { - return Surface{Gray: 37, Focus: te.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { + return Surface{Height: 4, Focus: te.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { addSemitoneBtn := ActionBtn(t.AddSemitone(), t.Theme, te.AddSemitoneBtn, "+1", "Add semitone") subtractSemitoneBtn := ActionBtn(t.SubtractSemitone(), t.Theme, te.SubtractSemitoneBtn, "-1", "Subtract semitone") addOctaveBtn := ActionBtn(t.AddOctave(), t.Theme, te.AddOctaveBtn, "+12", "Add octave") diff --git a/tracker/gioui/order_editor.go b/tracker/gioui/order_editor.go index e4731ec..52b8b01 100644 --- a/tracker/gioui/order_editor.go +++ b/tracker/gioui/order_editor.go @@ -120,7 +120,7 @@ func (oe *OrderEditor) Layout(gtx C) D { table := FilledScrollTable(t.Theme, oe.scrollTable) table.ColumnTitleHeight = orderTitleHeight - return Surface{Gray: 24, Focus: oe.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { + return Surface{Height: 3, Focus: oe.scrollTable.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D { return table.Layout(gtx, cell, colTitle, rowTitle, nil, rowTitleBg) }) } diff --git a/tracker/gioui/patch_panel.go b/tracker/gioui/patch_panel.go index 0975c77..81c71ba 100644 --- a/tracker/gioui/patch_panel.go +++ b/tracker/gioui/patch_panel.go @@ -174,7 +174,7 @@ func (it *InstrumentTools) Layout(gtx C) D { layout.Rigid(addInstrumentBtn.Layout), ) } - return Surface{Gray: 37, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, btns) + return Surface{Height: 4, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, btns) } func (it *InstrumentTools) update(gtx C, tr *Tracker) { diff --git a/tracker/gioui/song_panel.go b/tracker/gioui/song_panel.go index f0bbf7d..04a1383 100644 --- a/tracker/gioui/song_panel.go +++ b/tracker/gioui/song_panel.go @@ -467,7 +467,7 @@ func (pb *PlayBar) Layout(gtx C) D { followBtn := ToggleIconBtn(tr.Follow(), tr.Theme, pb.FollowBtn, icons.ActionSpeakerNotesOff, icons.ActionSpeakerNotes, pb.followOffHint, pb.followOnHint) loopBtn := ToggleIconBtn(tr.LoopToggle(), tr.Theme, pb.LoopBtn, icons.NavigationArrowForward, icons.AVLoop, pb.loopOffHint, pb.loopOnHint) - return Surface{Gray: 37}.Layout(gtx, func(gtx C) D { + return Surface{Height: 4}.Layout(gtx, func(gtx C) D { return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx, layout.Flexed(1, playBtn.Layout), layout.Rigid(rewindBtn.Layout), diff --git a/tracker/gioui/surface.go b/tracker/gioui/surface.go index ae52cfd..9bdd603 100644 --- a/tracker/gioui/surface.go +++ b/tracker/gioui/surface.go @@ -9,25 +9,26 @@ import ( ) type Surface struct { - Gray int - Inset layout.Inset - Focus bool + Height int + Inset layout.Inset + Focus bool } func (s Surface) Layout(gtx C, widget layout.Widget) D { - return layout.Background{}.Layout(gtx, - func(gtx C) D { - gray := s.Gray - if s.Focus { - gray += 8 - } - gray8 := uint8(min(max(gray, 0), 255)) - color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255} - paint.FillShape(gtx.Ops, color, clip.Rect{Max: gtx.Constraints.Min}.Op()) - return D{Size: gtx.Constraints.Min} - }, - func(gtx C) D { - return s.Inset.Layout(gtx, widget) - }, - ) + t := TrackerFromContext(gtx) + t.surfaceHeight += s.Height + bg := func(gtx C) D { + gray := s.Height * 8 + if s.Focus { + gray += 8 + } + gray8 := uint8(min(max(gray, 0), 255)) + color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255} + paint.FillShape(gtx.Ops, color, clip.Rect{Max: gtx.Constraints.Min}.Op()) + return D{Size: gtx.Constraints.Min} + } + fg := func(gtx C) D { return s.Inset.Layout(gtx, widget) } + dims := layout.Background{}.Layout(gtx, bg, fg) + t.surfaceHeight -= s.Height + return dims } diff --git a/tracker/gioui/tracker.go b/tracker/gioui/tracker.go index 2c9361c..c96ea86 100644 --- a/tracker/gioui/tracker.go +++ b/tracker/gioui/tracker.go @@ -56,6 +56,8 @@ type ( preferences Preferences *tracker.Model + + surfaceHeight int } ShowManual Tracker