example/kitchen: add Switch widget

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-04 14:30:32 +02:00
parent 26da49e145
commit 05efb9b5f4
3 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/example
go 1.13
require (
gioui.org v0.0.0-20200503190452-8d9612f9aa46
gioui.org v0.0.0-20200505083831-26da49e145f3
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-20200503190452-8d9612f9aa46 h1:7OFSBlHlymqJPrX54xUKnattrlsTxmVbTZwtFbG+kgU=
gioui.org v0.0.0-20200503190452-8d9612f9aa46/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200505083831-26da49e145f3 h1:cWBPA7uPLhrfO3AfRaD2YwsURnANl5zfR6j1N5Vv58U=
gioui.org v0.0.0-20200505083831-26da49e145f3/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=
+12 -2
View File
@@ -141,7 +141,8 @@ var (
green = true
topLabel = "Hello, Gio"
icon *widget.Icon
checkbox = new(widget.CheckBox)
checkbox = new(widget.Bool)
swtch = new(widget.Bool)
)
func (b iconAndTextButton) Layout(gtx *layout.Context, button *widget.Button, icon *widget.Icon, word string) {
@@ -227,7 +228,16 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
material.ProgressBar(th).Layout(gtx, progress)
},
func() {
material.CheckBox(th, "Checkbox").Layout(gtx, checkbox)
layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func() {
material.CheckBox(th, "Checkbox").Layout(gtx, checkbox)
}),
layout.Rigid(func() {
layout.Inset{Left: unit.Dp(16)}.Layout(gtx, func() {
material.Switch(th).Layout(gtx, swtch)
})
}),
)
},
func() {
layout.Flex{}.Layout(gtx,