-
Notifications
You must be signed in to change notification settings - Fork 60
/
main.go
38 lines (33 loc) · 889 Bytes
/
main.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
package main
import (
"fmt"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
xwidget "fyne.io/x/fyne/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Two State Demo")
twoState0 := xwidget.NewTwoStateToolbarAction(nil,
nil, func(on bool) {
fmt.Println(on)
})
sep := widget.NewToolbarSeparator()
tb := widget.NewToolbar(twoState0, sep)
toggleButton := widget.NewButton("Toggle State", func() {
on := twoState0.GetOn()
twoState0.SetOn(!on)
})
offIconButton := widget.NewButton("Set OffIcon", func() {
twoState0.SetOffIcon(theme.MediaPlayIcon())
})
onIconButton := widget.NewButton("Set OnIcon", func() {
twoState0.SetOnIcon(theme.MediaStopIcon())
})
vc := container.NewVBox(toggleButton, offIconButton, onIconButton)
c := container.NewBorder(tb, vc, nil, nil)
w.SetContent(c)
w.ShowAndRun()
}