refactor(tracker): change so that all icon initialization is a lazy & cache in iconcache

This commit is contained in:
vsariola
2021-02-01 17:57:13 +02:00
parent c667ffb4e1
commit 3cf2fc70a8
4 changed files with 30 additions and 48 deletions

View File

@ -11,6 +11,7 @@ import (
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
"golang.org/x/exp/shiny/materialdesign/icons"
)
type C = layout.Context
@ -25,7 +26,7 @@ func (t *Tracker) updateInstrumentScroll() {
}
func (t *Tracker) layoutInstruments() layout.Widget {
btnStyle := material.IconButton(t.Theme, t.NewInstrumentBtn, addIcon)
btnStyle := material.IconButton(t.Theme, t.NewInstrumentBtn, widgetForIcon(icons.ContentAdd))
btnStyle.Background = transparent
btnStyle.Inset = layout.UniformInset(unit.Dp(6))
if t.song.Patch.TotalVoices() < 32 {
@ -57,7 +58,7 @@ func (t *Tracker) layoutInstrumentHeader() layout.Widget {
return layout.Dimensions{Size: gtx.Constraints.Min}
}
header := func(gtx C) D {
deleteInstrumentBtnStyle := material.IconButton(t.Theme, t.DeleteInstrumentBtn, deleteIcon)
deleteInstrumentBtnStyle := material.IconButton(t.Theme, t.DeleteInstrumentBtn, widgetForIcon(icons.ActionDelete))
deleteInstrumentBtnStyle.Background = transparent
deleteInstrumentBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
if len(t.song.Patch.Instruments) > 1 {