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
+10 -1
View File
@@ -19,6 +19,7 @@ type AuxControls struct {
VolumeControl *VolumeControl
loop *IconButton
showQueue *IconButton
container *fyne.Container
}
@@ -27,14 +28,18 @@ func NewAuxControls(initialVolume int) *AuxControls {
a := &AuxControls{
VolumeControl: NewVolumeControl(initialVolume),
loop: NewIconButton(myTheme.RepeatIcon, nil),
showQueue: NewIconButton(myTheme.PlayQueueIcon, nil),
}
a.loop.IconSize = IconButtonSizeSmaller
a.showQueue.IconSize = IconButtonSizeSmaller
a.container = container.NewHBox(
layout.NewSpacer(),
container.NewVBox(
layout.NewSpacer(),
a.VolumeControl,
container.NewHBox(layout.NewSpacer(), a.loop, util.NewHSpace(5)),
container.New(
layout.NewCustomPaddedHBoxLayout(theme.Padding()*1.5),
layout.NewSpacer(), a.loop, a.showQueue, util.NewHSpace(5)),
layout.NewSpacer(),
),
)
@@ -64,6 +69,10 @@ func (a *AuxControls) SetLoopMode(mode backend.LoopMode) {
}
}
func (a *AuxControls) OnShowPlayQueue(f func()) {
a.showQueue.OnTapped = f
}
type volumeSlider struct {
widget.Slider
+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()