example/kitchen: place buttons on the same row

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-12 16:52:00 +02:00
parent e1de1ba591
commit 5a82fc9267
+18 -7
View File
@@ -104,12 +104,25 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
} }
}, },
func() { func() {
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) { for button.Clicked(gtx) {
enabled = !enabled enabled = !enabled
} }
th.Button("Click me!").Layout(gtx, button) th.Button("Click me!").Layout(gtx, button)
}, })
func() { })
b3 := buttons.Rigid(gtx, func() {
in.Layout(gtx, func() {
if enabled { if enabled {
for disabledButton.Clicked(gtx) { for disabledButton.Clicked(gtx) {
} }
@@ -117,11 +130,9 @@ func kitchen(gtx *layout.Context, th *material.Theme) {
} else { } else {
th.Button("Disabled").Layout(gtx, disabledButton) th.Button("Disabled").Layout(gtx, disabledButton)
} }
}, })
func() { })
for iconButton.Clicked(gtx) { buttons.Layout(gtx, b1, b2, b3)
}
th.IconButton(icon).Layout(gtx, iconButton)
}, },
} }
list.Layout(gtx, len(widgets), func(i int) { list.Layout(gtx, len(widgets), func(i int) {