forked from libsgh/chrome_updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.go
30 lines (22 loc) · 884 Bytes
/
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
package main
import "fyne.io/fyne/v2"
type buttonLayout struct{}
func (l *buttonLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
// 将选项卡容器放在顶部,按钮放在底部
tabContent := objects[0]
button := objects[1]
buttonSize := button.MinSize()
button.Resize(fyne.NewSize(size.Width, buttonSize.Height))
button.Move(fyne.NewPos(0, size.Height-buttonSize.Height))
tabContent.Resize(fyne.NewSize(size.Width, size.Height-buttonSize.Height-20))
tabContent.Move(fyne.NewPos(0, 0))
}
func (l *buttonLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
// 计算布局的最小尺寸
tabContent := objects[0]
button := objects[1]
tabContentMinSize := tabContent.MinSize()
buttonMinSize := button.MinSize()
return fyne.NewSize(fyne.Max(tabContentMinSize.Width, buttonMinSize.Width),
tabContentMinSize.Height+buttonMinSize.Height+20)
}