remove redundant CenterPad layout
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/dweymouth/supersonic/res"
|
"github.com/dweymouth/supersonic/res"
|
||||||
"github.com/dweymouth/supersonic/ui/layouts"
|
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
@@ -75,7 +74,7 @@ func (a *AboutDialog) buildMainTabContainer(version string) *fyne.Container {
|
|||||||
widget.NewHyperlink("Support the project", kofiUrl)),
|
widget.NewHyperlink("Support the project", kofiUrl)),
|
||||||
)
|
)
|
||||||
|
|
||||||
return container.New(&layouts.CenterPadLayout{PadTopBottom: 10},
|
return container.New(&layout.CustomPaddedLayout{TopPadding: 10, BottomPadding: 10},
|
||||||
container.NewVBox(iconImage,
|
container.NewVBox(iconImage,
|
||||||
container.New(layout.NewCustomPaddedVBoxLayout(theme.Padding()-10), title, versionLbl, copyright, license, githubKofi)))
|
container.New(layout.NewCustomPaddedVBoxLayout(theme.Padding()-10), title, versionLbl, copyright, license, githubKofi)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package layouts
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fyne.io/fyne/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ fyne.Layout = (*CenterPadLayout)(nil)
|
|
||||||
|
|
||||||
type CenterPadLayout struct {
|
|
||||||
PadLeftRight float32
|
|
||||||
PadTopBottom float32
|
|
||||||
}
|
|
||||||
|
|
||||||
// only supports one object
|
|
||||||
func (c *CenterPadLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
|
|
||||||
if len(objects) == 0 {
|
|
||||||
return fyne.NewSize(0, 0)
|
|
||||||
}
|
|
||||||
return fyne.Size{
|
|
||||||
Width: objects[0].MinSize().Width + c.PadLeftRight*2,
|
|
||||||
Height: objects[0].MinSize().Height + c.PadTopBottom*2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CenterPadLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
|
|
||||||
if len(objects) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
objSize := objects[0].MinSize()
|
|
||||||
xOffs := (size.Width - objSize.Width) / 2
|
|
||||||
yOffs := (size.Height - objSize.Height) / 2
|
|
||||||
for _, child := range objects {
|
|
||||||
if !child.Visible() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
child.Move(fyne.NewPos(xOffs, yOffs))
|
|
||||||
child.Resize(child.MinSize())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/dweymouth/supersonic/res"
|
"github.com/dweymouth/supersonic/res"
|
||||||
"github.com/dweymouth/supersonic/ui/layouts"
|
|
||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
@@ -201,7 +200,7 @@ func (g *GridViewItem) createContainer() {
|
|||||||
g.focusRect.StrokeWidth = 3
|
g.focusRect.StrokeWidth = 3
|
||||||
coverStack := container.NewStack(g.Cover, g.focusRect)
|
coverStack := container.NewStack(g.Cover, g.focusRect)
|
||||||
c := container.New(layout.NewCustomPaddedVBoxLayout(theme.Padding()-5), coverStack, info)
|
c := container.New(layout.NewCustomPaddedVBoxLayout(theme.Padding()-5), coverStack, info)
|
||||||
pad := &layouts.CenterPadLayout{PadLeftRight: 20, PadTopBottom: 10}
|
pad := layout.NewCustomPaddedLayout(10, 10, 20, 20)
|
||||||
g.container = container.New(pad, c)
|
g.container = container.New(pad, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
"github.com/dweymouth/supersonic/ui/layouts"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LoadingDots struct {
|
type LoadingDots struct {
|
||||||
@@ -92,9 +92,7 @@ func (l *LoadingDots) doTick(foreground, disabled color.Color) {
|
|||||||
|
|
||||||
func (l *LoadingDots) CreateRenderer() fyne.WidgetRenderer {
|
func (l *LoadingDots) CreateRenderer() fyne.WidgetRenderer {
|
||||||
if l.container == nil {
|
if l.container == nil {
|
||||||
layout := &layouts.CenterPadLayout{
|
layout := layout.NewCustomPaddedLayout(0, 0, 3, 3)
|
||||||
PadLeftRight: 3,
|
|
||||||
}
|
|
||||||
l.container = container.NewHBox(
|
l.container = container.NewHBox(
|
||||||
container.New(layout, &l.dots[0]),
|
container.New(layout, &l.dots[0]),
|
||||||
container.New(layout, &l.dots[1]),
|
container.New(layout, &l.dots[1]),
|
||||||
|
|||||||
Reference in New Issue
Block a user