Skip to content

Commit

Permalink
Minor cleanup of padded layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Dec 29, 2023
1 parent 92e0cbd commit b1d8578
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 5 additions & 6 deletions layout/paddedlayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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{}
}
3 changes: 1 addition & 2 deletions layout/stacklayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b1d8578

Please sign in to comment.