forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxlayout.go
31 lines (25 loc) · 893 Bytes
/
maxlayout.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package layout defines the various layouts available to Fyne apps
package layout // import "fyne.io/fyne/layout"
import "fyne.io/fyne"
type maxLayout struct {
}
// Layout is called to pack all child objects into a specified size.
// For MaxLayout this sets all children to the full size passed.
func (m *maxLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
for _, child := range objects {
child.Resize(size)
}
}
// MinSize finds the smallest size that satisfies all the child objects.
// For MaxLayout this is determined simply as the MinSize of the largest child.
func (m *maxLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
minSize := fyne.NewSize(0, 0)
for _, child := range objects {
minSize = minSize.Union(child.MinSize())
}
return minSize
}
// NewMaxLayout creates a new MaxLayout instance
func NewMaxLayout() fyne.Layout {
return &maxLayout{}
}