feat(tracker): add numeric up down to adjust number of voices per track

This commit is contained in:
vsariola
2021-02-12 08:43:27 +02:00
parent 10f53bdbf7
commit d01657ab83
2 changed files with 38 additions and 1 deletions

View File

@ -47,6 +47,7 @@ type Tracker struct {
RowsPerPattern *NumberInput
RowsPerBeat *NumberInput
InstrumentVoices *NumberInput
TrackVoices *NumberInput
InstrumentNameEditor *widget.Editor
NewTrackBtn *widget.Clickable
NewInstrumentBtn *widget.Clickable
@ -220,6 +221,25 @@ func (t *Tracker) AddTrack() {
}
}
func (t *Tracker) SetTrackVoices(value int) bool {
if value < 1 {
value = 1
}
maxRemain := t.song.Patch.TotalVoices() - t.song.TotalTrackVoices() + t.song.Tracks[t.Cursor.Track].NumVoices
if maxRemain < 1 {
maxRemain = 1
}
if value > maxRemain {
value = maxRemain
}
if value != int(t.song.Tracks[t.Cursor.Track].NumVoices) {
t.SaveUndo()
t.song.Tracks[t.Cursor.Track].NumVoices = value
return true
}
return false
}
func (t *Tracker) AddInstrument() {
if t.song.Patch.TotalVoices() >= 32 {
return
@ -519,6 +539,7 @@ func New(audioContext sointu.AudioContext, synthService sointu.SynthService) *Tr
RowsPerPattern: new(NumberInput),
RowsPerBeat: new(NumberInput),
InstrumentVoices: new(NumberInput),
TrackVoices: new(NumberInput),
InstrumentNameEditor: &widget.Editor{SingleLine: true, Submit: true, Alignment: text.Middle},
NewTrackBtn: new(widget.Clickable),
NewInstrumentBtn: new(widget.Clickable),