2021-12-11 13:54:32 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"image/color"
|
|
|
|
|
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/app"
|
|
|
|
"fyne.io/fyne/v2/canvas"
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
|
|
|
"git.martyn.berlin/martyn/fyne-widgets/pkg/layouts"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
a := app.New()
|
|
|
|
w := a.NewWindow("FloatingButtons")
|
|
|
|
|
|
|
|
background := canvas.NewRectangle(color.RGBA{255, 0, 0, 128})
|
|
|
|
|
|
|
|
layout := layouts.NewFloatingControlsLayout()
|
|
|
|
layout.FloatingControlsLocation = layouts.FloatingControlsCenter
|
|
|
|
button := widget.NewButton("X", func() {
|
|
|
|
fmt.Println("button clicked")
|
|
|
|
layout.FloatingControlsLocation = layout.FloatingControlsLocation + 1
|
2021-12-11 14:22:55 +00:00
|
|
|
if layout.FloatingControlsLocation > 8 {
|
2021-12-11 13:54:32 +00:00
|
|
|
layout.FloatingControlsLocation = 0
|
|
|
|
}
|
|
|
|
w.SetContent(w.Content())
|
|
|
|
})
|
|
|
|
|
|
|
|
w.SetContent(container.New(&layout, background, button))
|
|
|
|
w.Resize(fyne.NewSize(100, 100))
|
|
|
|
w.ShowAndRun()
|
|
|
|
}
|