refactor(tracker/gioui): Surface is given relative Height, not Gray

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-11-02 15:52:51 +02:00
parent 3495d91a4a
commit fa9654d311
8 changed files with 31 additions and 28 deletions

View File

@ -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) { func (ul *InstrumentEditor) update(gtx C) {
@ -279,7 +279,7 @@ func (pe *InstrumentEditor) layoutTable(gtx C) D {
if pe.searching.Value() { if pe.searching.Value() {
editorFunc = pe.layoutUnitTypeChooser 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, return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Flexed(1, editorFunc), layout.Flexed(1, editorFunc),
layout.Rigid(pe.layoutFooter), layout.Rigid(pe.layoutFooter),

View File

@ -104,7 +104,7 @@ func (ip *InstrumentPresets) layout(gtx C) D {
return dims return dims
} }
dirSurface := func(gtx C) D { 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 { resultElem := func(gtx C, i int) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X gtx.Constraints.Min.X = gtx.Constraints.Max.X
@ -142,7 +142,7 @@ func (ip *InstrumentPresets) layout(gtx C) D {
return dims return dims
} }
resultSurface := func(gtx C) D { 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 { bottom := func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx, return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
@ -169,7 +169,7 @@ func (ip *InstrumentPresets) layout(gtx C) D {
) )
return D{Size: m} 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 { func (ip *InstrumentPresets) layoutSearch(gtx C) D {

View File

@ -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() 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, return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D { layout.Rigid(func(gtx C) D {
return te.layoutButtons(gtx, t) 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 { 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") addSemitoneBtn := ActionBtn(t.AddSemitone(), t.Theme, te.AddSemitoneBtn, "+1", "Add semitone")
subtractSemitoneBtn := ActionBtn(t.SubtractSemitone(), t.Theme, te.SubtractSemitoneBtn, "-1", "Subtract semitone") subtractSemitoneBtn := ActionBtn(t.SubtractSemitone(), t.Theme, te.SubtractSemitoneBtn, "-1", "Subtract semitone")
addOctaveBtn := ActionBtn(t.AddOctave(), t.Theme, te.AddOctaveBtn, "+12", "Add octave") addOctaveBtn := ActionBtn(t.AddOctave(), t.Theme, te.AddOctaveBtn, "+12", "Add octave")

View File

@ -120,7 +120,7 @@ func (oe *OrderEditor) Layout(gtx C) D {
table := FilledScrollTable(t.Theme, oe.scrollTable) table := FilledScrollTable(t.Theme, oe.scrollTable)
table.ColumnTitleHeight = orderTitleHeight 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) return table.Layout(gtx, cell, colTitle, rowTitle, nil, rowTitleBg)
}) })
} }

View File

@ -174,7 +174,7 @@ func (it *InstrumentTools) Layout(gtx C) D {
layout.Rigid(addInstrumentBtn.Layout), 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) { func (it *InstrumentTools) update(gtx C, tr *Tracker) {

View File

@ -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) 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) 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, return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(1, playBtn.Layout), layout.Flexed(1, playBtn.Layout),
layout.Rigid(rewindBtn.Layout), layout.Rigid(rewindBtn.Layout),

View File

@ -9,25 +9,26 @@ import (
) )
type Surface struct { type Surface struct {
Gray int Height int
Inset layout.Inset Inset layout.Inset
Focus bool Focus bool
} }
func (s Surface) Layout(gtx C, widget layout.Widget) D { func (s Surface) Layout(gtx C, widget layout.Widget) D {
return layout.Background{}.Layout(gtx, t := TrackerFromContext(gtx)
func(gtx C) D { t.surfaceHeight += s.Height
gray := s.Gray bg := func(gtx C) D {
if s.Focus { gray := s.Height * 8
gray += 8 if s.Focus {
} gray += 8
gray8 := uint8(min(max(gray, 0), 255)) }
color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255} gray8 := uint8(min(max(gray, 0), 255))
paint.FillShape(gtx.Ops, color, clip.Rect{Max: gtx.Constraints.Min}.Op()) color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255}
return D{Size: gtx.Constraints.Min} 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) fg := func(gtx C) D { return s.Inset.Layout(gtx, widget) }
}, dims := layout.Background{}.Layout(gtx, bg, fg)
) t.surfaceHeight -= s.Height
return dims
} }

View File

@ -56,6 +56,8 @@ type (
preferences Preferences preferences Preferences
*tracker.Model *tracker.Model
surfaceHeight int
} }
ShowManual Tracker ShowManual Tracker