From 5a82fc9267c855ec6b7812433d4d4294e62691af Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 12 Oct 2019 16:52:00 +0200 Subject: [PATCH] example/kitchen: place buttons on the same row Signed-off-by: Elias Naur --- example/kitchen/kitchen.go | 47 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/example/kitchen/kitchen.go b/example/kitchen/kitchen.go index ea090aa7..9953e655 100644 --- a/example/kitchen/kitchen.go +++ b/example/kitchen/kitchen.go @@ -104,24 +104,35 @@ func kitchen(gtx *layout.Context, th *material.Theme) { } }, func() { - for button.Clicked(gtx) { - enabled = !enabled - } - th.Button("Click me!").Layout(gtx, button) - }, - func() { - if enabled { - for disabledButton.Clicked(gtx) { - } - th.Button("Enabled").Layout(gtx, disabledButton) - } else { - th.Button("Disabled").Layout(gtx, disabledButton) - } - }, - func() { - for iconButton.Clicked(gtx) { - } - th.IconButton(icon).Layout(gtx, iconButton) + buttons := layout.Flex{Alignment: layout.Middle} + in := layout.UniformInset(unit.Dp(8)) + b1 := buttons.Rigid(gtx, func() { + in.Layout(gtx, func() { + for iconButton.Clicked(gtx) { + } + th.IconButton(icon).Layout(gtx, iconButton) + }) + }) + b2 := buttons.Rigid(gtx, func() { + in.Layout(gtx, func() { + for button.Clicked(gtx) { + enabled = !enabled + } + th.Button("Click me!").Layout(gtx, button) + }) + }) + b3 := buttons.Rigid(gtx, func() { + in.Layout(gtx, func() { + if enabled { + for disabledButton.Clicked(gtx) { + } + th.Button("Enabled").Layout(gtx, disabledButton) + } else { + th.Button("Disabled").Layout(gtx, disabledButton) + } + }) + }) + buttons.Layout(gtx, b1, b2, b3) }, } list.Layout(gtx, len(widgets), func(i int) {