From 5214b26731a66d936229e11112bc2b3df872be5c Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Sun, 14 Jun 2020 11:38:56 -0400 Subject: [PATCH] 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 --- example/go.mod | 2 +- example/go.sum | 4 ++-- example/kitchen/kitchen.go | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/example/go.mod b/example/go.mod index 28ca6543..1b172f3d 100644 --- a/example/go.mod +++ b/example/go.mod @@ -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 diff --git a/example/go.sum b/example/go.sum index 9eaa2b75..f6388965 100644 --- a/example/go.sum +++ b/example/go.sum @@ -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= diff --git a/example/kitchen/kitchen.go b/example/kitchen/kitchen.go index 1ac974a3..31954ce0 100644 --- a/example/kitchen/kitchen.go +++ b/example/kitchen/kitchen.go @@ -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) }) }) })