mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
example: update to latest Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ module gioui.org/example
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20201102184456-38cdd28681b6
|
||||
gioui.org v0.0.0-20201105153219-94d242d18c92
|
||||
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
@@ -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-20201102184456-38cdd28681b6 h1:a/81sqLPxnLeWrsvR0NqrrdYA6quugSihC8j2A0b/o4=
|
||||
gioui.org v0.0.0-20201102184456-38cdd28681b6/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
gioui.org v0.0.0-20201105153219-94d242d18c92 h1:1GHIbWom8jXI3wzPOq5JOT40uEaPUFH9eki/ViecVR8=
|
||||
gioui.org v0.0.0-20201105153219-94d242d18c92/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
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=
|
||||
|
||||
@@ -327,11 +327,10 @@ type fill struct {
|
||||
func (f fill) Layout(gtx layout.Context) layout.Dimensions {
|
||||
cs := gtx.Constraints
|
||||
d := cs.Min
|
||||
dr := f32.Rectangle{
|
||||
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
||||
dr := image.Rectangle{
|
||||
Max: image.Point{X: d.X, Y: d.Y},
|
||||
}
|
||||
paint.ColorOp{Color: f.col}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
||||
paint.FillShape(gtx.Ops, f.col, clip.Rect(dr).Op())
|
||||
return layout.Dimensions{Size: d}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/op/paint"
|
||||
"gioui.org/text"
|
||||
"gioui.org/unit"
|
||||
@@ -241,14 +242,6 @@ func (b iconAndTextButton) Layout(gtx layout.Context) layout.Dimensions {
|
||||
})
|
||||
}
|
||||
|
||||
func bounds(gtx layout.Context) f32.Rectangle {
|
||||
cs := gtx.Constraints
|
||||
d := cs.Min
|
||||
return f32.Rectangle{
|
||||
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
||||
}
|
||||
}
|
||||
|
||||
func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
for _, e := range lineEditor.Events() {
|
||||
if e, ok := e.(widget.SubmitEvent); ok {
|
||||
@@ -274,15 +267,16 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
gtx.Constraints.Min.Y = gtx.Px(unit.Dp(50))
|
||||
gtx.Constraints.Max.Y = gtx.Constraints.Min.Y
|
||||
|
||||
dr := bounds(gtx)
|
||||
dr := image.Rectangle{Max: gtx.Constraints.Min}
|
||||
defer op.Push(gtx.Ops).Pop()
|
||||
paint.LinearGradientOp{
|
||||
Stop1: dr.Min,
|
||||
Stop2: dr.Max,
|
||||
Stop1: layout.FPt(dr.Min),
|
||||
Stop2: layout.FPt(dr.Max),
|
||||
Color1: color.RGBA{0x10, 0xff, 0x10, 0xFF},
|
||||
Color2: color.RGBA{0x10, 0x10, 0xff, 0xFF},
|
||||
}.Add(gtx.Ops)
|
||||
|
||||
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
||||
clip.Rect(dr).Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
return layout.Dimensions{
|
||||
Size: gtx.Constraints.Max,
|
||||
}
|
||||
|
||||
+13
-22
@@ -15,6 +15,7 @@ import (
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/op/paint"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
@@ -105,14 +106,9 @@ func drawTabs(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
if tabs.selected != tabIdx {
|
||||
return layout.Dimensions{}
|
||||
}
|
||||
paint.ColorOp{Color: th.Color.Primary}.Add(gtx.Ops)
|
||||
tabHeight := gtx.Px(unit.Dp(4))
|
||||
paint.PaintOp{Rect: f32.Rectangle{
|
||||
Max: f32.Point{
|
||||
X: float32(tabWidth),
|
||||
Y: float32(tabHeight),
|
||||
},
|
||||
}}.Add(gtx.Ops)
|
||||
tabRect := image.Rect(0, 0, tabWidth, tabHeight)
|
||||
paint.FillShape(gtx.Ops, th.Color.Primary, clip.Rect(tabRect).Op())
|
||||
return layout.Dimensions{
|
||||
Size: image.Point{X: tabWidth, Y: tabHeight},
|
||||
}
|
||||
@@ -131,31 +127,26 @@ func drawTabs(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
)
|
||||
}
|
||||
|
||||
func bounds(gtx layout.Context) f32.Rectangle {
|
||||
cs := gtx.Constraints
|
||||
d := cs.Min
|
||||
return f32.Rectangle{
|
||||
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
||||
}
|
||||
}
|
||||
|
||||
func fill(gtx layout.Context, col1, col2 color.RGBA) {
|
||||
dr := bounds(gtx)
|
||||
paint.ColorOp{Color: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xFF}}.Add(gtx.Ops)
|
||||
paint.ColorOp{Color: color.RGBA{R: 0, G: 0, B: 0, A: 0xFF}}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
||||
dr := image.Rectangle{Max: gtx.Constraints.Min}
|
||||
paint.FillShape(gtx.Ops,
|
||||
color.RGBA{R: 0, G: 0, B: 0, A: 0xFF},
|
||||
clip.Rect(dr).Op(),
|
||||
)
|
||||
|
||||
col2.R = byte(float32(col2.R))
|
||||
col2.G = byte(float32(col2.G))
|
||||
col2.B = byte(float32(col2.B))
|
||||
col2.A = byte(float32(col2.A) * 0.2)
|
||||
paint.LinearGradientOp{
|
||||
Stop1: f32.Pt(dr.Min.X, 0),
|
||||
Stop2: f32.Pt(dr.Max.X, 0),
|
||||
Stop1: f32.Pt(float32(dr.Min.X), 0),
|
||||
Stop2: f32.Pt(float32(dr.Max.X), 0),
|
||||
Color1: col1,
|
||||
Color2: col2,
|
||||
}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
||||
defer op.Push(gtx.Ops).Pop()
|
||||
clip.Rect(dr).Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
}
|
||||
|
||||
func dynamicColor(i int) color.RGBA {
|
||||
|
||||
Reference in New Issue
Block a user