Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltips #455

Merged
merged 5 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
github.com/dweymouth/fyne-advanced-list v0.0.0-20240623145729-9c6b8f99bcfe
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64
github.com/dweymouth/fyne-tooltip v0.2.0
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645
github.com/dweymouth/go-mpv v0.0.0-20240724002347-c5e5b36f1bbf
github.com/dweymouth/go-subsonic v0.0.0-20240726004217-2e8e348ad417
Expand Down Expand Up @@ -53,4 +54,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace fyne.io/fyne/v2 v2.5.0 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240728183020-7abcad1f4139
replace fyne.io/fyne/v2 v2.5.0 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240805144743-24df77c3cc7e
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ github.com/dweymouth/fyne-advanced-list v0.0.0-20240623145729-9c6b8f99bcfe h1:ow
github.com/dweymouth/fyne-advanced-list v0.0.0-20240623145729-9c6b8f99bcfe/go.mod h1:sbOhla4VcfFb4OjXiUFTLXMPTnhRUlVrDMhB8HtWR4o=
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64 h1:RUIrnGY034rDMlcOui/daurwX5b+52KdUKhH9aXaDSg=
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64/go.mod h1:3YrjFDHMlhCsSZ/OvmJCxWm9QHSgOVWZBxnraZz9Z7c=
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240728183020-7abcad1f4139 h1:JNOd+yJlurYrdAuOiibR6/EYl+/+idFkk+wwyXiNwIQ=
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240728183020-7abcad1f4139/go.mod h1:9D4oT3NWeG+MLi/lP7ItZZyujHC/qqMJpoGTAYX5Uqc=
github.com/dweymouth/fyne-tooltip v0.2.0 h1:6Zy3gryctuPoQfYf8Xp3tjenioebMt11NBGW/QXIvxE=
github.com/dweymouth/fyne-tooltip v0.2.0/go.mod h1:zEgy7p9tSVIuy2GufFbOCoK3Q04zhyDPOotlU4G3Ma4=
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240805144743-24df77c3cc7e h1:FSTLNY9xV0+4/x9jKPXqUpwPZfhkAMz5ZnzLBkRirMw=
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240805144743-24df77c3cc7e/go.mod h1:9D4oT3NWeG+MLi/lP7ItZZyujHC/qqMJpoGTAYX5Uqc=
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645 h1:KzqSaQwG3HsTZQlEtkp0BeUy9vmYZ0rq0B15qIPSiBs=
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
github.com/dweymouth/go-mpv v0.0.0-20240724002347-c5e5b36f1bbf h1:QVjXWx7XGkSPOCEu5EL9QVY3fkdDSnG5KEkok5o1svM=
Expand Down
8 changes: 8 additions & 0 deletions res/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"Authentication failed": "Authentication failed",
"Auto": "Auto",
"Autoselect device": "Autoselect device",
"Back": "Back",
"Bit rate": "Bit rate",
"BPM": "BPM",
"Broadcast": "Broadcast",
Expand Down Expand Up @@ -73,14 +74,17 @@
"Field Recording": "Field Recording",
"File path": "File path",
"File size": "File size",
"Filter albums": "Filter albums",
"Filter genres": "Filter genres",
"Foreward": "Foreward",
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
"Frequently Played": "Frequently Played",
"General": "General",
"Genre": "Genre",
"Genres": "Genres",
"Github page": "Github page",
"Go to release page": "Go to release page",
"Hide": "Hide",
"Home": "Home",
"Home Page": "Home Page",
"hr": "hr",
"hrs": "hrs",
Expand All @@ -95,9 +99,11 @@
"Login to Server": "Login to Server",
"Lyrics": "Lyrics",
"Lyrics not available": "Lyrics not available",
"Menu": "Menu",
"min": "min",
"minutes of track have been played": "minutes of track have been played",
"Mixtape": "Mixtape",
"Mute": "Mute",
"My Server": "My Server",
"Name": "Name",
"Name (A-Z)": "Name (A-Z)",
Expand Down Expand Up @@ -139,6 +145,7 @@
"Recently Added": "Recently Added",
"Recently Played": "Recently Played",
"Related": "Related",
"Reload": "Reload",
"Remix": "Remix",
"Remove from playlist": "Remove from playlist",
"ReplayGain mode": "ReplayGain mode",
Expand All @@ -163,6 +170,7 @@
"Show": "Show",
"Show info": "Show info",
"Show notification on track change": "Show notification on track change",
"Show play queue": "Show play queue",
"Show year in album grid cards": "Show year in album grid cards",
"Shuffle": "Shuffle",
"Shuffle albums": "Shuffle albums",
Expand Down
40 changes: 25 additions & 15 deletions ui/browsing/browsingpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package browsing
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand All @@ -11,6 +12,8 @@ import (
"github.com/dweymouth/supersonic/ui/controller"
"github.com/dweymouth/supersonic/ui/layouts"
myTheme "github.com/dweymouth/supersonic/ui/theme"

ttwidget "github.com/dweymouth/fyne-tooltip/widget"
)

type Page interface {
Expand Down Expand Up @@ -60,14 +63,14 @@ type BrowsingPane struct {

curPage Page

home *widget.Button
forward *widget.Button
back *widget.Button
reload *widget.Button
home *ttwidget.Button
forward *ttwidget.Button
back *ttwidget.Button
reload *ttwidget.Button
history []SavedPage
historyIdx int

settingsBtn *widget.Button
settingsBtn *ttwidget.Button
settingsMenu *fyne.Menu
navBtnsContainer *fyne.Container
pageContainer *fyne.Container
Expand All @@ -78,22 +81,28 @@ type BrowsingPane struct {
func NewBrowsingPane(app *backend.App, contr *controller.Controller, onGoHome func()) *BrowsingPane {
b := &BrowsingPane{app: app}
b.ExtendBaseWidget(b)
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), onGoHome)
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
b.home = ttwidget.NewButtonWithIcon("", theme.HomeIcon(), onGoHome)
b.home.SetToolTip(lang.L("Home"))
b.back = ttwidget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
b.back.SetToolTip(lang.L("Back"))
b.forward = ttwidget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
b.forward.SetToolTip(lang.L("Forward"))
b.reload = ttwidget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
b.reload.SetToolTip("Reload")
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
b.app.PlaybackManager.OnSongChange(b.onSongChange)
b.app.PlaybackManager.OnPlayTimeUpdate(b.onPlayTimeUpdate)
b.app.PlaybackManager.OnQueueChange(b.onQueueChange)
bkgrnd := myTheme.NewThemedRectangle(myTheme.ColorNamePageBackground)
b.pageContainer = container.NewStack(bkgrnd, layout.NewSpacer())
b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
b.settingsBtn = ttwidget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
p := widget.NewPopUpMenu(b.settingsMenu,
fyne.CurrentApp().Driver().CanvasForObject(b.settingsBtn))
p.ShowAtPosition(fyne.NewPos(b.Size().Width-p.MinSize().Width+4,
b.navBtnsContainer.MinSize().Height+theme.Padding()))
})
quickSearchBtn := widget.NewButtonWithIcon("", theme.SearchIcon(), contr.ShowQuickSearch)
b.settingsBtn.SetToolTip("Menu")
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
quickSearchBtn := ttwidget.NewButtonWithIcon("", theme.SearchIcon(), contr.ShowQuickSearch)
quickSearchBtn.SetToolTip("Search Everywhere")
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
b.settingsMenu = fyne.NewMenu("")
b.navBtnsContainer = container.NewHBox()
b.navBtnsPageMap = map[controller.PageName]fyne.Resource{}
Expand Down Expand Up @@ -146,24 +155,25 @@ func (b *BrowsingPane) AddSettingsMenuSeparator() {
fyne.NewMenuItemSeparator())
}

func (b *BrowsingPane) AddNavigationButton(icon fyne.Resource, pageName controller.PageName, action func()) *widget.Button {
func (b *BrowsingPane) AddNavigationButton(icon fyne.Resource, pageName controller.PageName, action func()) *ttwidget.Button {
// make a copy of the icon, because it can change the color
browsingPaneIcon := theme.NewThemedResource(icon)
btn := widget.NewButtonWithIcon("", browsingPaneIcon, action)
btn := ttwidget.NewButtonWithIcon("", browsingPaneIcon, action)
btn.SetToolTip(lang.L(pageName.String()))
b.navBtnsContainer.Add(btn)
b.navBtnsPageMap[pageName] = browsingPaneIcon
return btn
}

func (b *BrowsingPane) DisableNavigationButtons() {
for _, obj := range b.navBtnsContainer.Objects {
obj.(*widget.Button).Disable()
obj.(fyne.Disableable).Disable()
}
}

func (b *BrowsingPane) EnableNavigationButtons() {
for _, obj := range b.navBtnsContainer.Objects {
obj.(*widget.Button).Enable()
obj.(fyne.Disableable).Enable()
}
}

Expand Down
70 changes: 42 additions & 28 deletions ui/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"sync"
"time"

fynetooltip "github.com/dweymouth/fyne-tooltip"
"github.com/dweymouth/supersonic/backend"
"github.com/dweymouth/supersonic/backend/mediaprovider"
"github.com/dweymouth/supersonic/backend/player"
Expand Down Expand Up @@ -49,7 +50,8 @@ type Controller struct {
RefreshPageFunc func()

popUpQueueMutex sync.Mutex
popUpQueue *widgets.PlayQueueList
popUpQueue *widget.PopUp
popUpQueueList *widgets.PlayQueueList
popUpQueueLastUsed int64
escapablePopUp *widget.PopUp
haveModal bool
Expand All @@ -64,18 +66,22 @@ func New(app *backend.App, appVersion string, mainWindow fyne.Window) *Controlle
}
c.initVisualizations()
c.App.PlaybackManager.OnQueueChange(func() {
c.popUpQueueMutex.Lock()
defer c.popUpQueueMutex.Unlock()
if c.popUpQueue != nil {
c.popUpQueue.SetItems(c.App.PlaybackManager.GetPlayQueue())
c.popUpQueueList.SetItems(c.App.PlaybackManager.GetPlayQueue())
}
})
c.App.PlaybackManager.OnSongChange(func(track mediaprovider.MediaItem, _ *mediaprovider.Track) {
c.popUpQueueMutex.Lock()
defer c.popUpQueueMutex.Unlock()
if c.popUpQueue == nil {
return
}
if track == nil {
c.popUpQueue.SetNowPlaying("")
c.popUpQueueList.SetNowPlaying("")
} else {
c.popUpQueue.SetNowPlaying(track.Metadata().ID)
c.popUpQueueList.SetNowPlaying(track.Metadata().ID)
}
})
return c
Expand Down Expand Up @@ -115,10 +121,28 @@ func (m *Controller) HaveModal() bool {
func (m *Controller) ShowPopUpPlayQueue() {
m.popUpQueueMutex.Lock()
if m.popUpQueue == nil {
m.popUpQueue = widgets.NewPlayQueueList(m.App.ImageManager, false)
m.popUpQueue.Reorderable = true
m.popUpQueue.SetItems(m.App.PlaybackManager.GetPlayQueue())
m.ConnectPlayQueuelistActions(m.popUpQueue)
m.popUpQueueList = widgets.NewPlayQueueList(m.App.ImageManager, false)
m.popUpQueueList.Reorderable = true
m.popUpQueueList.SetItems(m.App.PlaybackManager.GetPlayQueue())
m.ConnectPlayQueuelistActions(m.popUpQueueList)

title := widget.NewRichTextWithText(lang.L("Play Queue"))
title.Segments[0].(*widget.TextSegment).Style.Alignment = fyne.TextAlignCenter
title.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = true
ctr := container.NewBorder(title, nil, nil, nil,
container.NewPadded(m.popUpQueueList),
)
m.popUpQueue = widget.NewPopUp(ctr, m.MainWindow.Canvas())
fynetooltip.AddPopUpToolTipLayer(m.popUpQueue)

container.NewThemeOverride(m.popUpQueue, myTheme.WithColorTransformOverride(
theme.ColorNameOverlayBackground,
func(c color.Color) color.Color {
c_ := c.(color.NRGBA)
c_.A = 245
return c_
},
))

// free popUpQueue if it hasn't been used in awhile
go func() {
Expand All @@ -127,7 +151,9 @@ func (m *Controller) ShowPopUpPlayQueue() {
m.popUpQueueMutex.Lock()
now := time.Now().UnixMilli()
if m.popUpQueueLastUsed < now-120_000 /*2 min*/ {
fynetooltip.DestroyPopUpToolTipLayer(m.popUpQueue)
m.popUpQueue = nil
m.popUpQueueList = nil
m.popUpQueueLastUsed = 0
m.popUpQueueMutex.Unlock()
t.Stop()
Expand All @@ -138,31 +164,17 @@ func (m *Controller) ShowPopUpPlayQueue() {
}()
}
m.popUpQueueLastUsed = time.Now().UnixMilli()
popUpQueue := m.popUpQueue
popUpQueueList := m.popUpQueueList
pop := m.popUpQueue
m.popUpQueueMutex.Unlock()

npID := ""
if np := m.App.PlaybackManager.NowPlaying(); np != nil {
npID = np.Metadata().ID
}
popUpQueue.SetNowPlaying(npID)
popUpQueue.UnselectAll()

title := widget.NewRichTextWithText(lang.L("Play Queue"))
title.Segments[0].(*widget.TextSegment).Style.Alignment = fyne.TextAlignCenter
title.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = true
ctr := container.NewBorder(title, nil, nil, nil,
container.NewPadded(m.popUpQueue),
)
pop := widget.NewPopUp(ctr, m.MainWindow.Canvas())
container.NewThemeOverride(pop, myTheme.WithColorTransformOverride(
theme.ColorNameOverlayBackground,
func(c color.Color) color.Color {
c_ := c.(color.NRGBA)
c_.A = 245
return c_
},
))
popUpQueueList.SetNowPlaying(npID)
popUpQueueList.UnselectAll()

m.ClosePopUpOnEscape(pop)
minSize := fyne.NewSize(300, 400)
maxSize := fyne.NewSize(800, 1000)
Expand All @@ -171,7 +183,7 @@ func (m *Controller) ShowPopUpPlayQueue() {
fyne.NewSize(canvasSize.Width*0.4, canvasSize.Height*0.5),
))
pop.Resize(size)
popUpQueue.ScrollToNowPlaying() // must come after resize
popUpQueueList.ScrollToNowPlaying() // must come after resize
pop.ShowAtPosition(fyne.NewPos(
canvasSize.Width-size.Width-10,
canvasSize.Height-size.Height-100,
Expand Down Expand Up @@ -528,8 +540,10 @@ func (c *Controller) ShowSettingsDialog(themeUpdateCallbk func(), themeFiles map
}
dlg.OnPageNeedsRefresh = c.RefreshPageFunc
pop := widget.NewModalPopUp(dlg, c.MainWindow.Canvas())
fynetooltip.AddPopUpToolTipLayer(pop)
dlg.OnDismiss = func() {
pop.Hide()
fynetooltip.DestroyPopUpToolTipLayer(pop)
c.doModalClosed()
c.App.SaveConfigFile()
}
Expand Down
31 changes: 31 additions & 0 deletions ui/controller/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@ const (
Radios
)

func (p PageName) String() string {
switch p {
case Album:
return "Album"
case Albums:
return "Albums"
case Artist:
return "Artist"
case Artists:
return "Artists"
case Genre:
return "Genre"
case Genres:
return "Genres"
case Favorites:
return "Favorites"
case NowPlaying:
return "Now Playing"
case Playlist:
return "Playlist"
case Playlists:
return "Playlists"
case Tracks:
return "All Tracks"
case Radios:
return "Internet Radio Stations"
default:
return ""
}
}

type Route struct {
Page PageName
Arg string
Expand Down
Loading
Loading