fix(tracker): clamp CurrentUnit to valid values when instrument changes

This commit is contained in:
vsariola
2021-02-06 19:15:06 +02:00
parent ef59c4a61a
commit 6c0cf6832e

View File

@ -112,6 +112,9 @@ func (t *Tracker) layoutInstrumentNames(gtx C) D {
dims := instrumentList.Layout(gtx)
if t.CurrentInstrument != t.InstrumentDragList.SelectedItem {
t.CurrentInstrument = t.InstrumentDragList.SelectedItem
if l := len(t.song.Patch.Instruments[t.CurrentInstrument].Units); t.CurrentUnit >= l {
t.CurrentUnit = l - 1
}
op.InvalidateOp{}.Add(gtx.Ops)
}
return dims