fyne-widgets/examples/nuvumeter/main.go

38 lines
1.1 KiB
Go
Raw Normal View History

package main
import (
"time"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"git.martyn.berlin/martyn/fyne-widgets/pkg/numeter"
)
func main() {
a := app.New()
w := a.NewWindow("VUMeter")
level := binding.NewFloat()
levelPB := numeter.NewVUMeterWithData(level)
level.Set(0.95)
levelPB.TextFormatter = func() string { return " " }
levelPB.Peakhold = 3 * time.Second
progress := widget.NewProgressBarWithData(level)
setLevel := binding.NewFloat()
setLevel.Set(75.0)
slider := widget.NewSliderWithData(0.0, 100.0, setLevel)
slider.OnChanged = func(data float64) {
level.Set(data / 100)
}
vLevelPB := numeter.NewVUMeterWithData(level)
vLevelPB.VUMeterDirection = numeter.VUMeterVertical
levelPB.Peakhold = 3 * time.Second
levelPB.TextFormatter = func() string { return " " }
contain := container.New(layout.NewVBoxLayout(), levelPB, progress, slider)
w.SetContent(container.New(layout.NewHBoxLayout(), contain, vLevelPB))
w.ShowAndRun()
}