add disabling of sorting where appropriate

This commit is contained in:
Drew Weymouth
2023-05-23 11:10:43 -07:00
parent 1f3559de43
commit 137e0334e0
5 changed files with 23 additions and 6 deletions
+9 -1
View File
@@ -61,6 +61,9 @@ type Tracklist struct {
// the tracklist context menu.
DisablePlaybackMenu bool
// Disables sorting the tracklist by clicking individual columns.
DisableSorting bool
// user action callbacks
OnPlayTrackAt func(int)
OnPlaySelection func(tracks []*mediaprovider.Track, shuffle bool)
@@ -92,7 +95,7 @@ type Tracklist struct {
}
func NewTracklist(tracks []*mediaprovider.Track) *Tracklist {
t := &Tracklist{tracks: tracks, visibleColumns: make([]bool, 12)}
t := &Tracklist{tracks: tracks, tracksOrigOrder: tracks, visibleColumns: make([]bool, 12)}
t.ExtendBaseWidget(t)
t.selectionMgr = util.NewListSelectionManager(t.lenTracks)
@@ -348,6 +351,11 @@ func (t *Tracklist) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(t.container)
}
func (t *Tracklist) Refresh() {
t.hdr.DisableSorting = t.DisableSorting
t.BaseWidget.Refresh()
}
func (t *Tracklist) onPlayTrackAt(idx int) {
if t.OnPlayTrackAt != nil {
t.OnPlayTrackAt(idx)