Skip to content

Commit

Permalink
Merge pull request #392 from dweymouth/feat/tracklist-thumbnails
Browse files Browse the repository at this point in the history
Add tracklist row thumbnails to everything but album page
  • Loading branch information
dweymouth authored May 31, 2024
2 parents 3fb3922 + 84d9372 commit 3e21a08
Show file tree
Hide file tree
Showing 12 changed files with 469 additions and 280 deletions.
6 changes: 3 additions & 3 deletions backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ func DefaultConfig(appVersionTag string) *Config {
SortOrder: string("Name (A-Z)"),
},
FavoritesPage: FavoritesPageConfig{
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
TracklistColumns: []string{"Album", "Time", "Plays"},
InitialView: "Albums",
},
PlaylistPage: PlaylistPageConfig{
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
TracklistColumns: []string{"Album", "Time", "Plays"},
},
PlaylistsPage: PlaylistsPageConfig{
InitialView: "List",
Expand All @@ -189,7 +189,7 @@ func DefaultConfig(appVersionTag string) *Config {
InitialView: "Play Queue",
},
TracksPage: TracksPageConfig{
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
TracklistColumns: []string{"Album", "Time", "Plays"},
},
LocalPlayback: LocalPlaybackConfig{
// "auto" is the name to pass to MPV for autoselecting the output device
Expand Down
6 changes: 3 additions & 3 deletions ui/browsing/albumpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ func newAlbumPage(
a.header = NewAlbumPageHeader(a)
}
a.header.page = a
if t := a.pool.Obtain(util.WidgetTypeTracklist); t != nil {
if t := a.pool.Obtain(util.WidgetTypeCompactTracklist); t != nil {
a.tracklist = t.(*widgets.Tracklist)
a.tracklist.Reset()
} else {
a.tracklist = widgets.NewTracklist(nil)
a.tracklist = widgets.NewTracklist(nil, a.im, true)
}
a.tracklist.SetVisibleColumns(a.cfg.TracklistColumns)
a.tracklist.SetSorting(sort)
Expand Down Expand Up @@ -122,7 +122,7 @@ func (a *AlbumPage) Save() SavedPage {
a.header.page = nil
a.pool.Release(util.WidgetTypeAlbumPageHeader, a.header)
a.tracklist.Clear()
a.pool.Release(util.WidgetTypeTracklist, a.tracklist)
a.pool.Release(util.WidgetTypeCompactTracklist, a.tracklist)
return &s
}

Expand Down
2 changes: 1 addition & 1 deletion ui/browsing/artistpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (a *ArtistPage) showTopTracks() {
tl.Reset()
tl.SetTracks(ts)
} else {
tl = widgets.NewTracklist(ts)
tl = widgets.NewTracklist(ts, a.im, false)
}
tl.Options = widgets.TracklistOptions{AutoNumber: true}
_, canRate := a.mp.(mediaprovider.SupportsRating)
Expand Down
2 changes: 1 addition & 1 deletion ui/browsing/favoritespage.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (a *FavoritesPage) onShowFavoriteSongs() {
tracklist.Reset()
tracklist.SetTracks(fav.Tracks)
} else {
tracklist = widgets.NewTracklist(fav.Tracks)
tracklist = widgets.NewTracklist(fav.Tracks, a.im, false)
}
tracklist.Options = widgets.TracklistOptions{AutoNumber: true}
_, canRate := a.mp.(mediaprovider.SupportsRating)
Expand Down
2 changes: 1 addition & 1 deletion ui/browsing/playlistpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newPlaylistPage(
a.tracklist = tl.(*widgets.Tracklist)
a.tracklist.Reset()
} else {
a.tracklist = widgets.NewTracklist(nil)
a.tracklist = widgets.NewTracklist(nil, a.im, false)
}
a.tracklist.SetVisibleColumns(conf.TracklistColumns)
a.tracklist.SetSorting(trackSort)
Expand Down
2 changes: 1 addition & 1 deletion ui/browsing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r Router) CreatePage(rte controller.Route) Page {
case controller.Playlists:
return NewPlaylistsPage(r.Controller, r.widgetPool, &r.App.Config.PlaylistsPage, r.App.ServerManager.Server)
case controller.Tracks:
return NewTracksPage(r.Controller, &r.App.Config.TracksPage, r.widgetPool, r.App.ServerManager.Server)
return NewTracksPage(r.Controller, &r.App.Config.TracksPage, r.widgetPool, r.App.ServerManager.Server, r.App.ImageManager)
}
return nil
}
Expand Down
9 changes: 5 additions & 4 deletions ui/browsing/trackspage.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ type tracksPageState struct {
contr *controller.Controller
conf *backend.TracksPageConfig
mp mediaprovider.MediaProvider
im *backend.ImageManager
canRate bool
canShare bool
}

func NewTracksPage(contr *controller.Controller, conf *backend.TracksPageConfig, pool *util.WidgetPool, mp mediaprovider.MediaProvider) *TracksPage {
t := &TracksPage{tracksPageState: tracksPageState{contr: contr, conf: conf, widgetPool: pool, mp: mp}}
func NewTracksPage(contr *controller.Controller, conf *backend.TracksPageConfig, pool *util.WidgetPool, mp mediaprovider.MediaProvider, im *backend.ImageManager) *TracksPage {
t := &TracksPage{tracksPageState: tracksPageState{contr: contr, conf: conf, widgetPool: pool, mp: mp, im: im}}
t.ExtendBaseWidget(t)

t.tracklist = t.obtainTracklist()
Expand Down Expand Up @@ -175,7 +176,7 @@ func (t *TracksPage) Save() SavedPage {
}

func (s *tracksPageState) Restore() Page {
t := NewTracksPage(s.contr, s.conf, s.widgetPool, s.mp)
t := NewTracksPage(s.contr, s.conf, s.widgetPool, s.mp, s.im)
t.searchText = s.searchText
if t.searchText != "" {
t.searcher.Entry.Text = t.searchText
Expand All @@ -194,5 +195,5 @@ func (t *TracksPage) obtainTracklist() *widgets.Tracklist {
tracklist.Reset()
return tracklist
}
return widgets.NewTracklist(nil)
return widgets.NewTracklist(nil, t.im, false)
}
1 change: 1 addition & 0 deletions ui/util/widgetpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
WidgetTypeGridView
WidgetTypePlaylistPageHeader
WidgetTypeTracklist
WidgetTypeCompactTracklist
WidgetTypeNowPlayingPage

// keep at bottom
Expand Down
21 changes: 21 additions & 0 deletions ui/widgets/focuslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ type FocusList struct {
type FocusListRow interface {
fyne.Focusable
ItemID() widget.ListItemID
SetItemID(widget.ListItemID)

SetOnTapped(func())
SetOnDoubleTapped(func())
SetOnFocusNeighbor(func(up bool))
}

func NewFocusList(len func() int, create func() fyne.CanvasObject, update func(widget.GridWrapItemID, fyne.CanvasObject)) *FocusList {
Expand Down Expand Up @@ -101,10 +106,26 @@ type FocusListRowBase struct {
selectionRect *canvas.Rectangle
}

func (l *FocusListRowBase) SetOnTapped(f func()) {
l.OnTapped = f
}

func (l *FocusListRowBase) SetOnDoubleTapped(f func()) {
l.OnDoubleTapped = f
}

func (l *FocusListRowBase) SetOnFocusNeighbor(f func(up bool)) {
l.OnFocusNeighbor = f
}

func (l *FocusListRowBase) ItemID() widget.ListItemID {
return l.ListItemID
}

func (l *FocusListRowBase) SetItemID(id widget.ListItemID) {
l.ListItemID = id
}

func (l *FocusListRowBase) EnsureUnfocused() {
if l.Focused {
fyne.CurrentApp().Driver().CanvasForObject(l).Unfocus()
Expand Down
4 changes: 2 additions & 2 deletions ui/widgets/playqueuelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/dweymouth/supersonic/ui/util"
)

const thumbnailSize = 52
const playQueueListThumbnailSize = 52

type PlayQueueList struct {
widget.BaseWidget
Expand Down Expand Up @@ -298,7 +298,7 @@ func NewPlayQueueListRow(playQueueList *PlayQueueList, im *backend.ImageManager,
playingIcon: playingIcon,
playQueueList: playQueueList,
num: widget.NewLabel(""),
cover: NewImagePlaceholder(myTheme.TracksIcon, thumbnailSize),
cover: NewImagePlaceholder(myTheme.TracksIcon, playQueueListThumbnailSize),
title: util.NewTruncatingLabel(),
artist: NewMultiHyperlink(),
time: util.NewTrailingAlignLabel(),
Expand Down
Loading

0 comments on commit 3e21a08

Please sign in to comment.