mirror of
https://github.com/vsariola/sointu.git
synced 2026-01-30 20:30:11 -05:00
feat(tracker): make clear unit action clear all selected units
This commit is contained in:
parent
4a46d601f2
commit
a37990a7fa
@ -290,9 +290,12 @@ func (m *ClearUnit) Enabled() bool {
|
||||
}
|
||||
func (m *ClearUnit) Do() {
|
||||
defer (*Model)(m).change("DeleteUnitAction", PatchChange, MajorChange)()
|
||||
m.d.UnitIndex = max(min(m.d.UnitIndex, len(m.d.Song.Patch[m.d.InstrIndex].Units)-1), 0)
|
||||
m.d.Song.Patch[m.d.InstrIndex].Units[m.d.UnitIndex] = sointu.Unit{}
|
||||
m.d.Song.Patch[m.d.InstrIndex].Units[m.d.UnitIndex].ID = (*Model)(m).maxID() + 1
|
||||
l := ((*Model)(m)).Units().List()
|
||||
r := l.listRange()
|
||||
for i := r.Start; i < r.End; i++ {
|
||||
m.d.Song.Patch[m.d.InstrIndex].Units[i] = sointu.Unit{}
|
||||
m.d.Song.Patch[m.d.InstrIndex].Units[i].ID = (*Model)(m).maxID() + 1
|
||||
}
|
||||
}
|
||||
|
||||
// Undo
|
||||
|
||||
Reference in New Issue
Block a user