-
Notifications
You must be signed in to change notification settings - Fork 8
/
layout.go
61 lines (48 loc) · 1.96 KB
/
layout.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
package transfer
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
"github.com/fabiodcorreia/catch-my-file/pkg/layout"
)
type transferLayout struct {
maxMinSizeHeight float32
}
// Layout will calculate the size and position of each object in a row
// of the Transfers List.
func (l *transferLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
col1Width := float32(25)
col1X := theme.Padding()
col2Width := (size.Width - col1Width) * 0.42
col2X := col1X + col1Width + theme.Padding()
col3Width := (size.Width - col2Width) * 0.25
col3X := col2X + col2Width + theme.Padding()
col4Width := (size.Width - col3Width) * 0.10
col4X := col3X + col3Width + theme.Padding()
col5Width := (size.Width - col4Width) * 0.13
col5X := col4X + col4Width + theme.Padding()
col6Width := (size.Width - col5X - col5Width)
col6X := col5X + col5Width - theme.Padding()
layout.ResizeAndMove(objects[0], col1Width, col1X, l.maxMinSizeHeight)
layout.ResizeAndMove(objects[1], col2Width, col2X, l.maxMinSizeHeight)
layout.ResizeAndMove(objects[2], col3Width, col3X, l.maxMinSizeHeight)
layout.ResizeAndMove(objects[3], col4Width, col4X, l.maxMinSizeHeight)
layout.ResizeAndMove(objects[4], col5Width, col5X, l.maxMinSizeHeight)
layout.ResizeAndMove(objects[5], col6Width, col6X, l.maxMinSizeHeight)
col6 := objects[5].(*fyne.Container)
if col6.Objects[0].Visible() {
layout.ResizeAndMove(col6.Objects[0], col6Width, theme.Padding(), l.maxMinSizeHeight)
return
}
col62Width := float32(40)
col62X := theme.Padding()
layout.ResizeAndMove(col6.Objects[1], col62Width, col62X, l.maxMinSizeHeight)
col63Width := col62Width
col63X := col62X + col62Width + theme.Padding()
layout.ResizeAndMove(col6.Objects[2], col63Width, col63X, l.maxMinSizeHeight)
}
// MinSize will calculate the minimum size allowed that.
func (l *transferLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
size, height := layout.MinSize(l.maxMinSizeHeight, objects)
l.maxMinSizeHeight = height
return size
}