mirror of
https://github.com/vsariola/sointu.git
synced 2025-09-10 07:15:56 -04:00
feat(tracker): highlight beats / every second beat in the tracker
Closes #30
This commit is contained in:
@ -18,7 +18,6 @@ const rowMarkerWidth = 50
|
|||||||
func (t *Tracker) layoutRowMarkers(patternRows, sequenceLength, cursorRow, cursorPattern, cursorCol, playRow, playPattern int) layout.Widget {
|
func (t *Tracker) layoutRowMarkers(patternRows, sequenceLength, cursorRow, cursorPattern, cursorCol, playRow, playPattern int) layout.Widget {
|
||||||
return func(gtx layout.Context) layout.Dimensions {
|
return func(gtx layout.Context) layout.Dimensions {
|
||||||
gtx.Constraints.Min.X = rowMarkerWidth
|
gtx.Constraints.Min.X = rowMarkerWidth
|
||||||
gtx.Constraints.Max.X = rowMarkerWidth
|
|
||||||
paint.FillShape(gtx.Ops, rowMarkerSurfaceColor, clip.Rect{
|
paint.FillShape(gtx.Ops, rowMarkerSurfaceColor, clip.Rect{
|
||||||
Max: gtx.Constraints.Max,
|
Max: gtx.Constraints.Max,
|
||||||
}.Op())
|
}.Op())
|
||||||
@ -28,11 +27,20 @@ func (t *Tracker) layoutRowMarkers(patternRows, sequenceLength, cursorRow, curso
|
|||||||
cursorSongRow := cursorPattern*patternRows + cursorRow
|
cursorSongRow := cursorPattern*patternRows + cursorRow
|
||||||
playSongRow := playPattern*patternRows + playRow
|
playSongRow := playPattern*patternRows + playRow
|
||||||
op.Offset(f32.Pt(0, (-1*trackRowHeight)*float32(cursorSongRow))).Add(gtx.Ops)
|
op.Offset(f32.Pt(0, (-1*trackRowHeight)*float32(cursorSongRow))).Add(gtx.Ops)
|
||||||
|
beatMarkerDensity := t.song.RowsPerBeat
|
||||||
|
for beatMarkerDensity <= 2 {
|
||||||
|
beatMarkerDensity *= 2
|
||||||
|
}
|
||||||
for i := 0; i < sequenceLength; i++ {
|
for i := 0; i < sequenceLength; i++ {
|
||||||
for j := 0; j < patternRows; j++ {
|
for j := 0; j < patternRows; j++ {
|
||||||
songRow := i*patternRows + j
|
songRow := i*patternRows + j
|
||||||
|
if mod(songRow, beatMarkerDensity*2) == 0 {
|
||||||
|
paint.FillShape(gtx.Ops, twoBeatHighlight, clip.Rect{Max: image.Pt(gtx.Constraints.Max.X, trackRowHeight)}.Op())
|
||||||
|
} else if mod(songRow, beatMarkerDensity) == 0 {
|
||||||
|
paint.FillShape(gtx.Ops, oneBeatHighlight, clip.Rect{Max: image.Pt(gtx.Constraints.Max.X, trackRowHeight)}.Op())
|
||||||
|
}
|
||||||
if songRow == playSongRow {
|
if songRow == playSongRow {
|
||||||
paint.FillShape(gtx.Ops, trackerPlayColor, clip.Rect{Max: image.Pt(trackColWidth, trackRowHeight)}.Op())
|
paint.FillShape(gtx.Ops, trackerPlayColor, clip.Rect{Max: image.Pt(gtx.Constraints.Max.X, trackRowHeight)}.Op())
|
||||||
}
|
}
|
||||||
if j == 0 {
|
if j == 0 {
|
||||||
paint.ColorOp{Color: rowMarkerPatternTextColor}.Add(gtx.Ops)
|
paint.ColorOp{Color: rowMarkerPatternTextColor}.Add(gtx.Ops)
|
||||||
@ -48,6 +56,6 @@ func (t *Tracker) layoutRowMarkers(patternRows, sequenceLength, cursorRow, curso
|
|||||||
op.Offset(f32.Pt(-rowMarkerWidth/2, trackRowHeight)).Add(gtx.Ops)
|
op.Offset(f32.Pt(-rowMarkerWidth/2, trackRowHeight)).Add(gtx.Ops)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
return layout.Dimensions{Size: image.Pt(rowMarkerWidth, gtx.Constraints.Max.Y)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ var trackerInactiveTextColor = highEmphasisTextColor
|
|||||||
var trackerActiveTextColor = color.NRGBA{R: 255, G: 255, B: 130, A: 255}
|
var trackerActiveTextColor = color.NRGBA{R: 255, G: 255, B: 130, A: 255}
|
||||||
var trackerPlayColor = color.NRGBA{R: 55, G: 55, B: 61, A: 255}
|
var trackerPlayColor = color.NRGBA{R: 55, G: 55, B: 61, A: 255}
|
||||||
var trackerPatMarker = primaryColor
|
var trackerPatMarker = primaryColor
|
||||||
|
var oneBeatHighlight = color.NRGBA{R: 31, G: 37, B: 38, A: 255}
|
||||||
|
var twoBeatHighlight = color.NRGBA{R: 31, G: 51, B: 53, A: 255}
|
||||||
|
|
||||||
var patternPlayColor = color.NRGBA{R: 55, G: 55, B: 61, A: 255}
|
var patternPlayColor = color.NRGBA{R: 55, G: 55, B: 61, A: 255}
|
||||||
var patternTextColor = primaryColor
|
var patternTextColor = primaryColor
|
||||||
|
@ -228,10 +228,6 @@ func (t *Tracker) layoutTracks(gtx C) D {
|
|||||||
y2 *= trackRowHeight * t.song.RowsPerPattern
|
y2 *= trackRowHeight * t.song.RowsPerPattern
|
||||||
paint.FillShape(gtx.Ops, inactiveSelectionColor, clip.Rect{Min: image.Pt(x1, y1), Max: image.Pt(x2, y2)}.Op())
|
paint.FillShape(gtx.Ops, inactiveSelectionColor, clip.Rect{Min: image.Pt(x1, y1), Max: image.Pt(x2, y2)}.Op())
|
||||||
}
|
}
|
||||||
if t.Playing {
|
|
||||||
py := trackRowHeight * (t.PlayPosition.Pattern*t.song.RowsPerPattern + t.PlayPosition.Row)
|
|
||||||
paint.FillShape(gtx.Ops, trackerPlayColor, clip.Rect{Min: image.Pt(0, py), Max: image.Pt(gtx.Constraints.Max.X, py+trackRowHeight)}.Op())
|
|
||||||
}
|
|
||||||
if t.EditMode == EditTracks {
|
if t.EditMode == EditTracks {
|
||||||
x1, y1 := t.Cursor.Track, t.Cursor.Pattern*t.song.RowsPerPattern+t.Cursor.Row
|
x1, y1 := t.Cursor.Track, t.Cursor.Pattern*t.song.RowsPerPattern+t.Cursor.Row
|
||||||
x2, y2 := t.SelectionCorner.Track, t.SelectionCorner.Pattern*t.song.RowsPerPattern+t.SelectionCorner.Row
|
x2, y2 := t.SelectionCorner.Track, t.SelectionCorner.Pattern*t.song.RowsPerPattern+t.SelectionCorner.Row
|
||||||
|
Reference in New Issue
Block a user