-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
layouts.go
105 lines (93 loc) · 3.77 KB
/
layouts.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package container // import "fyne.io/fyne/v2/container"
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/internal"
"fyne.io/fyne/v2/layout"
)
// NewAdaptiveGrid creates a new container with the specified objects and using the grid layout.
// When in a horizontal arrangement the rowcols parameter will specify the column count, when in vertical
// it will specify the rows. On mobile this will dynamically refresh when device is rotated.
//
// Since: 1.4
func NewAdaptiveGrid(rowcols int, objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewAdaptiveGridLayout(rowcols), objects...)
}
// NewBorder creates a new container with the specified objects and using the border layout.
// The top, bottom, left and right parameters specify the items that should be placed around edges,
// the remaining elements will be in the center. Nil can be used to an edge if it should not be filled.
//
// Since: 1.4
func NewBorder(top, bottom, left, right fyne.CanvasObject, objects ...fyne.CanvasObject) *fyne.Container {
all := objects
if top != nil {
all = append(all, top)
}
if bottom != nil {
all = append(all, bottom)
}
if left != nil {
all = append(all, left)
}
if right != nil {
all = append(all, right)
}
if len(objects) == 1 && objects[0] == nil {
internal.LogHint("Border layout requires only 4 parameters, optional items cannot be nil")
all = all[1:]
}
return New(layout.NewBorderLayout(top, bottom, left, right), all...)
}
// NewCenter creates a new container with the specified objects centered in the available space.
//
// Since: 1.4
func NewCenter(objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewCenterLayout(), objects...)
}
// NewGridWithColumns creates a new container with the specified objects and using the grid layout with
// a specified number of columns. The number of rows will depend on how many children are in the container.
//
// Since: 1.4
func NewGridWithColumns(cols int, objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewGridLayoutWithColumns(cols), objects...)
}
// NewGridWithRows creates a new container with the specified objects and using the grid layout with
// a specified number of rows. The number of columns will depend on how many children are in the container.
//
// Since: 1.4
func NewGridWithRows(rows int, objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewGridLayoutWithRows(rows), objects...)
}
// NewGridWrap creates a new container with the specified objects and using the gridwrap layout.
// Every element will be resized to the size parameter and the content will arrange along a row and flow to a
// new row if the elements don't fit.
//
// Since: 1.4
func NewGridWrap(size fyne.Size, objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewGridWrapLayout(size), objects...)
}
// NewHBox creates a new container with the specified objects and using the HBox layout.
// The objects will be placed in the container from left to right.
//
// Since: 1.4
func NewHBox(objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewHBoxLayout(), objects...)
}
// NewMax creates a new container with the specified objects filling the available space.
//
// Since: 1.4
func NewMax(objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewMaxLayout(), objects...)
}
// NewPadded creates a new container with the specified objects inset by standard padding size.
//
// Since: 1.4
func NewPadded(objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewPaddedLayout(), objects...)
}
// NewVBox creates a new container with the specified objects and using the VBox layout.
// The objects will be stacked in the container from top to bottom.
//
// Since: 1.4
func NewVBox(objects ...fyne.CanvasObject) *fyne.Container {
return New(layout.NewVBoxLayout(), objects...)
}