refactor(tracker): use go v1.23 style iterators throughout

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-10-15 00:01:02 +03:00
parent 2b7ce39069
commit 97e59c5650
7 changed files with 108 additions and 87 deletions

View File

@ -102,11 +102,10 @@ func (pe *UnitEditor) layoutSliders(gtx C, t *Tracker) D {
}
index := 0
t.Model.Params().Iterate(func(param tracker.Parameter) {
for param := range t.Model.Params().Iterate() {
pe.Parameters[index].Parameter = param
index++
})
}
element := func(gtx C, index int) D {
if index < 0 || index >= numItems {
return D{}
@ -177,12 +176,12 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
func (pe *UnitEditor) layoutUnitTypeChooser(gtx C, t *Tracker) D {
var names [256]string
index := 0
t.Model.SearchResults().Iterate(func(item string) (ok bool) {
names[index] = item
index++
return index <= 256
})
for i, item := range t.Model.SearchResults().Iterate() {
if i >= 256 {
break
}
names[i] = item
}
element := func(gtx C, i int) D {
w := LabelStyle{Text: names[i], ShadeColor: black, Color: white, Font: labelDefaultFont, FontSize: unit.Sp(12), Shaper: t.Theme.Shaper}
if i == pe.searchList.TrackerList.Selected() {