mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
feat(tracker): add numeric up down to adjust number of voices per track
This commit is contained in:
parent
10f53bdbf7
commit
d01657ab83
@ -104,7 +104,19 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
|
|||||||
gtx.Constraints.Min.X = gtx.Px(unit.Dp(70))
|
gtx.Constraints.Min.X = gtx.Px(unit.Dp(70))
|
||||||
return in.Layout(gtx, numStyle.Layout)
|
return in.Layout(gtx, numStyle.Layout)
|
||||||
}
|
}
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
n := t.song.Tracks[t.Cursor.Track].NumVoices
|
||||||
|
maxRemain := t.song.Patch.TotalVoices() - t.song.TotalTrackVoices() + n
|
||||||
|
if maxRemain < 1 {
|
||||||
|
maxRemain = 1
|
||||||
|
}
|
||||||
|
t.TrackVoices.Value = n
|
||||||
|
voiceUpDown := func(gtx C) D {
|
||||||
|
numStyle := NumericUpDown(t.Theme, t.TrackVoices, 1, maxRemain)
|
||||||
|
gtx.Constraints.Min.Y = gtx.Px(unit.Dp(20))
|
||||||
|
gtx.Constraints.Min.X = gtx.Px(unit.Dp(70))
|
||||||
|
return in.Layout(gtx, numStyle.Layout)
|
||||||
|
}
|
||||||
|
dims := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(Label("OCT:", white)),
|
layout.Rigid(Label("OCT:", white)),
|
||||||
layout.Rigid(octave),
|
layout.Rigid(octave),
|
||||||
layout.Rigid(Label(" PITCH:", white)),
|
layout.Rigid(Label(" PITCH:", white)),
|
||||||
@ -112,8 +124,12 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
|
|||||||
layout.Rigid(subtractSemitoneBtnStyle.Layout),
|
layout.Rigid(subtractSemitoneBtnStyle.Layout),
|
||||||
layout.Rigid(addOctaveBtnStyle.Layout),
|
layout.Rigid(addOctaveBtnStyle.Layout),
|
||||||
layout.Rigid(subtractOctaveBtnStyle.Layout),
|
layout.Rigid(subtractOctaveBtnStyle.Layout),
|
||||||
|
layout.Rigid(Label("Voices:", white)),
|
||||||
|
layout.Rigid(voiceUpDown),
|
||||||
layout.Flexed(1, func(gtx C) D { return layout.Dimensions{Size: gtx.Constraints.Min} }),
|
layout.Flexed(1, func(gtx C) D { return layout.Dimensions{Size: gtx.Constraints.Min} }),
|
||||||
layout.Rigid(newTrackBtnStyle.Layout))
|
layout.Rigid(newTrackBtnStyle.Layout))
|
||||||
|
t.SetTrackVoices(t.TrackVoices.Value)
|
||||||
|
return dims
|
||||||
}
|
}
|
||||||
|
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
|
@ -47,6 +47,7 @@ type Tracker struct {
|
|||||||
RowsPerPattern *NumberInput
|
RowsPerPattern *NumberInput
|
||||||
RowsPerBeat *NumberInput
|
RowsPerBeat *NumberInput
|
||||||
InstrumentVoices *NumberInput
|
InstrumentVoices *NumberInput
|
||||||
|
TrackVoices *NumberInput
|
||||||
InstrumentNameEditor *widget.Editor
|
InstrumentNameEditor *widget.Editor
|
||||||
NewTrackBtn *widget.Clickable
|
NewTrackBtn *widget.Clickable
|
||||||
NewInstrumentBtn *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() {
|
func (t *Tracker) AddInstrument() {
|
||||||
if t.song.Patch.TotalVoices() >= 32 {
|
if t.song.Patch.TotalVoices() >= 32 {
|
||||||
return
|
return
|
||||||
@ -519,6 +539,7 @@ func New(audioContext sointu.AudioContext, synthService sointu.SynthService) *Tr
|
|||||||
RowsPerPattern: new(NumberInput),
|
RowsPerPattern: new(NumberInput),
|
||||||
RowsPerBeat: new(NumberInput),
|
RowsPerBeat: new(NumberInput),
|
||||||
InstrumentVoices: new(NumberInput),
|
InstrumentVoices: new(NumberInput),
|
||||||
|
TrackVoices: new(NumberInput),
|
||||||
InstrumentNameEditor: &widget.Editor{SingleLine: true, Submit: true, Alignment: text.Middle},
|
InstrumentNameEditor: &widget.Editor{SingleLine: true, Submit: true, Alignment: text.Middle},
|
||||||
NewTrackBtn: new(widget.Clickable),
|
NewTrackBtn: new(widget.Clickable),
|
||||||
NewInstrumentBtn: new(widget.Clickable),
|
NewInstrumentBtn: new(widget.Clickable),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user