Fix #326: don't refresh tracklist rows when not needed
This commit is contained in:
+49
-22
@@ -781,7 +781,11 @@ func newTrailingAlignLabel() *widget.Label {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TrackRow) Update(tm *trackModel, rowNum int) {
|
func (t *TrackRow) Update(tm *trackModel, rowNum int) {
|
||||||
t.Selected = tm.selected
|
changed := false
|
||||||
|
if tm.selected != t.Selected {
|
||||||
|
t.Selected = tm.selected
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
|
||||||
// Update info that can change if this row is bound to
|
// Update info that can change if this row is bound to
|
||||||
// a new track (*mediaprovider.Track)
|
// a new track (*mediaprovider.Track)
|
||||||
@@ -804,6 +808,7 @@ func (t *TrackRow) Update(tm *trackModel, rowNum int) {
|
|||||||
t.bitrate.Text = strconv.Itoa(tr.BitRate)
|
t.bitrate.Text = strconv.Itoa(tr.BitRate)
|
||||||
t.size.Text = util.BytesToSizeString(tr.Size)
|
t.size.Text = util.BytesToSizeString(tr.Size)
|
||||||
t.path.Text = tr.FilePath
|
t.path.Text = tr.FilePath
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update track num if needed
|
// Update track num if needed
|
||||||
@@ -824,12 +829,14 @@ func (t *TrackRow) Update(tm *trackModel, rowNum int) {
|
|||||||
str = strconv.Itoa(rowNum)
|
str = strconv.Itoa(rowNum)
|
||||||
}
|
}
|
||||||
t.num.Text = str
|
t.num.Text = 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.Text = strconv.Itoa(int(tr.PlayCount))
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render whether track is playing or not
|
// Render whether track is playing or not
|
||||||
@@ -842,34 +849,54 @@ func (t *TrackRow) Update(tm *trackModel, rowNum int) {
|
|||||||
} else {
|
} else {
|
||||||
t.Content.(*fyne.Container).Objects[0] = t.num
|
t.Content.(*fyne.Container).Objects[0] = t.num
|
||||||
}
|
}
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render favorite column
|
// Update favorite column
|
||||||
if tr.Favorite {
|
if tr.Favorite != t.isFavorite {
|
||||||
t.isFavorite = true
|
if tr.Favorite {
|
||||||
t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.FavoriteIcon
|
t.isFavorite = true
|
||||||
} else {
|
t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.FavoriteIcon
|
||||||
t.isFavorite = false
|
} else {
|
||||||
t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.NotFavoriteIcon
|
t.isFavorite = false
|
||||||
|
t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.NotFavoriteIcon
|
||||||
|
}
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
t.rating.Rating = tr.Rating
|
// Update rating column
|
||||||
|
if t.rating.Rating != tr.Rating {
|
||||||
|
t.rating.Rating = tr.Rating
|
||||||
|
t.rating.Refresh()
|
||||||
|
}
|
||||||
|
if t.rating.IsDisabled != t.tracklist.Options.DisableRating {
|
||||||
|
t.rating.IsDisabled = t.tracklist.Options.DisableRating
|
||||||
|
t.rating.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
// Show only columns configured to be visible
|
// Show only columns configured to be visible
|
||||||
t.artist.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnArtist)]
|
updateHidden := func(hiddenPtr *bool, colName string) {
|
||||||
t.album.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnAlbum)]
|
colHidden := !t.tracklist.visibleColumns[ColNumber(colName)]
|
||||||
t.dur.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnTime)]
|
if colHidden != *hiddenPtr {
|
||||||
t.year.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnYear)]
|
*hiddenPtr = colHidden
|
||||||
t.favorite.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnFavorite)]
|
changed = true
|
||||||
t.rating.IsDisabled = t.tracklist.Options.DisableRating
|
}
|
||||||
t.rating.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnRating)]
|
}
|
||||||
t.plays.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnPlays)]
|
updateHidden(&t.artist.Hidden, ColumnArtist)
|
||||||
t.comment.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnComment)]
|
updateHidden(&t.album.Hidden, ColumnAlbum)
|
||||||
t.bitrate.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnBitrate)]
|
updateHidden(&t.dur.Hidden, ColumnTime)
|
||||||
t.size.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnSize)]
|
updateHidden(&t.year.Hidden, ColumnYear)
|
||||||
t.path.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnPath)]
|
updateHidden(&t.favorite.Hidden, ColumnFavorite)
|
||||||
|
updateHidden(&t.rating.Hidden, ColumnRating)
|
||||||
|
updateHidden(&t.plays.Hidden, ColumnPlays)
|
||||||
|
updateHidden(&t.comment.Hidden, ColumnComment)
|
||||||
|
updateHidden(&t.bitrate.Hidden, ColumnBitrate)
|
||||||
|
updateHidden(&t.size.Hidden, ColumnSize)
|
||||||
|
updateHidden(&t.path.Hidden, ColumnPath)
|
||||||
|
|
||||||
t.Refresh()
|
if changed {
|
||||||
|
t.Refresh()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TrackRow) toggleFavorited() {
|
func (t *TrackRow) toggleFavorited() {
|
||||||
|
|||||||
Reference in New Issue
Block a user