use larger playing icon for expanded tracklist rows and fix positioning bug when replacing back with track number
This commit is contained in:
+12
-5
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/driver/desktop"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
@@ -100,15 +101,25 @@ type Tracklist struct {
|
||||
}
|
||||
|
||||
func NewTracklist(tracks []*mediaprovider.Track, im *backend.ImageManager, useCompactRows bool) *Tracklist {
|
||||
playIcon := theme.NewThemedResource(theme.MediaPlayIcon())
|
||||
playIcon.ColorName = theme.ColorNamePrimary
|
||||
|
||||
t := &Tracklist{compactRows: useCompactRows}
|
||||
t.ExtendBaseWidget(t)
|
||||
t.columns = ExpandedTracklistRowColumns
|
||||
colWidths := ExpandedTracklistRowColumnWidths
|
||||
var playingIcon fyne.CanvasObject
|
||||
if useCompactRows {
|
||||
t.columns = CompactTracklistRowColumns
|
||||
colWidths = CompactTracklistRowColumnWidths
|
||||
playingIcon = container.NewCenter(container.NewHBox(util.NewHSpace(2), widget.NewIcon(playIcon)))
|
||||
} else {
|
||||
playIconImg := canvas.NewImageFromResource(playIcon)
|
||||
playIconImg.FillMode = canvas.ImageFillContain
|
||||
playIconImg.SetMinSize(fyne.NewSquareSize(theme.IconInlineSize() * 1.5))
|
||||
playingIcon = container.NewCenter(playIconImg)
|
||||
}
|
||||
t.visibleColumns = make([]bool, len(t.columns))
|
||||
t.ExtendBaseWidget(t)
|
||||
|
||||
if len(tracks) > 0 {
|
||||
t._setTracks(tracks)
|
||||
@@ -125,10 +136,6 @@ func NewTracklist(tracks []*mediaprovider.Track, im *backend.ImageManager, useCo
|
||||
}
|
||||
}
|
||||
|
||||
playIcon := theme.NewThemedResource(theme.MediaPlayIcon())
|
||||
playIcon.ColorName = theme.ColorNamePrimary
|
||||
playingIcon := container.NewCenter(container.NewHBox(util.NewHSpace(2), widget.NewIcon(playIcon)))
|
||||
|
||||
t.list = NewFocusList(
|
||||
t.lenTracks,
|
||||
func() fyne.CanvasObject {
|
||||
|
||||
@@ -86,6 +86,10 @@ type tracklistRowBase struct {
|
||||
// set by extending widget
|
||||
playingIcon fyne.CanvasObject
|
||||
|
||||
// when replacing the content of col 0 with playing icon,
|
||||
// the original content is saved here for resetting
|
||||
originalNumColContent fyne.CanvasObject
|
||||
|
||||
// internal state
|
||||
tracklist *Tracklist
|
||||
trackNum int
|
||||
@@ -108,6 +112,7 @@ type tracklistRowBase struct {
|
||||
size *widget.Label
|
||||
path *widget.Label
|
||||
|
||||
// must be injected by extending widget
|
||||
setColVisibility func(int, bool) bool
|
||||
}
|
||||
|
||||
@@ -303,9 +308,10 @@ func (t *tracklistRowBase) Update(tm *util.TrackListModel, rowNum int) {
|
||||
t.name.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = isPlaying
|
||||
|
||||
if isPlaying {
|
||||
t.originalNumColContent = t.Content.(*fyne.Container).Objects[0]
|
||||
t.Content.(*fyne.Container).Objects[0] = t.playingIcon
|
||||
} else {
|
||||
t.Content.(*fyne.Container).Objects[0] = t.num
|
||||
t.Content.(*fyne.Container).Objects[0] = t.originalNumColContent
|
||||
}
|
||||
changed = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user