From 0fb1e5fa178af9d39685c034ba09b9cd3c6fa238 Mon Sep 17 00:00:00 2001 From: Siiiiinth <60766886+Siiiiinth@users.noreply.github.com> Date: Wed, 14 Jan 2026 22:47:31 +0100 Subject: [PATCH] wip ui --- backend/playbackengine.go | 2 ++ ui/widgets/auxcontrols.go | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/playbackengine.go b/backend/playbackengine.go index 1491c50..b10450b 100644 --- a/backend/playbackengine.go +++ b/backend/playbackengine.go @@ -65,6 +65,7 @@ type playbackEngine struct { nowPlayingIdx int isRadio bool loopMode LoopMode + shuffle bool pauseAfterCurrent bool // flag to pause playback after current track ends @@ -97,6 +98,7 @@ type playbackEngine struct { onSongChange []func(nowPlaying mediaprovider.MediaItem, justScrobbledIfAny *mediaprovider.Track) onPlayTimeUpdate []func(float64, float64, bool) onLoopModeChange []func(LoopMode) + onShuffleChange []func() onVolumeChange []func(int) onSeek []func() onPaused []func() diff --git a/ui/widgets/auxcontrols.go b/ui/widgets/auxcontrols.go index 558ea72..3da8839 100644 --- a/ui/widgets/auxcontrols.go +++ b/ui/widgets/auxcontrols.go @@ -22,8 +22,10 @@ type AuxControls struct { widget.BaseWidget OnChangeAutoplay func(autoplay bool) + OnChangeShuffle func(shuffle bool) VolumeControl *VolumeControl + shuffle *IconButton autoplay *IconButton loop *IconButton cast *IconButton @@ -35,12 +37,22 @@ type AuxControls struct { func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode, initialAutoplay bool) *AuxControls { a := &AuxControls{ VolumeControl: NewVolumeControl(initialVolume), + shuffle: NewIconButton(myTheme.ShuffleIcon, nil), autoplay: NewIconButton(myTheme.AutoplayIcon, nil), loop: NewIconButton(myTheme.RepeatIcon, nil), cast: NewIconButton(myTheme.CastIcon, nil), showQueue: NewIconButton(myTheme.PlayQueueIcon, nil), } + a.shuffle.IconSize = IconButtonSizeSmaller + a.shuffle.SetToolTip(lang.L("Shuffle")) + a.shuffle.OnTapped = func() { + a.SetShuffle(!a.shuffle.Highlighted) + if a.OnChangeShuffle != nil { + a.OnChangeShuffle(a.shuffle.Highlighted) + } + } + a.loop.IconSize = IconButtonSizeSmaller a.loop.SetToolTip(lang.L("Repeat")) a.SetLoopMode(initialLoopMode) @@ -68,7 +80,7 @@ func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode, initial a.VolumeControl, container.New( layout.NewCustomPaddedHBoxLayout(theme.Padding()*1.5), - layout.NewSpacer(), a.autoplay, a.loop, a.cast, a.showQueue, util.NewHSpace(5)), + layout.NewSpacer(), a.autoplay, a.shuffle, a.loop, a.cast, a.showQueue, util.NewHSpace(5)), layout.NewSpacer(), ), ) @@ -98,6 +110,14 @@ func (a *AuxControls) SetLoopMode(mode backend.LoopMode) { } } +func (a *AuxControls) SetShuffle(isShuffle bool) { + if isShuffle { + a.shuffle.Highlighted = true + } else { + a.shuffle.Highlighted = false + } +} + func (a *AuxControls) DisableCastButton() { a.cast.Disable() }