mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat(tracker): implement saving and loading a song file
This commit is contained in:
@ -20,6 +20,8 @@ import (
|
||||
var upIcon *widget.Icon
|
||||
var downIcon *widget.Icon
|
||||
var addIcon *widget.Icon
|
||||
var loadIcon *widget.Icon
|
||||
var saveIcon *widget.Icon
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
@ -35,6 +37,14 @@ func init() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
loadIcon, err = widget.NewIcon(icons.FileFolder)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
saveIcon, err = widget.NewIcon(icons.ContentSave)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func smallButton(icStyle material.IconButtonStyle) material.IconButtonStyle {
|
||||
@ -170,6 +180,14 @@ func (t *Tracker) layoutControls(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
}()
|
||||
|
||||
for t.LoadSongFileBtn.Clicked() {
|
||||
t.LoadSongFile()
|
||||
}
|
||||
|
||||
for t.SaveSongFileBtn.Clicked() {
|
||||
t.SaveSongFile()
|
||||
}
|
||||
|
||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||
layout.Rigid(t.layoutPatterns(
|
||||
t.song.Tracks,
|
||||
@ -190,6 +208,14 @@ func (t *Tracker) layoutControls(gtx layout.Context) layout.Dimensions {
|
||||
iconBtn := enableButton(material.IconButton(t.Theme, t.NewInstrumentBtn, addIcon), t.song.Patch.TotalVoices() < 32)
|
||||
return in.Layout(gtx, iconBtn.Layout)
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
iconBtn := material.IconButton(t.Theme, t.LoadSongFileBtn, loadIcon)
|
||||
return in.Layout(gtx, iconBtn.Layout)
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
iconBtn := material.IconButton(t.Theme, t.SaveSongFileBtn, saveIcon)
|
||||
return in.Layout(gtx, iconBtn.Layout)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user