From dd1adaf2a22226367de09d231fe303a6d031a316 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sun, 26 Mar 2023 20:22:37 -0700 Subject: [PATCH 01/14] beginning of moving custom icons to theme --- ui/theme/theme.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index e420137..2fddd53 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "log" "strings" + "supersonic/res" "fyne.io/fyne/v2" "fyne.io/fyne/v2/theme" @@ -23,6 +24,17 @@ type MyTheme struct { BoldFont string } +const ( + IconNameNowPlaying fyne.ThemeIconName = "NowPlaying" + IconNameFavorite fyne.ThemeIconName = "Favorite" + IconNameNotFavorite fyne.ThemeIconName = "NotFavorite" + IconNameAlbum fyne.ThemeIconName = "Album" + IconNameArtist fyne.ThemeIconName = "Artist" + IconNameGenre fyne.ThemeIconName = "Genre" + IconNamePlaylist fyne.ThemeIconName = "Playlist" + IconNameShuffle fyne.ThemeIconName = "Shuffle" +) + var _ fyne.Theme = (*MyTheme)(nil) func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color { @@ -42,7 +54,26 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) col } func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { - return theme.DefaultTheme().Icon(name) + switch name { + case IconNameAlbum: + return res.ResDiscInvertPng + case IconNameArtist: + return res.ResPeopleInvertPng + case IconNameFavorite: + return res.ResHeartFilledInvertPng + case IconNameNotFavorite: + return res.ResHeartOutlineInvertPng + case IconNameGenre: + return res.ResTheatermasksInvertPng + case IconNameNowPlaying: + return res.ResHeadphonesInvertPng + case IconNamePlaylist: + return res.ResPlaylistInvertPng + case IconNameShuffle: + return res.ResShuffleInvertSvg + default: + return theme.DefaultTheme().Icon(name) + } } func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { From 4711a2b19615725192fccaa8963b67ab43c58671 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 27 Mar 2023 09:19:20 -0700 Subject: [PATCH 02/14] more work on light theme colos --- ui/browsing/browsingpane.go | 2 +- ui/theme/theme.go | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index 91e76d3..c432a4e 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -69,7 +69,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane { b.app.PlaybackManager.OnSongChange(b.onSongChange) b.pageContainer = container.NewMax( canvas.NewRectangle(fyne.CurrentApp().Settings().Theme().Color( - myTheme.ColorNamePageBackground, theme.VariantDark, + myTheme.ColorNamePageBackground, fyne.CurrentApp().Settings().ThemeVariant(), )), layout.NewSpacer()) b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() { diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 2fddd53..b49941e 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -40,17 +40,39 @@ var _ fyne.Theme = (*MyTheme)(nil) func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color { switch name { case ColorNamePageBackground: - return color.RGBA{R: 15, G: 15, B: 15, A: 255} + if variant == theme.VariantDark { + return color.RGBA{R: 15, G: 15, B: 15, A: 255} + } + return color.RGBA{R: 255, G: 255, B: 255, A: 255} case theme.ColorNameBackground: - return color.RGBA{R: 30, G: 30, B: 30, A: 255} + if variant == theme.VariantDark { + return color.RGBA{R: 35, G: 35, B: 35, A: 255} + } + return color.RGBA{R: 240, G: 240, B: 240, A: 255} case theme.ColorNameScrollBar: - return theme.DarkTheme().Color(theme.ColorNameForeground, variant) + if variant == theme.VariantDark { + return theme.DarkTheme().Color(theme.ColorNameForeground, variant) + } + return theme.LightTheme().Color(theme.ColorNameForeground, variant) case theme.ColorNameButton: - return color.RGBA{R: 20, G: 20, B: 20, A: 50} + if variant == theme.VariantDark { + return color.RGBA{R: 20, G: 20, B: 20, A: 50} + } + return color.RGBA{R: 200, G: 200, B: 200, A: 240} case theme.ColorNameInputBackground: - return color.RGBA{R: 20, G: 20, B: 20, A: 50} + if variant == theme.VariantDark { + return color.RGBA{R: 20, G: 20, B: 20, A: 50} + } + case theme.ColorNameForeground: + if variant == theme.VariantLight { + return color.RGBA{R: 10, G: 10, B: 10, A: 255} + } + case theme.ColorNamePrimary: + if variant == theme.VariantLight { + return color.RGBA{R: 25, G: 25, B: 250, A: 255} + } } - return theme.DarkTheme().Color(name, variant) + return theme.DefaultTheme().Color(name, variant) } func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { From 94157b3a00551cbbb02de7493fe00106baa0ec65 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 27 Mar 2023 17:42:53 -0700 Subject: [PATCH 03/14] more light theme work: themed icon button, colors adj --- ui/browsing/browsingpane.go | 17 +++---- ui/mainwindow.go | 14 +++--- ui/theme/theme.go | 87 +++++++++++++++++++++++++++--------- ui/widgets/favoritebutton.go | 7 ++- ui/widgets/listheader.go | 3 +- ui/widgets/themed.go | 63 ++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 43 deletions(-) create mode 100644 ui/widgets/themed.go diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index c432a4e..cadee11 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -5,9 +5,9 @@ import ( "supersonic/ui/controller" "supersonic/ui/layouts" myTheme "supersonic/ui/theme" + "supersonic/ui/widgets" "fyne.io/fyne/v2" - "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/theme" @@ -67,11 +67,8 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane { b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward) b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload) b.app.PlaybackManager.OnSongChange(b.onSongChange) - b.pageContainer = container.NewMax( - canvas.NewRectangle(fyne.CurrentApp().Settings().Theme().Color( - myTheme.ColorNamePageBackground, fyne.CurrentApp().Settings().ThemeVariant(), - )), - layout.NewSpacer()) + bkgrnd := widgets.NewThemedRectangle(myTheme.ColorNamePageBackground) + b.pageContainer = container.NewMax(bkgrnd, layout.NewSpacer()) b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() { p := widget.NewPopUpMenu(b.settingsMenu, fyne.CurrentApp().Driver().CanvasForObject(b.settingsBtn)) @@ -110,19 +107,19 @@ func (b *BrowsingPane) AddSettingsMenuItem(label string, action func()) { fyne.NewMenuItem(label, action)) } -func (b *BrowsingPane) AddNavigationButton(iconRes fyne.Resource, action func()) { - b.navBtnsContainer.Add(widget.NewButtonWithIcon("", iconRes, action)) +func (b *BrowsingPane) AddNavigationButton(iconName fyne.ThemeIconName, action func()) { + b.navBtnsContainer.Add(widgets.NewThemedIconButton(iconName, "", action)) } func (b *BrowsingPane) DisableNavigationButtons() { for _, obj := range b.navBtnsContainer.Objects { - obj.(*widget.Button).Disable() + obj.(*widgets.ThemedIconButton).Disable() } } func (b *BrowsingPane) EnableNavigationButtons() { for _, obj := range b.navBtnsContainer.Objects { - obj.(*widget.Button).Enable() + obj.(*widgets.ThemedIconButton).Enable() } } diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 17bbf5c..be2ae54 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -3,10 +3,10 @@ package ui import ( "fmt" "supersonic/backend" - "supersonic/res" "supersonic/ui/browsing" "supersonic/ui/controller" "supersonic/ui/os" + "supersonic/ui/theme" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" @@ -178,22 +178,22 @@ func (m *MainWindow) ShowNewVersionDialog(appName, versionTag string) { } func (m *MainWindow) addNavigationButtons() { - m.BrowsingPane.AddNavigationButton(res.ResHeadphonesInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNameNowPlaying, func() { m.Router.NavigateTo(controller.NowPlayingRoute("")) }) - m.BrowsingPane.AddNavigationButton(res.ResHeartFilledInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNameFavorite, func() { m.Router.NavigateTo(controller.FavoritesRoute()) }) - m.BrowsingPane.AddNavigationButton(res.ResDiscInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNameAlbum, func() { m.Router.NavigateTo(controller.AlbumsRoute()) }) - m.BrowsingPane.AddNavigationButton(res.ResPeopleInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNameArtist, func() { m.Router.NavigateTo(controller.ArtistsRoute()) }) - m.BrowsingPane.AddNavigationButton(res.ResTheatermasksInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNameGenre, func() { m.Router.NavigateTo(controller.GenresRoute()) }) - m.BrowsingPane.AddNavigationButton(res.ResPlaylistInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.IconNamePlaylist, func() { m.Router.NavigateTo(controller.PlaylistsRoute()) }) m.BrowsingPane.AddNavigationButton(res.ResMusicnotesInvertPng, func() { diff --git a/ui/theme/theme.go b/ui/theme/theme.go index b49941e..633d013 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -14,16 +14,6 @@ import ( const ColorNamePageBackground fyne.ThemeColorName = "PageBackground" -var ( - normalFont fyne.Resource - boldFont fyne.Resource -) - -type MyTheme struct { - NormalFont string - BoldFont string -} - const ( IconNameNowPlaying fyne.ThemeIconName = "NowPlaying" IconNameFavorite fyne.ThemeIconName = "Favorite" @@ -35,20 +25,40 @@ const ( IconNameShuffle fyne.ThemeIconName = "Shuffle" ) +type VariantMode int + +const ( + VariantModeAuto VariantMode = iota + VariantModeDark + VariantModeLight +) + +var ( + normalFont fyne.Resource + boldFont fyne.Resource +) + +type MyTheme struct { + NormalFont string + BoldFont string + VariantMode VariantMode +} + var _ fyne.Theme = (*MyTheme)(nil) -func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color { +func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color { + variant := m.getVariant() switch name { case ColorNamePageBackground: if variant == theme.VariantDark { return color.RGBA{R: 15, G: 15, B: 15, A: 255} } - return color.RGBA{R: 255, G: 255, B: 255, A: 255} + return color.RGBA{R: 250, G: 250, B: 250, A: 255} case theme.ColorNameBackground: if variant == theme.VariantDark { return color.RGBA{R: 35, G: 35, B: 35, A: 255} } - return color.RGBA{R: 240, G: 240, B: 240, A: 255} + return color.RGBA{R: 225, G: 225, B: 225, A: 255} case theme.ColorNameScrollBar: if variant == theme.VariantDark { return theme.DarkTheme().Color(theme.ColorNameForeground, variant) @@ -76,23 +86,48 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) col } func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { + variant := m.getVariant() switch name { case IconNameAlbum: - return res.ResDiscInvertPng + if variant == theme.VariantDark { + return res.ResDiscInvertPng + } + return res.ResDiscPng case IconNameArtist: - return res.ResPeopleInvertPng + if variant == theme.VariantDark { + return res.ResPeopleInvertPng + } + return res.ResPeoplePng case IconNameFavorite: - return res.ResHeartFilledInvertPng + if variant == theme.VariantDark { + return res.ResHeartFilledInvertPng + } + return res.ResHeartFilledPng case IconNameNotFavorite: - return res.ResHeartOutlineInvertPng + if variant == theme.VariantDark { + return res.ResHeartOutlineInvertPng + } + return res.ResHeartOutlinePng case IconNameGenre: - return res.ResTheatermasksInvertPng + if variant == theme.VariantDark { + return res.ResTheatermasksInvertPng + } + return res.ResTheatermasksPng case IconNameNowPlaying: - return res.ResHeadphonesInvertPng + if variant == theme.VariantDark { + return res.ResHeadphonesInvertPng + } + return res.ResHeadphonesPng case IconNamePlaylist: - return res.ResPlaylistInvertPng + if variant == theme.VariantDark { + return res.ResPlaylistInvertPng + } + return res.ResPlaylistPng case IconNameShuffle: - return res.ResShuffleInvertSvg + if variant == theme.VariantDark { + return res.ResShuffleInvertSvg + } + return res.ResShuffleSvg default: return theme.DefaultTheme().Icon(name) } @@ -127,7 +162,6 @@ func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { return normalFont } } - return theme.DefaultTheme().Font(style) } @@ -135,6 +169,15 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 { return theme.DefaultTheme().Size(name) } +func (m *MyTheme) getVariant() fyne.ThemeVariant { + if m.VariantMode == VariantModeDark { + return theme.VariantDark + } else if m.VariantMode == VariantModeLight { + return theme.VariantLight + } + return fyne.CurrentApp().Settings().ThemeVariant() +} + func readTTFFile(filepath string) ([]byte, error) { if !strings.HasSuffix(filepath, ".ttf") { err := errors.New("only .ttf fonts are supported") diff --git a/ui/widgets/favoritebutton.go b/ui/widgets/favoritebutton.go index 942ffac..bac50e4 100644 --- a/ui/widgets/favoritebutton.go +++ b/ui/widgets/favoritebutton.go @@ -2,6 +2,7 @@ package widgets import ( "supersonic/res" + "supersonic/ui/theme" "fyne.io/fyne/v2" "fyne.io/fyne/v2/widget" @@ -31,10 +32,12 @@ func (f *FavoriteButton) Tapped(e *fyne.PointEvent) { } func (f *FavoriteButton) Refresh() { + var iconName fyne.ThemeIconName if f.IsFavorited { - f.Icon = res.ResHeartFilledInvertPng + iconName = theme.IconNameFavorite } else { - f.Icon = res.ResHeartOutlineInvertPng + iconName = theme.IconNameNotFavorite } + f.Icon = fyne.CurrentApp().Settings().Theme().Icon(iconName) f.Button.Refresh() } diff --git a/ui/widgets/listheader.go b/ui/widgets/listheader.go index e90d829..ccf21b3 100644 --- a/ui/widgets/listheader.go +++ b/ui/widgets/listheader.go @@ -5,7 +5,6 @@ import ( "supersonic/ui/layouts" "fyne.io/fyne/v2" - "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" @@ -42,7 +41,7 @@ func NewListHeader(cols []ListColumn, layout *layouts.ColumnsLayout) *ListHeader for i, _ := range l.columnVisible { l.columnVisible[i] = true } - l.container = container.NewMax(canvas.NewRectangle(theme.BackgroundColor()), l.columnsContainer) + l.container = container.NewMax(NewThemedRectangle(theme.ColorNameBackground), l.columnsContainer) l.ExtendBaseWidget(l) l.buildColumns() return l diff --git a/ui/widgets/themed.go b/ui/widgets/themed.go new file mode 100644 index 0000000..b709607 --- /dev/null +++ b/ui/widgets/themed.go @@ -0,0 +1,63 @@ +package widgets + +import ( + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/canvas" + "fyne.io/fyne/v2/widget" +) + +type ThemedIconButton struct { + widget.Button + + IconName fyne.ThemeIconName +} + +func NewThemedIconButton(iconName fyne.ThemeIconName, text string, action func()) *ThemedIconButton { + b := &ThemedIconButton{ + IconName: iconName, + Button: widget.Button{ + Text: text, + OnTapped: action, + }, + } + b.updateIcon() + b.ExtendBaseWidget(b) + return b +} + +func (b *ThemedIconButton) updateIcon() { + b.Icon = fyne.CurrentApp().Settings().Theme().Icon(b.IconName) +} + +func (b *ThemedIconButton) Refresh() { + b.updateIcon() + b.Button.Refresh() +} + +type ThemedRectangle struct { + widget.BaseWidget + + rect *canvas.Rectangle + + ColorName fyne.ThemeColorName +} + +func NewThemedRectangle(colorName fyne.ThemeColorName) *ThemedRectangle { + t := &ThemedRectangle{ + ColorName: colorName, + rect: canvas.NewRectangle(fyne.CurrentApp().Settings().Theme().Color(colorName, + fyne.CurrentApp().Settings().ThemeVariant())), + } + t.ExtendBaseWidget(t) + return t +} + +func (t *ThemedRectangle) Refresh() { + t.rect.FillColor = fyne.CurrentApp().Settings().Theme().Color(t.ColorName, + fyne.CurrentApp().Settings().ThemeVariant()) + t.BaseWidget.Refresh() +} + +func (t *ThemedRectangle) CreateRenderer() fyne.WidgetRenderer { + return widget.NewSimpleRenderer(t.rect) +} From cdac9ae66f1a0b32d9d9c0858a1548f27d607a14 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 27 Mar 2023 18:54:20 -0700 Subject: [PATCH 04/14] update rest of icons to themed --- ui/browsing/albumpage.go | 4 ++-- ui/browsing/artistpage.go | 5 +++-- ui/browsing/genrepage.go | 10 +++++----- ui/browsing/playlistpage.go | 3 ++- ui/theme/theme.go | 2 +- ui/widgets/themed.go | 18 ++++++++++++++++++ ui/widgets/tracklist.go | 14 +++++++------- 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index 9f483a9..f25fb01 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -4,10 +4,10 @@ import ( "fmt" "log" "supersonic/backend" - "supersonic/res" "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -170,7 +170,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { go page.pm.PlayAlbum(page.albumID, 0) }) - shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() { + shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { page.pm.LoadTracks(page.tracklist.Tracks, false, true) page.pm.PlayFromBeginning() }) diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index 7eac001..b1967aa 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -9,6 +9,7 @@ import ( "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -253,7 +254,7 @@ type ArtistPageHeader struct { similarArtists *fyne.Container favoriteBtn *widgets.FavoriteButton playBtn *widget.Button - playRadioBtn *widget.Button + playRadioBtn *widgets.ThemedIconButton container *fyne.Container } @@ -275,7 +276,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader { } a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() }) a.playBtn = widget.NewButtonWithIcon("Play Discography", theme.MediaPlayIcon(), page.playAllTracks) - a.playRadioBtn = widget.NewButtonWithIcon("Play Artist Radio", res.ResShuffleInvertSvg, page.playArtistRadio) + a.playRadioBtn = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play Artist Radio", page.playArtistRadio) a.biographyDisp.Wrapping = fyne.TextWrapWord a.ExtendBaseWidget(a) a.createContainer() diff --git a/ui/browsing/genrepage.go b/ui/browsing/genrepage.go index 70d2730..84ce6c5 100644 --- a/ui/browsing/genrepage.go +++ b/ui/browsing/genrepage.go @@ -2,8 +2,8 @@ package browsing import ( "supersonic/backend" - "supersonic/res" "supersonic/ui/controller" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -29,7 +29,7 @@ type GenrePage struct { searcher *widgets.Searcher searchText string titleDisp *widget.RichText - playRandom *widget.Button + playRandom *widgets.ThemedIconButton OnPlayAlbum func(string, int) @@ -50,7 +50,7 @@ func NewGenrePage(genre string, contr *controller.Controller, pm *backend.Playba g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, g.playRandomSongs) + g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play random", g.playRandomSongs) iter := g.lm.GenreIter(g.genre) g.grid = widgets.NewGridView(widgets.NewGridViewAlbumIterator(iter), g.im) g.grid.OnPlay = g.onPlayAlbum @@ -93,8 +93,8 @@ func restoreGenrePage(saved *savedGenrePage) *GenrePage { g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, g.playRandomSongs) - g.grid = widgets.NewGridViewFromState(saved.gridState) + g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, "Play random", g.playRandomSongs) + g.grid = widgets.NewAlbumGridFromState(saved.gridState) g.searcher = widgets.NewSearcher() g.searcher.OnSearched = g.OnSearched g.searcher.Entry.Text = saved.searchText diff --git a/ui/browsing/playlistpage.go b/ui/browsing/playlistpage.go index 1fddf60..ff54876 100644 --- a/ui/browsing/playlistpage.go +++ b/ui/browsing/playlistpage.go @@ -8,6 +8,7 @@ import ( "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -205,7 +206,7 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader { page.pm.PlayFromBeginning() }) // TODO: find way to pad shuffle svg rather than using a space in the label string - shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() { + shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { page.pm.LoadTracks(page.tracklist.Tracks, false /*append*/, true /*shuffle*/) page.pm.PlayFromBeginning() }) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 633d013..c46a09c 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -58,7 +58,7 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Col if variant == theme.VariantDark { return color.RGBA{R: 35, G: 35, B: 35, A: 255} } - return color.RGBA{R: 225, G: 225, B: 225, A: 255} + return color.RGBA{R: 225, G: 223, B: 225, A: 255} case theme.ColorNameScrollBar: if variant == theme.VariantDark { return theme.DarkTheme().Color(theme.ColorNameForeground, variant) diff --git a/ui/widgets/themed.go b/ui/widgets/themed.go index b709607..9e7036f 100644 --- a/ui/widgets/themed.go +++ b/ui/widgets/themed.go @@ -61,3 +61,21 @@ func (t *ThemedRectangle) Refresh() { func (t *ThemedRectangle) CreateRenderer() fyne.WidgetRenderer { return widget.NewSimpleRenderer(t.rect) } + +type ThemedTappableIcon struct { + TappableIcon + + IconName fyne.ThemeIconName +} + +func NewThemedTappableIcon(iconName fyne.ThemeIconName) *ThemedTappableIcon { + t := &ThemedTappableIcon{IconName: iconName} + t.ExtendBaseWidget(t) + return t +} + +func (t *ThemedTappableIcon) Refresh() { + icon := fyne.CurrentApp().Settings().Theme().Icon(t.IconName) + t.TappableIcon.Icon.Resource = icon + t.TappableIcon.Refresh() +} diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index af7b367..2a2cdce 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -1,13 +1,13 @@ -package widgets + package widgets import ( "fmt" "log" "strconv" - "supersonic/res" "supersonic/sharedutil" "supersonic/ui/layouts" "supersonic/ui/os" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "sync" "time" @@ -524,7 +524,7 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow t.album.OnTapped = func() { tracklist.onAlbumTapped(t.albumID) } t.dur = newTrailingAlignRichText() t.year = newTrailingAlignRichText() - favorite := NewTappbaleIcon(res.ResHeartOutlineInvertPng) + favorite := NewThemedTappableIcon(myTheme.IconNameNotFavorite) favorite.OnTapped = t.toggleFavorited t.favorite = container.NewCenter(favorite) t.rating = NewStarRating() @@ -623,10 +623,10 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { // Render favorite column if tr.Starred.IsZero() { t.isFavorite = false - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartOutlineInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite } else { t.isFavorite = true - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartFilledInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite } t.rating.Rating = tr.UserRating @@ -648,12 +648,12 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { func (t *TrackRow) toggleFavorited() { if t.isFavorite { - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartOutlineInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite t.favorite.Refresh() t.isFavorite = false t.tracklist.onSetFavorite(t.trackID, false) } else { - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartFilledInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite t.favorite.Refresh() t.isFavorite = true t.tracklist.onSetFavorite(t.trackID, true) From 62f8f821ccfba407c340c37b36b1eb4253187834 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 29 Mar 2023 08:44:25 -0700 Subject: [PATCH 05/14] hook up config settings to light/dark appearance --- backend/config.go | 8 ++++++++ main.go | 1 + ui/theme/theme.go | 24 +++++++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/backend/config.go b/backend/config.go index ab866ad..91851db 100644 --- a/backend/config.go +++ b/backend/config.go @@ -87,6 +87,10 @@ type ReplayGainConfig struct { PreventClipping bool } +type ThemeConfig struct { + Appearance string +} + type Config struct { Application AppConfig Servers []*ServerConfig @@ -101,6 +105,7 @@ type Config struct { LocalPlayback LocalPlaybackConfig Scrobbling ScrobbleConfig ReplayGain ReplayGainConfig + Theme ThemeConfig } var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"} @@ -158,6 +163,9 @@ func DefaultConfig(appVersionTag string) *Config { PreampGainDB: 0.0, PreventClipping: true, }, + Theme: ThemeConfig{ + Appearance: "Dark", + }, } } diff --git a/main.go b/main.go index 52a919a..1a9592e 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ func main() { fyneApp.Settings().SetTheme(&theme.MyTheme{ NormalFont: myApp.Config.Application.FontNormalTTF, BoldFont: myApp.Config.Application.FontBoldTTF, + Config: &myApp.Config.Theme, }) w := float32(myApp.Config.Application.WindowWidth) if w <= 1 { diff --git a/ui/theme/theme.go b/ui/theme/theme.go index c46a09c..c7bd999 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -6,7 +6,9 @@ import ( "io/ioutil" "log" "strings" + "supersonic/backend" "supersonic/res" + "supersonic/sharedutil" "fyne.io/fyne/v2" "fyne.io/fyne/v2/theme" @@ -25,12 +27,12 @@ const ( IconNameShuffle fyne.ThemeIconName = "Shuffle" ) -type VariantMode int +type AppearanceMode string const ( - VariantModeAuto VariantMode = iota - VariantModeDark - VariantModeLight + AppearanceLight AppearanceMode = "Light" + AppearanceDark AppearanceMode = "Dark" + AppearanceAuto AppearanceMode = "Auto" ) var ( @@ -41,7 +43,7 @@ var ( type MyTheme struct { NormalFont string BoldFont string - VariantMode VariantMode + Config *backend.ThemeConfig } var _ fyne.Theme = (*MyTheme)(nil) @@ -133,6 +135,7 @@ func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { } } +<<<<<<< HEAD func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { switch style { case fyne.TextStyle{}: @@ -170,9 +173,16 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 { } func (m *MyTheme) getVariant() fyne.ThemeVariant { - if m.VariantMode == VariantModeDark { + v := "Dark" // default if config has invalid or missing setting + if sharedutil.StringSliceContains( + []string{string(AppearanceLight), string(AppearanceDark), string(AppearanceAuto)}, + m.Config.Appearance) { + v = m.Config.Appearance + } + + if AppearanceMode(v) == AppearanceDark { return theme.VariantDark - } else if m.VariantMode == VariantModeLight { + } else if AppearanceMode(v) == AppearanceLight { return theme.VariantLight } return fyne.CurrentApp().Settings().ThemeVariant() From 0d8c7d38307cb2e6f6062a545fc2db7301cbbb35 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 29 Mar 2023 18:23:18 -0700 Subject: [PATCH 06/14] fix type casting crash --- ui/browsing/browsingpane.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index cadee11..34b4446 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -125,7 +125,7 @@ func (b *BrowsingPane) EnableNavigationButtons() { func (b *BrowsingPane) ActivateNavigationButton(num int) { if num < len(b.navBtnsContainer.Objects) { - btn := b.navBtnsContainer.Objects[num].(*widget.Button) + btn := b.navBtnsContainer.Objects[num].(*widgets.ThemedIconButton) if !btn.Disabled() { btn.OnTapped() } From 6c81db439873c1e6c58849cb4fb0eb5250a37992 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 1 May 2023 17:24:31 -0700 Subject: [PATCH 07/14] switch to simpler way of themeing PNG icons --- main.go | 10 ++--- ui/browsing/albumpage.go | 2 +- ui/browsing/artistpage.go | 4 +- ui/browsing/browsingpane.go | 10 ++--- ui/browsing/genrepage.go | 6 +-- ui/browsing/playlistpage.go | 2 +- ui/mainwindow.go | 12 +++--- ui/theme/theme.go | 73 +++++++++++++++++++++++++++++------- ui/widgets/favoritebutton.go | 6 +-- ui/widgets/themed.go | 46 ----------------------- ui/widgets/tracklist.go | 12 +++--- 11 files changed, 91 insertions(+), 92 deletions(-) diff --git a/main.go b/main.go index 1a9592e..3c8f15b 100644 --- a/main.go +++ b/main.go @@ -27,11 +27,11 @@ func main() { } fyneApp := app.New() - fyneApp.Settings().SetTheme(&theme.MyTheme{ - NormalFont: myApp.Config.Application.FontNormalTTF, - BoldFont: myApp.Config.Application.FontBoldTTF, - Config: &myApp.Config.Theme, - }) + theme := theme.NewMyTheme(&myApp.Config.Theme) + theme.NormalFont = myApp.Config.Application.FontNormalTTF + theme.BoldFont = myApp.Config.Application.FontBoldTTF + fyneApp.Settings().SetTheme(theme) + w := float32(myApp.Config.Application.WindowWidth) if w <= 1 { w = 1000 diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index f25fb01..de65621 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -170,7 +170,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { go page.pm.PlayAlbum(page.albumID, 0) }) - shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { + shuffleBtn := widget.NewButtonWithIcon(" Shuffle", myTheme.ShuffleIcon, func() { page.pm.LoadTracks(page.tracklist.Tracks, false, true) page.pm.PlayFromBeginning() }) diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index b1967aa..48c9078 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -254,7 +254,7 @@ type ArtistPageHeader struct { similarArtists *fyne.Container favoriteBtn *widgets.FavoriteButton playBtn *widget.Button - playRadioBtn *widgets.ThemedIconButton + playRadioBtn *widget.Button container *fyne.Container } @@ -276,7 +276,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader { } a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() }) a.playBtn = widget.NewButtonWithIcon("Play Discography", theme.MediaPlayIcon(), page.playAllTracks) - a.playRadioBtn = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play Artist Radio", page.playArtistRadio) + a.playRadioBtn = widget.NewButtonWithIcon(" Play Artist Radio", myTheme.ShuffleIcon, page.playArtistRadio) a.biographyDisp.Wrapping = fyne.TextWrapWord a.ExtendBaseWidget(a) a.createContainer() diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index 34b4446..e9676bd 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -107,25 +107,25 @@ func (b *BrowsingPane) AddSettingsMenuItem(label string, action func()) { fyne.NewMenuItem(label, action)) } -func (b *BrowsingPane) AddNavigationButton(iconName fyne.ThemeIconName, action func()) { - b.navBtnsContainer.Add(widgets.NewThemedIconButton(iconName, "", action)) +func (b *BrowsingPane) AddNavigationButton(icon fyne.Resource, action func()) { + b.navBtnsContainer.Add(widget.NewButtonWithIcon("", icon, action)) } func (b *BrowsingPane) DisableNavigationButtons() { for _, obj := range b.navBtnsContainer.Objects { - obj.(*widgets.ThemedIconButton).Disable() + obj.(*widget.Button).Disable() } } func (b *BrowsingPane) EnableNavigationButtons() { for _, obj := range b.navBtnsContainer.Objects { - obj.(*widgets.ThemedIconButton).Enable() + obj.(*widget.Button).Enable() } } func (b *BrowsingPane) ActivateNavigationButton(num int) { if num < len(b.navBtnsContainer.Objects) { - btn := b.navBtnsContainer.Objects[num].(*widgets.ThemedIconButton) + btn := b.navBtnsContainer.Objects[num].(*widget.Button) if !btn.Disabled() { btn.OnTapped() } diff --git a/ui/browsing/genrepage.go b/ui/browsing/genrepage.go index 84ce6c5..2d23272 100644 --- a/ui/browsing/genrepage.go +++ b/ui/browsing/genrepage.go @@ -29,7 +29,7 @@ type GenrePage struct { searcher *widgets.Searcher searchText string titleDisp *widget.RichText - playRandom *widgets.ThemedIconButton + playRandom *widget.Button OnPlayAlbum func(string, int) @@ -50,7 +50,7 @@ func NewGenrePage(genre string, contr *controller.Controller, pm *backend.Playba g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play random", g.playRandomSongs) + g.playRandom = widget.NewButtonWithIcon(" Play random", myTheme.ShuffleIcon, g.playRandomSongs) iter := g.lm.GenreIter(g.genre) g.grid = widgets.NewGridView(widgets.NewGridViewAlbumIterator(iter), g.im) g.grid.OnPlay = g.onPlayAlbum @@ -93,7 +93,7 @@ func restoreGenrePage(saved *savedGenrePage) *GenrePage { g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, "Play random", g.playRandomSongs) + g.playRandom = widget.NewButtonWithIcon("Play random", myTheme.ShuffleIcon, g.playRandomSongs) g.grid = widgets.NewAlbumGridFromState(saved.gridState) g.searcher = widgets.NewSearcher() g.searcher.OnSearched = g.OnSearched diff --git a/ui/browsing/playlistpage.go b/ui/browsing/playlistpage.go index ff54876..f7212b0 100644 --- a/ui/browsing/playlistpage.go +++ b/ui/browsing/playlistpage.go @@ -206,7 +206,7 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader { page.pm.PlayFromBeginning() }) // TODO: find way to pad shuffle svg rather than using a space in the label string - shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { + shuffleBtn := widget.NewButtonWithIcon(" Shuffle", myTheme.ShuffleIcon, func() { page.pm.LoadTracks(page.tracklist.Tracks, false /*append*/, true /*shuffle*/) page.pm.PlayFromBeginning() }) diff --git a/ui/mainwindow.go b/ui/mainwindow.go index be2ae54..66a95ab 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -178,22 +178,22 @@ func (m *MainWindow) ShowNewVersionDialog(appName, versionTag string) { } func (m *MainWindow) addNavigationButtons() { - m.BrowsingPane.AddNavigationButton(theme.IconNameNowPlaying, func() { + m.BrowsingPane.AddNavigationButton(theme.NowPlayingIcon, func() { m.Router.NavigateTo(controller.NowPlayingRoute("")) }) - m.BrowsingPane.AddNavigationButton(theme.IconNameFavorite, func() { + m.BrowsingPane.AddNavigationButton(theme.FavoriteIcon, func() { m.Router.NavigateTo(controller.FavoritesRoute()) }) - m.BrowsingPane.AddNavigationButton(theme.IconNameAlbum, func() { + m.BrowsingPane.AddNavigationButton(theme.AlbumIcon, func() { m.Router.NavigateTo(controller.AlbumsRoute()) }) - m.BrowsingPane.AddNavigationButton(theme.IconNameArtist, func() { + m.BrowsingPane.AddNavigationButton(theme.ArtistIcon, func() { m.Router.NavigateTo(controller.ArtistsRoute()) }) - m.BrowsingPane.AddNavigationButton(theme.IconNameGenre, func() { + m.BrowsingPane.AddNavigationButton(theme.GenreIcon, func() { m.Router.NavigateTo(controller.GenresRoute()) }) - m.BrowsingPane.AddNavigationButton(theme.IconNamePlaylist, func() { + m.BrowsingPane.AddNavigationButton(theme.PlaylistIcon, func() { m.Router.NavigateTo(controller.PlaylistsRoute()) }) m.BrowsingPane.AddNavigationButton(res.ResMusicnotesInvertPng, func() { diff --git a/ui/theme/theme.go b/ui/theme/theme.go index c7bd999..dcd4ec5 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -16,17 +16,6 @@ import ( const ColorNamePageBackground fyne.ThemeColorName = "PageBackground" -const ( - IconNameNowPlaying fyne.ThemeIconName = "NowPlaying" - IconNameFavorite fyne.ThemeIconName = "Favorite" - IconNameNotFavorite fyne.ThemeIconName = "NotFavorite" - IconNameAlbum fyne.ThemeIconName = "Album" - IconNameArtist fyne.ThemeIconName = "Artist" - IconNameGenre fyne.ThemeIconName = "Genre" - IconNamePlaylist fyne.ThemeIconName = "Playlist" - IconNameShuffle fyne.ThemeIconName = "Shuffle" -) - type AppearanceMode string const ( @@ -43,11 +32,17 @@ var ( type MyTheme struct { NormalFont string BoldFont string - Config *backend.ThemeConfig + config *backend.ThemeConfig } var _ fyne.Theme = (*MyTheme)(nil) +func NewMyTheme(config *backend.ThemeConfig) *MyTheme { + m := &MyTheme{config: config} + m.createThemeIcons() + return m +} + func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color { variant := m.getVariant() switch name { @@ -87,6 +82,7 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Col return theme.DefaultTheme().Color(name, variant) } +<<<<<<< HEAD func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { variant := m.getVariant() switch name { @@ -135,6 +131,55 @@ func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { } } +type myThemedResource struct { + myTheme MyTheme + darkVariant *fyne.StaticResource + lightVariant *fyne.StaticResource +} + +var _ fyne.Resource = myThemedResource{} + +func (p myThemedResource) Content() []byte { + if p.myTheme.getVariant() == theme.VariantDark { + return p.darkVariant.StaticContent + } + return p.lightVariant.StaticContent +} + +func (p myThemedResource) Name() string { + if p.myTheme.getVariant() == theme.VariantDark { + return p.darkVariant.StaticName + } + return p.lightVariant.StaticName +} + +var ( + AlbumIcon fyne.Resource + ArtistIcon fyne.Resource + FavoriteIcon fyne.Resource + NotFavoriteIcon fyne.Resource + GenreIcon fyne.Resource + NowPlayingIcon fyne.Resource + PlaylistIcon fyne.Resource + ShuffleIcon fyne.Resource +) + +// MUST be called at startup! +func (m MyTheme) createThemeIcons() { + AlbumIcon = myThemedResource{myTheme: m, darkVariant: res.ResDiscInvertPng, lightVariant: res.ResDiscPng} + ArtistIcon = myThemedResource{myTheme: m, darkVariant: res.ResPeopleInvertPng, lightVariant: res.ResPeoplePng} + FavoriteIcon = myThemedResource{myTheme: m, darkVariant: res.ResHeartFilledInvertPng, lightVariant: res.ResHeartFilledPng} + NotFavoriteIcon = myThemedResource{myTheme: m, darkVariant: res.ResHeartOutlineInvertPng, lightVariant: res.ResHeartOutlinePng} + GenreIcon = myThemedResource{myTheme: m, darkVariant: res.ResTheatermasksInvertPng, lightVariant: res.ResTheatermasksPng} + NowPlayingIcon = myThemedResource{myTheme: m, darkVariant: res.ResHeadphonesInvertPng, lightVariant: res.ResHeadphonesPng} + PlaylistIcon = myThemedResource{myTheme: m, darkVariant: res.ResPlaylistInvertPng, lightVariant: res.ResPlaylistPng} + ShuffleIcon = myThemedResource{myTheme: m, darkVariant: res.ResShuffleInvertSvg, lightVariant: res.ResShuffleSvg} +} + +func (m MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { + return theme.DefaultTheme().Icon(name) +} + <<<<<<< HEAD func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { switch style { @@ -176,8 +221,8 @@ func (m *MyTheme) getVariant() fyne.ThemeVariant { v := "Dark" // default if config has invalid or missing setting if sharedutil.StringSliceContains( []string{string(AppearanceLight), string(AppearanceDark), string(AppearanceAuto)}, - m.Config.Appearance) { - v = m.Config.Appearance + m.config.Appearance) { + v = m.config.Appearance } if AppearanceMode(v) == AppearanceDark { diff --git a/ui/widgets/favoritebutton.go b/ui/widgets/favoritebutton.go index bac50e4..4c49733 100644 --- a/ui/widgets/favoritebutton.go +++ b/ui/widgets/favoritebutton.go @@ -32,12 +32,10 @@ func (f *FavoriteButton) Tapped(e *fyne.PointEvent) { } func (f *FavoriteButton) Refresh() { - var iconName fyne.ThemeIconName if f.IsFavorited { - iconName = theme.IconNameFavorite + f.Icon = theme.FavoriteIcon } else { - iconName = theme.IconNameNotFavorite + f.Icon = theme.NotFavoriteIcon } - f.Icon = fyne.CurrentApp().Settings().Theme().Icon(iconName) f.Button.Refresh() } diff --git a/ui/widgets/themed.go b/ui/widgets/themed.go index 9e7036f..26d7e13 100644 --- a/ui/widgets/themed.go +++ b/ui/widgets/themed.go @@ -6,34 +6,6 @@ import ( "fyne.io/fyne/v2/widget" ) -type ThemedIconButton struct { - widget.Button - - IconName fyne.ThemeIconName -} - -func NewThemedIconButton(iconName fyne.ThemeIconName, text string, action func()) *ThemedIconButton { - b := &ThemedIconButton{ - IconName: iconName, - Button: widget.Button{ - Text: text, - OnTapped: action, - }, - } - b.updateIcon() - b.ExtendBaseWidget(b) - return b -} - -func (b *ThemedIconButton) updateIcon() { - b.Icon = fyne.CurrentApp().Settings().Theme().Icon(b.IconName) -} - -func (b *ThemedIconButton) Refresh() { - b.updateIcon() - b.Button.Refresh() -} - type ThemedRectangle struct { widget.BaseWidget @@ -61,21 +33,3 @@ func (t *ThemedRectangle) Refresh() { func (t *ThemedRectangle) CreateRenderer() fyne.WidgetRenderer { return widget.NewSimpleRenderer(t.rect) } - -type ThemedTappableIcon struct { - TappableIcon - - IconName fyne.ThemeIconName -} - -func NewThemedTappableIcon(iconName fyne.ThemeIconName) *ThemedTappableIcon { - t := &ThemedTappableIcon{IconName: iconName} - t.ExtendBaseWidget(t) - return t -} - -func (t *ThemedTappableIcon) Refresh() { - icon := fyne.CurrentApp().Settings().Theme().Icon(t.IconName) - t.TappableIcon.Icon.Resource = icon - t.TappableIcon.Refresh() -} diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index 2a2cdce..684a414 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -4,6 +4,8 @@ import ( "fmt" "log" "strconv" + "time" + "supersonic/sharedutil" "supersonic/ui/layouts" "supersonic/ui/os" @@ -524,7 +526,7 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow t.album.OnTapped = func() { tracklist.onAlbumTapped(t.albumID) } t.dur = newTrailingAlignRichText() t.year = newTrailingAlignRichText() - favorite := NewThemedTappableIcon(myTheme.IconNameNotFavorite) + favorite := NewTappbaleIcon(myTheme.NotFavoriteIcon) favorite.OnTapped = t.toggleFavorited t.favorite = container.NewCenter(favorite) t.rating = NewStarRating() @@ -623,10 +625,10 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { // Render favorite column if tr.Starred.IsZero() { t.isFavorite = false - t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite + t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.NotFavoriteIcon } else { t.isFavorite = true - t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite + t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.FavoriteIcon } t.rating.Rating = tr.UserRating @@ -648,12 +650,12 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { func (t *TrackRow) toggleFavorited() { if t.isFavorite { - t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite + t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.NotFavoriteIcon t.favorite.Refresh() t.isFavorite = false t.tracklist.onSetFavorite(t.trackID, false) } else { - t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite + t.favorite.Objects[0].(*TappableIcon).Resource = myTheme.FavoriteIcon t.favorite.Refresh() t.isFavorite = true t.tracklist.onSetFavorite(t.trackID, true) From 61d8d6916aed47cab4fa07bc9f47e117761448f0 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 1 May 2023 17:31:27 -0700 Subject: [PATCH 08/14] move ThemedRectangle to theme package --- ui/browsing/browsingpane.go | 3 +-- ui/{widgets/themed.go => theme/themedrectangle.go} | 2 +- ui/widgets/listheader.go | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) rename ui/{widgets/themed.go => theme/themedrectangle.go} (97%) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index e9676bd..77c33f9 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -5,7 +5,6 @@ import ( "supersonic/ui/controller" "supersonic/ui/layouts" myTheme "supersonic/ui/theme" - "supersonic/ui/widgets" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" @@ -67,7 +66,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane { b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward) b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload) b.app.PlaybackManager.OnSongChange(b.onSongChange) - bkgrnd := widgets.NewThemedRectangle(myTheme.ColorNamePageBackground) + bkgrnd := myTheme.NewThemedRectangle(myTheme.ColorNamePageBackground) b.pageContainer = container.NewMax(bkgrnd, layout.NewSpacer()) b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() { p := widget.NewPopUpMenu(b.settingsMenu, diff --git a/ui/widgets/themed.go b/ui/theme/themedrectangle.go similarity index 97% rename from ui/widgets/themed.go rename to ui/theme/themedrectangle.go index 26d7e13..663274f 100644 --- a/ui/widgets/themed.go +++ b/ui/theme/themedrectangle.go @@ -1,4 +1,4 @@ -package widgets +package theme import ( "fyne.io/fyne/v2" diff --git a/ui/widgets/listheader.go b/ui/widgets/listheader.go index ccf21b3..8935309 100644 --- a/ui/widgets/listheader.go +++ b/ui/widgets/listheader.go @@ -3,6 +3,7 @@ package widgets import ( "log" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" @@ -41,7 +42,7 @@ func NewListHeader(cols []ListColumn, layout *layouts.ColumnsLayout) *ListHeader for i, _ := range l.columnVisible { l.columnVisible[i] = true } - l.container = container.NewMax(NewThemedRectangle(theme.ColorNameBackground), l.columnsContainer) + l.container = container.NewMax(myTheme.NewThemedRectangle(theme.ColorNameBackground), l.columnsContainer) l.ExtendBaseWidget(l) l.buildColumns() return l From 64091bb84c0ef68cc02ce7b2ece202d37999e277 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 1 May 2023 17:56:13 -0700 Subject: [PATCH 09/14] cleanup from bad merge conflict 1: fix build errors --- ui/browsing/genrepage.go | 2 +- ui/mainwindow.go | 1 + ui/theme/theme.go | 19 ++++++++++++------- ui/widgets/tracklist.go | 3 +-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/browsing/genrepage.go b/ui/browsing/genrepage.go index 2d23272..a5b840f 100644 --- a/ui/browsing/genrepage.go +++ b/ui/browsing/genrepage.go @@ -94,7 +94,7 @@ func restoreGenrePage(saved *savedGenrePage) *GenrePage { SizeName: theme.SizeNameHeadingText, } g.playRandom = widget.NewButtonWithIcon("Play random", myTheme.ShuffleIcon, g.playRandomSongs) - g.grid = widgets.NewAlbumGridFromState(saved.gridState) + g.grid = widgets.NewGridViewFromState(saved.gridState) g.searcher = widgets.NewSearcher() g.searcher.OnSearched = g.OnSearched g.searcher.Entry.Text = saved.searchText diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 66a95ab..c2248be 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -3,6 +3,7 @@ package ui import ( "fmt" "supersonic/backend" + "supersonic/res" "supersonic/ui/browsing" "supersonic/ui/controller" "supersonic/ui/os" diff --git a/ui/theme/theme.go b/ui/theme/theme.go index dcd4ec5..130a8f8 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -16,6 +16,17 @@ import ( const ColorNamePageBackground fyne.ThemeColorName = "PageBackground" +const ( + IconNameNowPlaying fyne.ThemeIconName = "NowPlaying" + IconNameFavorite fyne.ThemeIconName = "Favorite" + IconNameNotFavorite fyne.ThemeIconName = "NotFavorite" + IconNameAlbum fyne.ThemeIconName = "Album" + IconNameArtist fyne.ThemeIconName = "Artist" + IconNameGenre fyne.ThemeIconName = "Genre" + IconNamePlaylist fyne.ThemeIconName = "Playlist" + IconNameShuffle fyne.ThemeIconName = "Shuffle" +) + type AppearanceMode string const ( @@ -82,7 +93,6 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Col return theme.DefaultTheme().Color(name, variant) } -<<<<<<< HEAD func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { variant := m.getVariant() switch name { @@ -176,11 +186,6 @@ func (m MyTheme) createThemeIcons() { ShuffleIcon = myThemedResource{myTheme: m, darkVariant: res.ResShuffleInvertSvg, lightVariant: res.ResShuffleSvg} } -func (m MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { - return theme.DefaultTheme().Icon(name) -} - -<<<<<<< HEAD func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { switch style { case fyne.TextStyle{}: @@ -219,7 +224,7 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 { func (m *MyTheme) getVariant() fyne.ThemeVariant { v := "Dark" // default if config has invalid or missing setting - if sharedutil.StringSliceContains( + if sharedutil.SliceContains( []string{string(AppearanceLight), string(AppearanceDark), string(AppearanceAuto)}, m.config.Appearance) { v = m.config.Appearance diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index 684a414..d4fc921 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "strconv" + "sync" "time" "supersonic/sharedutil" @@ -11,8 +12,6 @@ import ( "supersonic/ui/os" myTheme "supersonic/ui/theme" "supersonic/ui/util" - "sync" - "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" From a1d91d748c532bd463c4ac1634a8ac473c089349 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 1 May 2023 18:02:53 -0700 Subject: [PATCH 10/14] cleanup from bad merge 2: misc cleanum + make tracks icon themed --- ui/mainwindow.go | 2 +- ui/theme/theme.go | 65 ++++------------------------------------- ui/widgets/tracklist.go | 2 +- 3 files changed, 8 insertions(+), 61 deletions(-) diff --git a/ui/mainwindow.go b/ui/mainwindow.go index c2248be..18ec5f6 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -197,7 +197,7 @@ func (m *MainWindow) addNavigationButtons() { m.BrowsingPane.AddNavigationButton(theme.PlaylistIcon, func() { m.Router.NavigateTo(controller.PlaylistsRoute()) }) - m.BrowsingPane.AddNavigationButton(res.ResMusicnotesInvertPng, func() { + m.BrowsingPane.AddNavigationButton(theme.TracksIcon, func() { m.Router.NavigateTo(controller.TracksRoute()) }) } diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 130a8f8..1bcbd66 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -16,17 +16,6 @@ import ( const ColorNamePageBackground fyne.ThemeColorName = "PageBackground" -const ( - IconNameNowPlaying fyne.ThemeIconName = "NowPlaying" - IconNameFavorite fyne.ThemeIconName = "Favorite" - IconNameNotFavorite fyne.ThemeIconName = "NotFavorite" - IconNameAlbum fyne.ThemeIconName = "Album" - IconNameArtist fyne.ThemeIconName = "Artist" - IconNameGenre fyne.ThemeIconName = "Genre" - IconNamePlaylist fyne.ThemeIconName = "Playlist" - IconNameShuffle fyne.ThemeIconName = "Shuffle" -) - type AppearanceMode string const ( @@ -41,9 +30,9 @@ var ( ) type MyTheme struct { - NormalFont string - BoldFont string - config *backend.ThemeConfig + NormalFont string + BoldFont string + config *backend.ThemeConfig } var _ fyne.Theme = (*MyTheme)(nil) @@ -94,51 +83,7 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Col } func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource { - variant := m.getVariant() - switch name { - case IconNameAlbum: - if variant == theme.VariantDark { - return res.ResDiscInvertPng - } - return res.ResDiscPng - case IconNameArtist: - if variant == theme.VariantDark { - return res.ResPeopleInvertPng - } - return res.ResPeoplePng - case IconNameFavorite: - if variant == theme.VariantDark { - return res.ResHeartFilledInvertPng - } - return res.ResHeartFilledPng - case IconNameNotFavorite: - if variant == theme.VariantDark { - return res.ResHeartOutlineInvertPng - } - return res.ResHeartOutlinePng - case IconNameGenre: - if variant == theme.VariantDark { - return res.ResTheatermasksInvertPng - } - return res.ResTheatermasksPng - case IconNameNowPlaying: - if variant == theme.VariantDark { - return res.ResHeadphonesInvertPng - } - return res.ResHeadphonesPng - case IconNamePlaylist: - if variant == theme.VariantDark { - return res.ResPlaylistInvertPng - } - return res.ResPlaylistPng - case IconNameShuffle: - if variant == theme.VariantDark { - return res.ResShuffleInvertSvg - } - return res.ResShuffleSvg - default: - return theme.DefaultTheme().Icon(name) - } + return theme.DefaultTheme().Icon(name) } type myThemedResource struct { @@ -172,6 +117,7 @@ var ( NowPlayingIcon fyne.Resource PlaylistIcon fyne.Resource ShuffleIcon fyne.Resource + TracksIcon fyne.Resource ) // MUST be called at startup! @@ -184,6 +130,7 @@ func (m MyTheme) createThemeIcons() { NowPlayingIcon = myThemedResource{myTheme: m, darkVariant: res.ResHeadphonesInvertPng, lightVariant: res.ResHeadphonesPng} PlaylistIcon = myThemedResource{myTheme: m, darkVariant: res.ResPlaylistInvertPng, lightVariant: res.ResPlaylistPng} ShuffleIcon = myThemedResource{myTheme: m, darkVariant: res.ResShuffleInvertSvg, lightVariant: res.ResShuffleSvg} + TracksIcon = myThemedResource{myTheme: m, darkVariant: res.ResMusicnotesInvertPng, lightVariant: res.ResMusicnotesPng} } func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource { diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index d4fc921..1bea566 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -1,4 +1,4 @@ - package widgets +package widgets import ( "fmt" From 4ed6a75778af4a4c4e5843258a950eb23d9da804 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 3 May 2023 17:32:36 -0700 Subject: [PATCH 11/14] add theme choice to settings dialog --- ui/controller/controller.go | 3 ++- ui/dialogs/settingsdialog.go | 26 +++++++++++++++++++++++++- ui/mainwindow.go | 12 +++++++++++- ui/theme/theme.go | 6 ++++-- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ui/controller/controller.go b/ui/controller/controller.go index f191a1d..54e4658 100644 --- a/ui/controller/controller.go +++ b/ui/controller/controller.go @@ -315,7 +315,7 @@ func (c *Controller) ShowAboutDialog() { pop.Show() } -func (c *Controller) ShowSettingsDialog() { +func (c *Controller) ShowSettingsDialog(themeUpdateCallbk func()) { devs, err := c.App.Player.ListAudioDevices() if err != nil { log.Printf("error listing audio devices: %v", err) @@ -332,6 +332,7 @@ func (c *Controller) ShowSettingsDialog() { dlg.OnAudioDeviceSettingChanged = func() { c.App.Player.SetAudioDevice(c.App.Config.LocalPlayback.AudioDeviceName) } + dlg.OnThemeSettingChanged = themeUpdateCallbk pop := widget.NewModalPopUp(dlg, c.MainWindow.Canvas()) dlg.OnDismiss = func() { pop.Hide() diff --git a/ui/dialogs/settingsdialog.go b/ui/dialogs/settingsdialog.go index a870391..2609ef0 100644 --- a/ui/dialogs/settingsdialog.go +++ b/ui/dialogs/settingsdialog.go @@ -9,6 +9,7 @@ import ( "supersonic/backend" "supersonic/player" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" "unicode" @@ -31,6 +32,7 @@ type SettingsDialog struct { OnReplayGainSettingsChanged func() OnAudioExclusiveSettingChanged func() OnAudioDeviceSettingChanged func() + OnThemeSettingChanged func() OnDismiss func() config *backend.Config @@ -50,6 +52,10 @@ func NewSettingsDialog(config *backend.Config, audioDeviceList []player.AudioDev s.createPlaybackTab(), s.createExperimentalTab(window), ) + // workaround issue where inactivated tabs don't fully update when theme setting is changed + tabs.OnSelected = func(ti *container.TabItem) { + ti.Content.Refresh() + } s.promptText = widget.NewRichTextWithText("") s.content = container.NewVBox(tabs, widget.NewSeparator(), container.NewHBox(s.promptText, layout.NewSpacer(), widget.NewButton("Close", func() { @@ -62,6 +68,21 @@ func NewSettingsDialog(config *backend.Config, audioDeviceList []player.AudioDev } func (s *SettingsDialog) createGeneralTab() *container.TabItem { + themeSelect := widget.NewSelect([]string{ + string(myTheme.AppearanceDark), + string(myTheme.AppearanceLight), + string(myTheme.AppearanceAuto)}, nil) + themeSelect.OnChanged = func(_ string) { + s.config.Theme.Appearance = themeSelect.Options[themeSelect.SelectedIndex()] + if s.OnThemeSettingChanged != nil { + s.OnThemeSettingChanged() + } + } + themeSelect.SetSelected(s.config.Theme.Appearance) + if themeSelect.Selected == "" { + themeSelect.SetSelectedIndex(0) + } + startupPage := widget.NewSelect(backend.SupportedStartupPages, func(choice string) { s.config.Application.StartupPage = choice }) @@ -161,7 +182,10 @@ func (s *SettingsDialog) createGeneralTab() *container.TabItem { scrobbleEnabled.Checked = s.config.Scrobbling.Enabled return container.NewTabItem("General", container.NewVBox( - container.New(layout.NewFormLayout(), widget.NewLabel("Startup page"), startupPage), + container.New(layout.NewFormLayout(), + widget.NewLabel("Appearance"), container.NewGridWithColumns(2, themeSelect), + widget.NewLabel("Startup page"), container.NewGridWithColumns(2, startupPage), + ), container.NewHBox(systemTrayEnable, closeToTray), s.newSectionSeparator(), diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 18ec5f6..b45f650 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -43,6 +43,7 @@ type MainWindow struct { BrowsingPane *browsing.BrowsingPane BottomPanel *BottomPanel + theme *theme.MyTheme haveSystemTray bool container *fyne.Container } @@ -52,8 +53,13 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap App: app, Window: fyneApp.NewWindow(appName), BrowsingPane: browsing.NewBrowsingPane(app), + theme: theme.NewMyTheme(&app.Config.Theme), } + m.theme.NormalFont = app.Config.Application.FontNormalTTF + m.theme.BoldFont = app.Config.Application.FontBoldTTF + fyneApp.Settings().SetTheme(m.theme) + if app.Config.Application.EnableSystemTray { m.SetupSystemTrayMenu(appName, fyneApp) } @@ -118,7 +124,11 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap } }() }) - m.BrowsingPane.AddSettingsMenuItem("Settings...", m.Controller.ShowSettingsDialog) + m.BrowsingPane.AddSettingsMenuItem("Settings...", func() { + m.Controller.ShowSettingsDialog(func() { + fyneApp.Settings().SetTheme(m.theme) + }) + }) m.BrowsingPane.AddSettingsMenuItem("About...", m.Controller.ShowAboutDialog) m.addNavigationButtons() m.BrowsingPane.DisableNavigationButtons() diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 1bcbd66..11d5238 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -22,6 +22,8 @@ const ( AppearanceLight AppearanceMode = "Light" AppearanceDark AppearanceMode = "Dark" AppearanceAuto AppearanceMode = "Auto" + + DefaultAppearance AppearanceMode = AppearanceDark ) var ( @@ -170,11 +172,11 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 { } func (m *MyTheme) getVariant() fyne.ThemeVariant { - v := "Dark" // default if config has invalid or missing setting + v := DefaultAppearance // default if config has invalid or missing setting if sharedutil.SliceContains( []string{string(AppearanceLight), string(AppearanceDark), string(AppearanceAuto)}, m.config.Appearance) { - v = m.config.Appearance + v = AppearanceMode(m.config.Appearance) } if AppearanceMode(v) == AppearanceDark { From 750bc71ef138aed5badc38d54bcd26a2678eb5dc Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 3 May 2023 17:33:01 -0700 Subject: [PATCH 12/14] fix last few non-themed icon references --- ui/browsing/favoritespage.go | 8 ++++---- ui/browsing/trackspage.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/browsing/favoritespage.go b/ui/browsing/favoritespage.go index 389682c..437e18e 100644 --- a/ui/browsing/favoritespage.go +++ b/ui/browsing/favoritespage.go @@ -3,9 +3,9 @@ package browsing import ( "log" "supersonic/backend" - "supersonic/res" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" "time" @@ -73,9 +73,9 @@ func (a *FavoritesPage) createHeader(activeBtnIdx int, searchText string) { SizeName: theme.SizeNameHeadingText, } a.toggleBtns = widgets.NewToggleButtonGroup(activeBtnIdx, - widget.NewButtonWithIcon("", res.ResDiscInvertPng, a.onShowFavoriteAlbums), - widget.NewButtonWithIcon("", res.ResPeopleInvertPng, a.onShowFavoriteArtists), - widget.NewButtonWithIcon("", res.ResMusicnotesInvertPng, a.onShowFavoriteSongs)) + widget.NewButtonWithIcon("", myTheme.AlbumIcon, a.onShowFavoriteAlbums), + widget.NewButtonWithIcon("", myTheme.ArtistIcon, a.onShowFavoriteArtists), + widget.NewButtonWithIcon("", myTheme.TracksIcon, a.onShowFavoriteSongs)) a.searcher = widgets.NewSearcher() a.searcher.OnSearched = a.OnSearched a.searcher.Entry.Text = searchText diff --git a/ui/browsing/trackspage.go b/ui/browsing/trackspage.go index 99f8b75..b3e06c9 100644 --- a/ui/browsing/trackspage.go +++ b/ui/browsing/trackspage.go @@ -2,10 +2,10 @@ package browsing import ( "supersonic/backend" - "supersonic/res" "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + "supersonic/ui/theme" "supersonic/ui/widgets" "fyne.io/fyne/v2" @@ -56,7 +56,7 @@ func NewTracksPage(contr *controller.Controller, conf *backend.TracksPageConfig, t.title = widget.NewRichTextWithText("All Tracks") t.title.Segments[0].(*widget.TextSegment).Style.SizeName = widget.RichTextStyleHeading.SizeName - t.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, t.playRandomSongs) + t.playRandom = widget.NewButtonWithIcon("Play random", theme.ShuffleIcon, t.playRandomSongs) t.searcher = widgets.NewSearcher() t.searcher.OnSearched = t.OnSearched t.createContainer() From 587979020e880d381e04c5a58edc8d6284f65364 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 3 May 2023 17:34:09 -0700 Subject: [PATCH 13/14] forgot a file --- main.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/main.go b/main.go index 3c8f15b..9b66bf1 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "log" "supersonic/backend" "supersonic/ui" - "supersonic/ui/theme" "time" "fyne.io/fyne/v2" @@ -27,11 +26,7 @@ func main() { } fyneApp := app.New() - theme := theme.NewMyTheme(&myApp.Config.Theme) - theme.NormalFont = myApp.Config.Application.FontNormalTTF - theme.BoldFont = myApp.Config.Application.FontBoldTTF - fyneApp.Settings().SetTheme(theme) - + w := float32(myApp.Config.Application.WindowWidth) if w <= 1 { w = 1000 From bafcfc399afcbddaf936aff0937ae804b808e7d1 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 3 May 2023 17:47:14 -0700 Subject: [PATCH 14/14] Update genrepage.go --- ui/browsing/genrepage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/browsing/genrepage.go b/ui/browsing/genrepage.go index a5b840f..11c5098 100644 --- a/ui/browsing/genrepage.go +++ b/ui/browsing/genrepage.go @@ -93,7 +93,7 @@ func restoreGenrePage(saved *savedGenrePage) *GenrePage { g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widget.NewButtonWithIcon("Play random", myTheme.ShuffleIcon, g.playRandomSongs) + g.playRandom = widget.NewButtonWithIcon(" Play random", myTheme.ShuffleIcon, g.playRandomSongs) g.grid = widgets.NewGridViewFromState(saved.gridState) g.searcher = widgets.NewSearcher() g.searcher.OnSearched = g.OnSearched