Add pop up plqy queue button to lower right

This commit is contained in:
Drew Weymouth
2024-07-24 17:36:47 -07:00
parent 56c68450ae
commit 6f74b5a2b8
12 changed files with 282 additions and 158 deletions
+16
View File
@@ -2,6 +2,7 @@ package widgets
import (
"image"
"slices"
"strconv"
"sync"
@@ -134,6 +135,12 @@ func (p *PlayQueueList) SetItems(items []mediaprovider.MediaItem) {
p.Refresh()
}
func (p *PlayQueueList) Items() []mediaprovider.MediaItem {
return sharedutil.MapSlice(p.items, func(item *util.TrackListModel) mediaprovider.MediaItem {
return item.Item
})
}
// Sets the currently playing item ID and updates the list rendering
func (p *PlayQueueList) SetNowPlaying(itemID string) {
prevNowPlaying := p.nowPlayingID
@@ -168,6 +175,15 @@ func (p *PlayQueueList) Scroll(amount float32) {
p.list.ScrollToOffset(p.list.GetScrollOffset() + amount)
}
func (p *PlayQueueList) ScrollToNowPlaying() {
idx := slices.IndexFunc(p.items, func(item *util.TrackListModel) bool {
return item.Item.Metadata().ID == p.nowPlayingID
})
if idx > 0 {
p.list.ScrollTo(idx)
}
}
func (p *PlayQueueList) Refresh() {
p.list.EnableDragging = p.Reorderable
p.BaseWidget.Refresh()