mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 21:02:52 -05:00
refactor(tracker/gioui): Surface is given relative Height, not Gray
This commit is contained in:
parent
3495d91a4a
commit
fa9654d311
@ -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),
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -56,6 +56,8 @@ type (
|
||||
preferences Preferences
|
||||
|
||||
*tracker.Model
|
||||
|
||||
surfaceHeight int
|
||||
}
|
||||
|
||||
ShowManual Tracker
|
||||
|
||||
Reference in New Issue
Block a user