feat(tracker): add button to make note off and use "1" also as the key event

Closes #54
This commit is contained in:
vsariola 2021-03-14 18:10:29 +02:00
parent 01226a2910
commit b6283cd13e
3 changed files with 17 additions and 2 deletions

View File

@ -382,7 +382,7 @@ func (t *Tracker) KeyEvent(w *app.Window, e key.Event) bool {
t.NumberPressed(byte(iv))
}
} else {
if e.Name == "A" {
if e.Name == "A" || e.Name == "1" {
t.SetNote(0)
} else {
if val, ok := noteMap[e.Name]; ok {

View File

@ -49,6 +49,14 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
t.AdjustSelectionPitch(-1)
}
for t.NoteOffBtn.Clicked() {
t.SetNote(0)
if !(t.NoteTracking() && t.player.Playing()) && t.Step.Value > 0 {
t.SetCursor(t.Cursor().AddRows(t.Step.Value))
t.SetSelectionCorner(t.Cursor())
}
}
for t.AddOctaveBtn.Clicked() {
t.AdjustSelectionPitch(12)
}
@ -74,6 +82,10 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
subtractOctaveBtnStyle.Color = primaryColor
subtractOctaveBtnStyle.Background = transparent
subtractOctaveBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
noteOffBtnStyle := material.Button(t.Theme, t.NoteOffBtn, "Note Off")
noteOffBtnStyle.Color = primaryColor
noteOffBtnStyle.Background = transparent
noteOffBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
deleteTrackBtnStyle := material.IconButton(t.Theme, t.DeleteTrackBtn, widgetForIcon(icons.ActionDelete))
deleteTrackBtnStyle.Background = transparent
deleteTrackBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
@ -113,11 +125,12 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
dims := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(Label("OCT:", white)),
layout.Rigid(octave),
layout.Rigid(Label(" PITCH:", white)),
layout.Rigid(func(gtx C) D { return layout.Dimensions{Size: image.Pt(gtx.Px(unit.Dp(12)), 0)} }),
layout.Rigid(addSemitoneBtnStyle.Layout),
layout.Rigid(subtractSemitoneBtnStyle.Layout),
layout.Rigid(addOctaveBtnStyle.Layout),
layout.Rigid(subtractOctaveBtnStyle.Layout),
layout.Rigid(noteOffBtnStyle.Layout),
layout.Rigid(hexCheckBoxStyle.Layout),
layout.Rigid(Label(" Voices:", white)),
layout.Rigid(voiceUpDown),

View File

@ -35,6 +35,7 @@ type Tracker struct {
SubtractSemitoneBtn *widget.Clickable
AddOctaveBtn *widget.Clickable
SubtractOctaveBtn *widget.Clickable
NoteOffBtn *widget.Clickable
SongLength *NumberInput
PanicBtn *widget.Clickable
CopyInstrumentBtn *widget.Clickable
@ -121,6 +122,7 @@ func New(audioContext sointu.AudioContext, synthService sointu.SynthService, syn
SubtractSemitoneBtn: new(widget.Clickable),
AddOctaveBtn: new(widget.Clickable),
SubtractOctaveBtn: new(widget.Clickable),
NoteOffBtn: new(widget.Clickable),
AddUnitBtn: new(widget.Clickable),
DeleteUnitBtn: new(widget.Clickable),
ClearUnitBtn: new(widget.Clickable),