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"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/driver/desktop"
|
"fyne.io/fyne/v2/driver/desktop"
|
||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
@@ -100,15 +101,25 @@ type Tracklist struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTracklist(tracks []*mediaprovider.Track, im *backend.ImageManager, useCompactRows bool) *Tracklist {
|
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 := &Tracklist{compactRows: useCompactRows}
|
||||||
|
t.ExtendBaseWidget(t)
|
||||||
t.columns = ExpandedTracklistRowColumns
|
t.columns = ExpandedTracklistRowColumns
|
||||||
colWidths := ExpandedTracklistRowColumnWidths
|
colWidths := ExpandedTracklistRowColumnWidths
|
||||||
|
var playingIcon fyne.CanvasObject
|
||||||
if useCompactRows {
|
if useCompactRows {
|
||||||
t.columns = CompactTracklistRowColumns
|
t.columns = CompactTracklistRowColumns
|
||||||
colWidths = CompactTracklistRowColumnWidths
|
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.visibleColumns = make([]bool, len(t.columns))
|
||||||
t.ExtendBaseWidget(t)
|
|
||||||
|
|
||||||
if len(tracks) > 0 {
|
if len(tracks) > 0 {
|
||||||
t._setTracks(tracks)
|
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.list = NewFocusList(
|
||||||
t.lenTracks,
|
t.lenTracks,
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ type tracklistRowBase struct {
|
|||||||
// set by extending widget
|
// set by extending widget
|
||||||
playingIcon fyne.CanvasObject
|
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
|
// internal state
|
||||||
tracklist *Tracklist
|
tracklist *Tracklist
|
||||||
trackNum int
|
trackNum int
|
||||||
@@ -108,6 +112,7 @@ type tracklistRowBase struct {
|
|||||||
size *widget.Label
|
size *widget.Label
|
||||||
path *widget.Label
|
path *widget.Label
|
||||||
|
|
||||||
|
// must be injected by extending widget
|
||||||
setColVisibility func(int, bool) bool
|
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
|
t.name.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = isPlaying
|
||||||
|
|
||||||
if isPlaying {
|
if isPlaying {
|
||||||
|
t.originalNumColContent = t.Content.(*fyne.Container).Objects[0]
|
||||||
t.Content.(*fyne.Container).Objects[0] = t.playingIcon
|
t.Content.(*fyne.Container).Objects[0] = t.playingIcon
|
||||||
} else {
|
} else {
|
||||||
t.Content.(*fyne.Container).Objects[0] = t.num
|
t.Content.(*fyne.Container).Objects[0] = t.originalNumColContent
|
||||||
}
|
}
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user