feat(tracker): add pattern marks to tracker

This commit is contained in:
vsariola
2021-01-06 16:45:26 +02:00
parent 91766e198d
commit 492b2252bf
3 changed files with 17 additions and 2 deletions

View File

@ -14,7 +14,8 @@ import (
)
const trackRowHeight = 16
const trackWidth = 100
const trackWidth = 84
const patmarkWidth = 16
func (t *Tracker) layoutTrack(patterns [][]byte, sequence []byte, active bool, cursorRow, cursorPattern, cursorCol, playRow, playPattern int) layout.Widget {
return func(gtx layout.Context) layout.Dimensions {
@ -55,6 +56,10 @@ func (t *Tracker) layoutTrack(patterns [][]byte, sequence []byte, active bool, c
if songRow == playSongRow {
paint.FillShape(gtx.Ops, trackerPlayColor, clip.Rect{Max: image.Pt(trackWidth, trackRowHeight)}.Op())
}
if j == 0 {
paint.ColorOp{Color: trackerPatMarker}.Add(gtx.Ops)
widget.Label{}.Layout(gtx, textShaper, trackerFont, trackerFontSize, patternIndexToString(s))
}
if songRow == cursorSongRow {
paint.ColorOp{Color: trackerActiveTextColor}.Add(gtx.Ops)
} else {
@ -64,10 +69,11 @@ func (t *Tracker) layoutTrack(patterns [][]byte, sequence []byte, active bool, c
paint.ColorOp{Color: trackerInactiveTextColor}.Add(gtx.Ops)
}
}
op.Offset(f32.Pt(patmarkWidth, 0)).Add(gtx.Ops)
widget.Label{}.Layout(gtx, textShaper, trackerFont, trackerFontSize, valueAsNote(c))
op.Offset(f32.Pt(trackWidth/2, 0)).Add(gtx.Ops)
widget.Label{}.Layout(gtx, textShaper, trackerFont, trackerFontSize, strings.ToUpper(fmt.Sprintf("%02x", c)))
op.Offset(f32.Pt(-trackWidth/2, trackRowHeight)).Add(gtx.Ops)
op.Offset(f32.Pt(-trackWidth/2-patmarkWidth, trackRowHeight)).Add(gtx.Ops)
}
}
return layout.Dimensions{Size: gtx.Constraints.Max}