rebase to Fyne 2.5 prerelease and onboard to new CustomPaddedLayout
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
@@ -104,8 +105,8 @@ func newAlbumPage(
|
||||
a.contr.ConnectTracklistActionsWithReplayGainAlbum(a.tracklist)
|
||||
|
||||
a.container = container.NewBorder(
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 15, PadBottom: 10}, a.header),
|
||||
nil, nil, nil, container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadBottom: 15}, a.tracklist))
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 15, BottomPadding: 10}, a.header),
|
||||
nil, nil, nil, container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, BottomPadding: 15}, a.tracklist))
|
||||
|
||||
go a.load()
|
||||
return a
|
||||
|
||||
@@ -91,7 +91,7 @@ func newArtistPage(artistID string, cfg *backend.ArtistPageConfig, pool *util.Wi
|
||||
layout.NewSpacer(),
|
||||
)
|
||||
a.container = container.NewBorder(
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 15, PadBottom: 10}, a.header),
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 15, BottomPadding: 10}, a.header),
|
||||
nil, nil, nil,
|
||||
container.NewBorder(viewToggleRow, nil, nil, nil, layout.NewSpacer()))
|
||||
go a.load()
|
||||
@@ -248,7 +248,7 @@ func (a *ArtistPage) showTopTracks() {
|
||||
tl.SetNowPlaying(a.nowPlayingID)
|
||||
a.contr.ConnectTracklistActions(tl)
|
||||
a.tracklistCtr = container.New(
|
||||
&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadBottom: 10},
|
||||
&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, BottomPadding: 10},
|
||||
tl)
|
||||
}
|
||||
a.container.Objects[0].(*fyne.Container).Objects[0] = a.tracklistCtr
|
||||
|
||||
@@ -98,7 +98,7 @@ func NewBrowsingPane(app *backend.App, contr *controller.Controller, onGoHome fu
|
||||
b.navBtnsContainer = container.NewHBox()
|
||||
b.navBtnsPageMap = map[controller.PageName]fyne.Resource{}
|
||||
b.container = container.NewBorder(container.New(
|
||||
&layouts.MaxPadLayout{PadLeft: -5, PadRight: -5},
|
||||
&layout.CustomPaddedLayout{LeftPadding: -5, RightPadding: -5},
|
||||
container.New(layouts.NewLeftMiddleRightLayout(0),
|
||||
container.NewHBox(b.home, b.back, b.forward, b.reload), b.navBtnsContainer,
|
||||
container.NewHBox(layout.NewSpacer(), quickSearchBtn, b.settingsBtn))),
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
"github.com/dweymouth/supersonic/ui/widgets"
|
||||
@@ -413,7 +412,7 @@ func (a *FavoritesPage) onShowFavoriteSongs() {
|
||||
tracklist.SetNowPlaying(a.nowPlayingID)
|
||||
a.contr.ConnectTracklistActions(tracklist)
|
||||
a.tracklistCtr = container.New(
|
||||
&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 5, PadBottom: 15},
|
||||
&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 5, BottomPadding: 15},
|
||||
tracklist)
|
||||
a.container.Objects[0] = a.tracklistCtr
|
||||
a.Refresh()
|
||||
|
||||
@@ -138,9 +138,9 @@ func (s *savedGenresPage) Restore() Page {
|
||||
|
||||
func (a *GenresPage) buildContainer() {
|
||||
searchVbox := container.NewVBox(layout.NewSpacer(), a.searcher, layout.NewSpacer())
|
||||
a.container = container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 5, PadBottom: 15},
|
||||
a.container = container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 5, BottomPadding: 15},
|
||||
container.NewBorder(
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: -5},
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: -5},
|
||||
container.NewHBox(a.titleDisp, layout.NewSpacer(), searchVbox)),
|
||||
nil, nil, nil, a.list))
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
@@ -102,8 +103,8 @@ func newPlaylistPage(
|
||||
a.contr.ConnectTracklistActions(a.tracklist)
|
||||
|
||||
a.container = container.NewBorder(
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 15, PadBottom: 10}, a.header),
|
||||
nil, nil, nil, container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadBottom: 15}, a.tracklist))
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 15, BottomPadding: 10}, a.header),
|
||||
nil, nil, nil, container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, BottomPadding: 15}, a.tracklist))
|
||||
go a.load()
|
||||
return a
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ func (s *savedPlaylistsPage) Restore() Page {
|
||||
|
||||
func (a *PlaylistsPage) buildContainer(initialView fyne.CanvasObject) {
|
||||
searchVbox := container.NewVBox(layout.NewSpacer(), a.searcher, layout.NewSpacer())
|
||||
a.container = container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 5, PadBottom: 15},
|
||||
a.container = container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 5, BottomPadding: 15},
|
||||
container.NewBorder(
|
||||
container.NewHBox(a.titleDisp, container.NewCenter(a.viewToggle), layout.NewSpacer(), searchVbox),
|
||||
nil, nil, nil, initialView))
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
"github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
"github.com/dweymouth/supersonic/ui/widgets"
|
||||
@@ -80,7 +79,7 @@ func (t *TracksPage) createContainer() {
|
||||
playRandomVbox := container.NewVBox(layout.NewSpacer(), t.playRandom, layout.NewSpacer())
|
||||
searchVbox := container.NewVBox(layout.NewSpacer(), t.searcher, layout.NewSpacer())
|
||||
topRow := container.NewHBox(t.title, playRandomVbox, layout.NewSpacer(), searchVbox)
|
||||
t.container = container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 5, PadBottom: 15},
|
||||
t.container = container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15, TopPadding: 5, BottomPadding: 15},
|
||||
container.NewBorder(topRow, nil, nil, nil, t.tracklist))
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func (a *AlbumInfoDialog) buildMainContainer(albumInfo *mediaprovider.AlbumInfo,
|
||||
urlContainer := a.buildUrlContainer(albumInfo.LastFmUrl, albumInfo.MusicBrainzID)
|
||||
|
||||
return container.New(
|
||||
&layouts.MaxPadLayout{PadLeft: 15, PadRight: 10, PadTop: 15, PadBottom: 10},
|
||||
&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 10, TopPadding: 15, BottomPadding: 10},
|
||||
container.NewVBox(
|
||||
iconImage,
|
||||
title,
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/backend/player/mpv"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
"github.com/dweymouth/supersonic/ui/widgets"
|
||||
@@ -385,7 +384,7 @@ func (s *SettingsDialog) createPlaybackTab(isLocalPlayer, isReplayGainPlayer boo
|
||||
|
||||
return container.NewTabItem("Playback", container.NewVBox(
|
||||
disableTranscode,
|
||||
container.New(&layouts.MaxPadLayout{PadTop: 5},
|
||||
container.New(&layout.CustomPaddedLayout{TopPadding: 5},
|
||||
container.New(layout.NewFormLayout(),
|
||||
widget.NewLabel("Audio device"), container.NewBorder(nil, nil, nil, util.NewHSpace(70), deviceSelect),
|
||||
layout.NewSpacer(), audioExclusive,
|
||||
@@ -521,7 +520,7 @@ func (s *SettingsDialog) setRestartRequired() {
|
||||
}
|
||||
|
||||
func (s *SettingsDialog) newSectionSeparator() fyne.CanvasObject {
|
||||
return container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15}, widget.NewSeparator())
|
||||
return container.New(&layout.CustomPaddedLayout{LeftPadding: 15, RightPadding: 15}, widget.NewSeparator())
|
||||
}
|
||||
|
||||
func (s *SettingsDialog) onReplayGainSettingsChanged() {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package layouts
|
||||
|
||||
import "fyne.io/fyne/v2"
|
||||
|
||||
var _ fyne.Layout = (*MaxPadLayout)(nil)
|
||||
|
||||
type MaxPadLayout struct {
|
||||
PadLeft float32
|
||||
PadRight float32
|
||||
PadTop float32
|
||||
PadBottom float32
|
||||
}
|
||||
|
||||
// only supports one object
|
||||
func (c *MaxPadLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
|
||||
if len(objects) == 0 {
|
||||
return fyne.NewSize(c.PadLeft+c.PadRight, c.PadTop+c.PadBottom)
|
||||
}
|
||||
return fyne.Size{
|
||||
Width: objects[0].MinSize().Width + c.PadLeft + c.PadRight,
|
||||
Height: objects[0].MinSize().Height + c.PadTop + c.PadBottom,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *MaxPadLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
|
||||
if len(objects) == 0 {
|
||||
return
|
||||
}
|
||||
pos := fyne.NewPos(c.PadLeft, c.PadTop)
|
||||
objSize := fyne.NewSize(size.Width-c.PadLeft-c.PadRight, size.Height-c.PadTop-c.PadBottom)
|
||||
for _, child := range objects {
|
||||
if !child.Visible() {
|
||||
continue
|
||||
}
|
||||
child.Move(pos)
|
||||
child.Resize(objSize)
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
@@ -208,7 +207,7 @@ func AddHeaderBackground(obj fyne.CanvasObject) *fyne.Container {
|
||||
bgrnd := myTheme.NewThemedRectangle(myTheme.ColorNamePageHeader)
|
||||
bgrnd.CornerRadiusName = theme.SizeNameInputRadius
|
||||
return container.NewStack(bgrnd,
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: 10, PadRight: 10, PadTop: 10, PadBottom: 10},
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: 10, RightPadding: 10, TopPadding: 10, BottomPadding: 10},
|
||||
obj))
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
)
|
||||
@@ -309,7 +308,7 @@ func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []
|
||||
|
||||
filterRow := container.NewBorder(nil, nil, nil, container.NewHBox(g.allBtn, g.noneBtn), g.filterText)
|
||||
g.container = container.NewBorder(g.genresTitleLine, nil, nil, nil,
|
||||
container.New(&layouts.MaxPadLayout{PadLeft: 5, PadRight: 5},
|
||||
container.New(&layout.CustomPaddedLayout{LeftPadding: 5, RightPadding: 5},
|
||||
container.NewBorder(filterRow, nil, nil, nil, g.genreListView),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
@@ -110,9 +111,9 @@ func (n *NowPlayingCard) onAddToPlaylist() {
|
||||
}
|
||||
|
||||
func (n *NowPlayingCard) CreateRenderer() fyne.WidgetRenderer {
|
||||
c := container.New(&layouts.MaxPadLayout{PadLeft: -4},
|
||||
c := container.New(&layout.CustomPaddedLayout{LeftPadding: -4},
|
||||
container.NewBorder(nil, nil, n.cover, nil,
|
||||
container.New(&layouts.MaxPadLayout{PadTop: -2},
|
||||
container.New(&layout.CustomPaddedLayout{TopPadding: -2},
|
||||
container.New(&layouts.VboxCustomPadding{ExtraPad: -13}, n.trackName, n.artistName, n.albumName))),
|
||||
)
|
||||
return widget.NewSimpleRenderer(c)
|
||||
|
||||
Reference in New Issue
Block a user