feat(gioui): implement own file save / load dialogs

Removes the dependency on sqweek/dialogs, which was always very buggy.

Closes #12
This commit is contained in:
vsariola
2021-04-18 19:10:41 +03:00
parent ac95fb65c4
commit 147e8a2513
10 changed files with 464 additions and 100 deletions

View File

@ -73,12 +73,18 @@ type Tracker struct {
ConfirmInstrDelete *Dialog
ConfirmSongDialog *Dialog
WaveTypeDialog *Dialog
OpenSongDialog *FileDialog
SaveSongDialog *FileDialog
OpenInstrumentDialog *FileDialog
SaveInstrumentDialog *FileDialog
ExportWavDialog *FileDialog
ConfirmSongActionType int
window *app.Window
lastVolume tracker.Volume
volumeChan chan tracker.Volume
wavFilePath string
player *tracker.Player
refresh chan struct{}
playerCloser chan struct{}
@ -172,9 +178,15 @@ func New(audioContext sointu.AudioContext, synthService sointu.SynthService, syn
ConfirmInstrDelete: new(Dialog),
ConfirmSongDialog: new(Dialog),
WaveTypeDialog: new(Dialog),
errorChannel: make(chan error, 32),
window: window,
synthService: synthService,
OpenSongDialog: NewFileDialog(),
SaveSongDialog: NewFileDialog(),
OpenInstrumentDialog: NewFileDialog(),
SaveInstrumentDialog: NewFileDialog(),
ExportWavDialog: NewFileDialog(),
errorChannel: make(chan error, 32),
window: window,
synthService: synthService,
}
t.Model = tracker.NewModel()
vuBufferObserver := make(chan []float32)
@ -203,3 +215,13 @@ func New(audioContext sointu.AudioContext, synthService sointu.SynthService, syn
t.ResetSong()
return t
}
func (t *Tracker) Quit(forced bool) bool {
if !forced && t.ChangedSinceSave() {
t.ConfirmSongActionType = ConfirmQuit
t.ConfirmSongDialog.Visible = true
return false
}
t.quitted = true
return true
}