example: bump gio version and add flat button example to kitchen

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-11 13:20:04 +02:00
parent 23baeff18d
commit a0df8ba59b
6 changed files with 30 additions and 14 deletions
+1 -1
View File
@@ -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() {
+1 -1
View File
@@ -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
+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-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=
+2 -2
View File
@@ -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,
+23 -7
View File
@@ -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() {
+1 -1
View File
@@ -56,7 +56,7 @@ type Tabs struct {
}
type Tab struct {
btn widget.Button
btn widget.Clickable
Title string
}