begin expandedtracklistrow
This commit is contained in:
@@ -21,8 +21,6 @@ import (
|
|||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const thumbnailSize = 52
|
|
||||||
|
|
||||||
type PlayQueueList struct {
|
type PlayQueueList struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
@@ -298,7 +296,7 @@ func NewPlayQueueListRow(playQueueList *PlayQueueList, im *backend.ImageManager,
|
|||||||
playingIcon: playingIcon,
|
playingIcon: playingIcon,
|
||||||
playQueueList: playQueueList,
|
playQueueList: playQueueList,
|
||||||
num: widget.NewLabel(""),
|
num: widget.NewLabel(""),
|
||||||
cover: NewImagePlaceholder(myTheme.TracksIcon, thumbnailSize),
|
cover: NewImagePlaceholder(myTheme.TracksIcon, tracklistThumbnailSize),
|
||||||
title: util.NewTruncatingLabel(),
|
title: util.NewTruncatingLabel(),
|
||||||
artist: NewMultiHyperlink(),
|
artist: NewMultiHyperlink(),
|
||||||
time: util.NewTrailingAlignLabel(),
|
time: util.NewTrailingAlignLabel(),
|
||||||
|
|||||||
@@ -2,14 +2,21 @@ package widgets
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"github.com/dweymouth/supersonic/backend"
|
||||||
|
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const tracklistThumbnailSize = 52
|
||||||
|
|
||||||
type tracklistRowBase struct {
|
type tracklistRowBase struct {
|
||||||
FocusListRowBase
|
FocusListRowBase
|
||||||
|
|
||||||
@@ -50,6 +57,9 @@ type TracklistRow interface {
|
|||||||
|
|
||||||
type ExpandedTracklistRow struct {
|
type ExpandedTracklistRow struct {
|
||||||
tracklistRowBase
|
tracklistRowBase
|
||||||
|
|
||||||
|
img *ImagePlaceholder
|
||||||
|
imageLoader util.ThumbnailLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompactTracklistRow struct {
|
type CompactTracklistRow struct {
|
||||||
@@ -61,8 +71,36 @@ var (
|
|||||||
_ TracklistRow = (*ExpandedTracklistRow)(nil)
|
_ TracklistRow = (*ExpandedTracklistRow)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *ExpandedTracklistRow {
|
func NewExpandedTracklistRow(tracklist *Tracklist, im *backend.ImageManager, playingIcon fyne.CanvasObject) *ExpandedTracklistRow {
|
||||||
return nil
|
t := &ExpandedTracklistRow{}
|
||||||
|
t.ExtendBaseWidget(t)
|
||||||
|
t.tracklistRowBase.create(tracklist)
|
||||||
|
t.playingIcon = playingIcon
|
||||||
|
t.img = NewImagePlaceholder(myTheme.TracksIcon, tracklistThumbnailSize)
|
||||||
|
|
||||||
|
t.imageLoader = util.NewThumbnailLoader(im, func(i image.Image) {
|
||||||
|
t.img.SetImage(i, false)
|
||||||
|
})
|
||||||
|
t.imageLoader.OnBeforeLoad = func() {
|
||||||
|
t.img.SetImage(nil, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
titleArtistImg := container.NewBorder(nil, nil,
|
||||||
|
container.NewPadded(t.img) /*left*/, nil,
|
||||||
|
container.New(layout.NewCustomPaddedVBoxLayout(theme.Padding()-15),
|
||||||
|
t.name, t.artist))
|
||||||
|
|
||||||
|
v := makeVerticallyCentered // func alias
|
||||||
|
t.Content = container.New(tracklist.colLayout,
|
||||||
|
v(t.num), titleArtistImg, v(t.album), v(t.dur), v(t.year), v(t.favorite), v(t.rating), v(t.plays), v(t.comment), v(t.bitrate), v(t.size), v(t.path))
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *ExpandedTracklistRow) Update(tm *util.TrackListModel, rowNum int) {
|
||||||
|
if t.trackID != tm.Track.ID {
|
||||||
|
t.imageLoader.Load(tm.Track.CoverArtID)
|
||||||
|
}
|
||||||
|
t.tracklistRowBase.Update(tm, rowNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *CompactTracklistRow {
|
func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *CompactTracklistRow {
|
||||||
@@ -231,3 +269,7 @@ func (t *tracklistRowBase) TappedSecondary(e *fyne.PointEvent) {
|
|||||||
t.OnTappedSecondary(e, t.ListItemID)
|
t.OnTappedSecondary(e, t.ListItemID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeVerticallyCentered(obj fyne.CanvasObject) fyne.CanvasObject {
|
||||||
|
return container.NewVBox(layout.NewSpacer(), obj, layout.NewSpacer())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user