example/kitchen: add Float/Slider

Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
This commit is contained in:
Gordon Klaus
2020-06-17 19:24:44 +02:00
committed by Elias Naur
parent 5368743478
commit 20cf570709
5 changed files with 19 additions and 7 deletions
+13 -1
View File
@@ -13,6 +13,7 @@ import (
"image/png"
"io/ioutil"
"log"
"math"
"os"
"time"
@@ -67,7 +68,7 @@ func main() {
}()
go func() {
w := app.NewWindow(app.Size(unit.Dp(800), unit.Dp(650)))
w := app.NewWindow(app.Size(unit.Dp(800), unit.Dp(700)))
if err := loop(w); err != nil {
log.Fatal(err)
}
@@ -197,6 +198,7 @@ var (
checkbox = new(widget.Bool)
swtch = new(widget.Bool)
transformTime time.Time
float = new(widget.Float)
)
type (
@@ -329,6 +331,16 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
layout.Rigid(material.RadioButton(th, radioButtonsGroup, "r3", "RadioButton3").Layout),
)
},
func(gtx C) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(1, material.Slider(th, float, 0, 2*math.Pi).Layout),
layout.Rigid(func(gtx C) D {
return layout.UniformInset(unit.Dp(8)).Layout(gtx,
material.Body1(th, fmt.Sprintf("%.2f", float.Value)).Layout,
)
}),
)
},
}
return list.Layout(gtx, len(widgets), func(gtx C, i int) D {