more tracklist rendering optimization

This commit is contained in:
Drew Weymouth
2026-01-23 18:49:15 -08:00
parent de7c49eca3
commit 0bb5f969ff
+9 -10
View File
@@ -466,10 +466,10 @@ func (t *tracklistRowBase) needsUpdate(tm *util.TrackListModel, rowNum int) bool
} }
func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) { func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
changed := false fullRefresh := false
if tm.Selected != t.Selected { if tm.Selected != t.Selected {
t.Selected = tm.Selected t.Selected = tm.Selected
changed = true fullRefresh = true
} }
// Update info that can change if this row is bound to // Update info that can change if this row is bound to
@@ -504,7 +504,7 @@ func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
t.dateAdded.Text = util.FormatDate(tr.DateAdded) t.dateAdded.Text = util.FormatDate(tr.DateAdded)
t.path.Text = tr.FilePath t.path.Text = tr.FilePath
t.path.SetToolTip(tr.FilePath) t.path.SetToolTip(tr.FilePath)
changed = true fullRefresh = true
} }
// Update track num if needed // Update track num if needed
@@ -524,21 +524,20 @@ func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
} else { } else {
str = strconv.Itoa(rowNum) str = strconv.Itoa(rowNum)
} }
t.num.Text = str t.num.SetText(str)
changed = true
} }
// Update play count if needed // Update play count if needed
if tr.PlayCount != t.playCount { if tr.PlayCount != t.playCount {
t.playCount = tr.PlayCount t.playCount = tr.PlayCount
t.plays.Text = strconv.Itoa(int(tr.PlayCount)) t.plays.SetText(strconv.Itoa(int(tr.PlayCount)))
changed = true
} }
// Render whether track is playing or not // Render whether track is playing or not
if isPlaying := t.tracklist.nowPlayingID == tr.ID; isPlaying != t.isPlaying { if isPlaying := t.tracklist.nowPlayingID == tr.ID; isPlaying != t.isPlaying {
t.isPlaying = isPlaying t.isPlaying = isPlaying
t.name.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = isPlaying t.name.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = isPlaying
t.name.Refresh()
if isPlaying { if isPlaying {
t.originalNumColContent = t.Content.(*fyne.Container).Objects[0] t.originalNumColContent = t.Content.(*fyne.Container).Objects[0]
@@ -546,14 +545,14 @@ func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
} else { } else {
t.Content.(*fyne.Container).Objects[0] = t.originalNumColContent t.Content.(*fyne.Container).Objects[0] = t.originalNumColContent
} }
changed = true canvas.Refresh(t)
} }
// Update favorite column // Update favorite column
if tr.Favorite != t.isFavorite { if tr.Favorite != t.isFavorite {
t.isFavorite = tr.Favorite t.isFavorite = tr.Favorite
t.favorite.Objects[0].(*FavoriteIcon).Favorite = tr.Favorite t.favorite.Objects[0].(*FavoriteIcon).Favorite = tr.Favorite
changed = true canvas.Refresh(t.favorite)
} }
// Update rating column // Update rating column
@@ -566,7 +565,7 @@ func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
t.rating.Refresh() t.rating.Refresh()
} }
if changed { if fullRefresh {
tracklistUpdateCounter.Add() tracklistUpdateCounter.Add()
t.Refresh() t.Refresh()
} }