refactor(tracker): Make Action have separate Doer and Enabler

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-05-26 13:35:31 +03:00
parent d6badb97be
commit 036cb1f34d
7 changed files with 600 additions and 480 deletions

View File

@ -332,11 +332,11 @@ func (p ParameterStyle) Layout(gtx C) D {
name, _, _, _ := p.tracker.Instruments().Item(i)
instrItems[i].Text = name
instrItems[i].IconBytes = icons.NavigationChevronRight
instrItems[i].Doer = tracker.Allow(func() {
instrItems[i].Doer = tracker.MakeEnabledAction((tracker.DoFunc)(func() {
if id, ok := p.tracker.Instruments().FirstID(i); ok {
tracker.Int{IntData: p.w.Parameter}.Set(id)
}
})
}))
}
var unitItems []MenuItem
instrName := "<instr>"
@ -350,9 +350,9 @@ func (p ParameterStyle) Layout(gtx C) D {
id := unit.ID
unitItems[j].Text = buildUnitLabel(j, unit)
unitItems[j].IconBytes = icons.NavigationChevronRight
unitItems[j].Doer = tracker.Allow(func() {
unitItems[j].Doer = tracker.MakeEnabledAction((tracker.DoFunc)(func() {
tracker.Int{IntData: p.w.Parameter}.Set(id)
})
}))
}
}
defer pointer.PassOp{}.Push(gtx.Ops).Pop()