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
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/example
go 1.13
require (
gioui.org v0.0.0-20200613094620-1b944c8e6556
gioui.org v0.0.0-20200615075349-9f6e09317d80
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72
github.com/google/go-github/v24 v24.0.1
+2 -2
View File
@@ -1,7 +1,7 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200613094620-1b944c8e6556 h1:CwAjSar9rhVuesKivjOTUx9CpeS0jsBFfKIk8kC8F1w=
gioui.org v0.0.0-20200613094620-1b944c8e6556/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200615075349-9f6e09317d80 h1:WXLl1RborKke9HbG04erZh3KcXClWF3izOoAsui45KI=
gioui.org v0.0.0-20200615075349-9f6e09317d80/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
+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)
})
})
})