From b1d85786ce45c328961760165378d6e2ac6c4ebf Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 29 Dec 2023 23:59:03 +0100 Subject: [PATCH] Minor cleanup of padded layout --- layout/paddedlayout.go | 11 +++++------ layout/stacklayout.go | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/layout/paddedlayout.go b/layout/paddedlayout.go index 5e6776d018..c260841819 100644 --- a/layout/paddedlayout.go +++ b/layout/paddedlayout.go @@ -8,14 +8,13 @@ import ( // Declare conformity with Layout interface var _ fyne.Layout = (*paddedLayout)(nil) -type paddedLayout struct { -} +type paddedLayout struct{} // Layout is called to pack all child objects into a specified size. // For PaddedLayout this sets all children to the full size passed minus padding all around. -func (l *paddedLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) { +func (l paddedLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) { padding := theme.Padding() - pos := fyne.NewPos(padding, padding) + pos := fyne.NewSquareOffsetPos(padding) siz := fyne.NewSize(size.Width-2*padding, size.Height-2*padding) for _, child := range objects { child.Resize(siz) @@ -25,7 +24,7 @@ func (l *paddedLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) { // MinSize finds the smallest size that satisfies all the child objects. // For PaddedLayout this is determined simply as the MinSize of the largest child plus padding all around. -func (l *paddedLayout) MinSize(objects []fyne.CanvasObject) (min fyne.Size) { +func (l paddedLayout) MinSize(objects []fyne.CanvasObject) (min fyne.Size) { for _, child := range objects { if !child.Visible() { continue @@ -41,5 +40,5 @@ func (l *paddedLayout) MinSize(objects []fyne.CanvasObject) (min fyne.Size) { // // Since: 1.4 func NewPaddedLayout() fyne.Layout { - return &paddedLayout{} + return paddedLayout{} } diff --git a/layout/stacklayout.go b/layout/stacklayout.go index 7874fbde15..a8f896ab1a 100644 --- a/layout/stacklayout.go +++ b/layout/stacklayout.go @@ -6,8 +6,7 @@ import "fyne.io/fyne/v2" // Declare conformity with Layout interface var _ fyne.Layout = (*stackLayout)(nil) -type stackLayout struct { -} +type stackLayout struct{} // NewStackLayout returns a new StackLayout instance. Objects are stacked // on top of each other with later objects on top of those before.