fyne-widgets/examples/vumeter/main.go

34 lines
982 B
Go

package main
import (
"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/vumeter"
)
func main() {
a := app.New()
w := a.NewWindow("VUMeter")
level := binding.NewFloat()
levelPB := vumeter.NewVUMeterWithData(level)
level.Set(0.95)
levelPB.TextFormatter = func() string { return " " }
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 := vumeter.NewVUMeterWithData(level)
vLevelPB.VUMeterDirection = vumeter.VUMeterVertical
vLevelPB.TextFormatter = func() string { return " " }
contain := container.New(layout.NewVBoxLayout(), levelPB, progress, slider)
w.SetContent(container.New(layout.NewHBoxLayout(), contain, vLevelPB))
w.ShowAndRun()
}