From a0df8ba59b0f52823e95a5b76afa7361e5d5ed63 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 11 May 2020 13:20:04 +0200 Subject: [PATCH] example: bump gio version and add flat button example to kitchen Signed-off-by: Elias Naur --- example/glfw/main.go | 2 +- example/go.mod | 2 +- example/go.sum | 4 ++-- example/gophers/ui.go | 4 ++-- example/kitchen/kitchen.go | 30 +++++++++++++++++++++++------- example/tabs/tabs.go | 2 +- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/example/glfw/main.go b/example/glfw/main.go index 463bc92e..a2b0f8eb 100644 --- a/example/glfw/main.go +++ b/example/glfw/main.go @@ -94,7 +94,7 @@ func main() { } } -var button widget.Button +var button widget.Clickable func draw(gtx *layout.Context, th *material.Theme) { layout.Center.Layout(gtx, func() { diff --git a/example/go.mod b/example/go.mod index 817fe499..1c1dc0fa 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-20200511093148-c32b3fe43a46 + gioui.org v0.0.0-20200511111714-23baeff18d75 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 8666ce2c..771b28be 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-20200511093148-c32b3fe43a46 h1:jPi+Ew7978cqHkgczCRtplLf1HBly+ZQDcDmevrWIm8= -gioui.org v0.0.0-20200511093148-c32b3fe43a46/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04= +gioui.org v0.0.0-20200511111714-23baeff18d75 h1:SHkyPzrwOM1YO/oSzndp/fHDgKEL6DViOu73eEddYgs= +gioui.org v0.0.0-20200511111714-23baeff18d75/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/gophers/ui.go b/example/gophers/ui.go index 5f68fe70..4947b7cd 100644 --- a/example/gophers/ui.go +++ b/example/gophers/ui.go @@ -34,7 +34,7 @@ import ( ) type UI struct { - fab *widget.Button + fab *widget.Clickable fabIcon *widget.Icon usersList *layout.List users []*user @@ -79,7 +79,7 @@ func newUI(fetchCommits func(string)) *UI { u.usersList = &layout.List{ Axis: layout.Vertical, } - u.fab = new(widget.Button) + u.fab = new(widget.Clickable) u.edit2 = &widget.Editor{ //Alignment: text.End, SingleLine: true, diff --git a/example/kitchen/kitchen.go b/example/kitchen/kitchen.go index f48026f7..ca1ef778 100644 --- a/example/kitchen/kitchen.go +++ b/example/kitchen/kitchen.go @@ -128,10 +128,11 @@ var ( SingleLine: true, Submit: true, } - button = new(widget.Button) - greenButton = new(widget.Button) - iconTextButton = new(widget.Button) - iconButton = new(widget.Button) + button = new(widget.Clickable) + greenButton = new(widget.Clickable) + iconTextButton = new(widget.Clickable) + iconButton = new(widget.Clickable) + flatBtn = new(widget.Clickable) radioButtonsGroup = new(widget.Enum) list = &layout.List{ Axis: layout.Vertical, @@ -145,7 +146,7 @@ var ( swtch = new(widget.Bool) ) -func (b iconAndTextButton) Layout(gtx *layout.Context, button *widget.Button, icon *widget.Icon, word string) { +func (b iconAndTextButton) Layout(gtx *layout.Context, button *widget.Clickable, icon *widget.Icon, word string) { material.ButtonLayout(b.theme).Layout(gtx, button, func() { iconAndLabel := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle} textIconSpacer := unit.Dp(5) @@ -204,7 +205,7 @@ func kitchen(gtx *layout.Context, th *material.Theme) { }), layout.Rigid(func() { in.Layout(gtx, func() { - iconAndTextButton{th}.Layout(gtx, iconTextButton, icon, "Horizontal button") + iconAndTextButton{th}.Layout(gtx, iconTextButton, icon, "Icon") }) }), layout.Rigid(func() { @@ -217,13 +218,28 @@ func kitchen(gtx *layout.Context, th *material.Theme) { }), layout.Rigid(func() { in.Layout(gtx, func() { - btn := material.Button(th, "Green button") + l := "Green" + if !green { + l = "Blue" + } + btn := material.Button(th, l) if green { btn.Background = color.RGBA{A: 0xff, R: 0x9e, G: 0x9d, B: 0x24} } btn.Layout(gtx, greenButton) }) }), + layout.Rigid(func() { + in.Layout(gtx, func() { + material.Clickable(gtx, flatBtn, func() { + layout.UniformInset(unit.Dp(12)).Layout(gtx, func() { + layout.Center.Layout(gtx, func() { + material.Body1(th, "Flat").Layout(gtx) + }) + }) + }) + }) + }), ) }, func() { diff --git a/example/tabs/tabs.go b/example/tabs/tabs.go index 94d15e20..6afcc1e7 100644 --- a/example/tabs/tabs.go +++ b/example/tabs/tabs.go @@ -56,7 +56,7 @@ type Tabs struct { } type Tab struct { - btn widget.Button + btn widget.Clickable Title string }