example/kitchen: add flag to draw all widgets disabled

This adds a --disable flag to the kitchen example so that it's easy
to preview what all widgets look like when they are disabled.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2020-06-14 11:38:56 -04:00
committed by Elias Naur
parent 9f6e09317d
commit 5214b26731
3 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -33,6 +33,7 @@ import (
)
var screenshot = flag.String("screenshot", "", "save a screenshot to a file and exit")
var disable = flag.Bool("disable", false, "disable all widgets")
type scaledConfig struct {
Scale float32
@@ -125,6 +126,9 @@ func loop(w *app.Window) error {
for flatBtn.Clicked() {
w.ReadClipboard()
}
if *disable {
gtx = gtx.Disabled()
}
kitchen(gtx, th)
e.Frame(gtx.Ops)
}
@@ -251,7 +255,11 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
return in.Layout(gtx, func(gtx C) D {
return material.Clickable(gtx, flatBtn, func(gtx C) D {
return layout.UniformInset(unit.Dp(12)).Layout(gtx, func(gtx C) D {
return layout.Center.Layout(gtx, material.Body1(th, "Flat").Layout)
flatBtnText := material.Body1(th, "Flat")
if gtx.Queue == nil {
flatBtnText.Color.A = 150
}
return layout.Center.Layout(gtx, flatBtnText.Layout)
})
})
})