go.*,cmd/tailscale: upgrade Gio

Add proper margins to toast messages while here.

Fixes tailscale/tailscale#3059

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/24/head
Elias Naur 3 years ago
parent 0a13b89ce0
commit a3152ae505

@ -490,8 +490,7 @@ type Dismiss struct {
}
func (d *Dismiss) Add(gtx layout.Context, color color.NRGBA) {
defer op.Save(gtx.Ops).Load()
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Add(gtx.Ops)
defer pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
pointer.InputOp{Tag: d, Types: pointer.Press}.Add(gtx.Ops)
paint.Fill(gtx.Ops, color)
}
@ -1008,7 +1007,11 @@ func (ui *UI) layoutMessage(gtx layout.Context, sysIns system.Insets) layout.Dim
}
op.InvalidateOp{At: now.Add(rem)}.Add(gtx.Ops)
return layout.S.Layout(gtx, func(gtx C) D {
return layout.Inset{Bottom: unit.Add(gtx.Metric, sysIns.Bottom, unit.Dp(8))}.Layout(gtx, func(gtx C) D {
return layout.Inset{
Left: unit.Add(gtx.Metric, sysIns.Left, unit.Dp(8)),
Right: unit.Add(gtx.Metric, sysIns.Right, unit.Dp(8)),
Bottom: unit.Add(gtx.Metric, sysIns.Bottom, unit.Dp(8)),
}.Layout(gtx, func(gtx C) D {
return Background{Color: rgb(0x323232), CornerRadius: unit.Dp(5)}.Layout(gtx, func(gtx C) D {
return layout.UniformInset(unit.Dp(12)).Layout(gtx, func(gtx C) D {
l := material.Body2(ui.theme, s)
@ -1214,60 +1217,58 @@ func drawLogo(ops *op.Ops, size int) {
tx := op.Offset(f32.Pt(off, 0))
ty := op.Offset(f32.Pt(0, off))
st := op.Save(ops)
defer st.Load()
defer op.Offset(f32.Point{}).Push(ops).Pop()
// First row of discs.
row := op.Save(ops)
row := op.Offset(f32.Point{}).Push(ops)
drawDisc(ops, discDia, rgb(0x54514d))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0x54514d))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0x54514d))
row.Load()
row.Pop()
ty.Add(ops)
// Second row.
row = op.Save(ops)
row = op.Offset(f32.Point{}).Push(ops)
drawDisc(ops, discDia, rgb(0xfffdfa))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0xfffdfa))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0xfffdfa))
row.Load()
row.Pop()
ty.Add(ops)
// Third row.
row = op.Save(ops)
row = op.Offset(f32.Point{}).Push(ops)
drawDisc(ops, discDia, rgb(0xfffdfa))
drawDisc(ops, discDia, rgb(0x54514d))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0xfffdfa))
tx.Add(ops)
drawDisc(ops, discDia, rgb(0x54514d))
row.Load()
row.Pop()
}
func drawImage(gtx layout.Context, img paint.ImageOp, size unit.Value) layout.Dimensions {
defer op.Save(gtx.Ops).Load()
img.Add(gtx.Ops)
sz := img.Size()
aspect := float32(sz.Y) / float32(sz.X)
w := gtx.Px(size)
h := int(float32(w)*aspect + .5)
scale := float32(w) / float32(sz.X)
op.Affine(f32.Affine2D{}.Scale(f32.Point{}, f32.Point{X: scale, Y: scale})).Add(gtx.Ops)
defer op.Affine(f32.Affine2D{}.Scale(f32.Point{}, f32.Point{X: scale, Y: scale})).Push(gtx.Ops).Pop()
paint.PaintOp{}.Add(gtx.Ops)
return layout.Dimensions{Size: image.Pt(w, h)}
}
func drawDisc(ops *op.Ops, radius float32, col color.NRGBA) {
defer op.Save(ops).Load()
r2 := radius * .5
dr := f32.Rectangle{Max: f32.Pt(radius, radius)}
clip.RRect{
defer clip.RRect{
Rect: dr,
NE: r2, NW: r2, SE: r2, SW: r2,
}.Add(ops)
}.Push(ops).Pop()
paint.ColorOp{Color: col}.Add(ops)
paint.PaintOp{}.Add(ops)
}
@ -1286,13 +1287,13 @@ func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimension
// Clip corners, if any.
if r := gtx.Px(b.CornerRadius); r > 0 {
rr := float32(r)
clip.RRect{
defer clip.RRect{
Rect: f32.Rectangle{Max: f32.Point{
X: float32(sz.X),
Y: float32(sz.Y),
}},
NE: rr, NW: rr, SE: rr, SW: rr,
}.Add(gtx.Ops)
}.Push(gtx.Ops).Pop()
}
fill{b.Color}.Layout(gtx, sz)
call.Add(gtx.Ops)
@ -1304,8 +1305,7 @@ type fill struct {
}
func (f fill) Layout(gtx layout.Context, sz image.Point) layout.Dimensions {
defer op.Save(gtx.Ops).Load()
clip.Rect(image.Rectangle{Max: sz}).Add(gtx.Ops)
defer clip.Rect(image.Rectangle{Max: sz}).Push(gtx.Ops).Pop()
paint.ColorOp{Color: f.col}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
return layout.Dimensions{Size: sz}

@ -4,7 +4,7 @@ go 1.17
require (
eliasnaur.com/font v0.0.0-20200617114307-e02d32decb4b
gioui.org v0.0.0-20210925100615-41f3a7e74ee6
gioui.org v0.0.0-20211016064351-4d22a926a9dd
gioui.org/cmd v0.0.0-20210925100615-41f3a7e74ee6
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34

@ -18,8 +18,8 @@ eliasnaur.com/font v0.0.0-20200617114307-e02d32decb4b/go.mod h1:CYwJpIhpzVfoHpFX
filippo.io/mkcert v1.4.3 h1:axpnmtrZMM8u5Hf4N3UXxboGemMOV+Tn+e+pkHM6E3o=
filippo.io/mkcert v1.4.3/go.mod h1:64ke566uBwAQcdK3vRDABgsgVHqrfORPTw6YytZCTxk=
gioui.org v0.0.0-20210910062418-d5d0a75a9bcb/go.mod h1:BTldRXnY5mrUrYZCdWyDwyMzyUzpfZN1cF4MMRrOt9w=
gioui.org v0.0.0-20210925100615-41f3a7e74ee6 h1:Eq8+DAY1WPaehLB/ixOXu38sKInyDhFQMH33V+CRB04=
gioui.org v0.0.0-20210925100615-41f3a7e74ee6/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211016064351-4d22a926a9dd h1:G5Rkf+VCEvFprJxe7E25N+40hCAI4fMv3iR7l2PekmE=
gioui.org v0.0.0-20211016064351-4d22a926a9dd/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org/cmd v0.0.0-20210925100615-41f3a7e74ee6 h1:SkAdohDhTUjl+ZtM417Xeu+uFd7SQubwR9uAyqJqC8c=
gioui.org/cmd v0.0.0-20210925100615-41f3a7e74ee6/go.mod h1:qrH3h4nt/PyIqx/XabL/eJ5cXQnQ0ERHqC3VEXx/Rmg=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
@ -554,6 +554,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
@ -1011,9 +1012,5 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237 h1:iAEkCBPbRaflBgZ7o9gjVUuWuvWeV4sytFWg9o+Pj2k=
software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237/go.mod h1:/xvNRWUqm0+/ZMiF4EX00vrSCMsE4/NHb+Pt3freEeQ=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
tailscale.com v1.1.1-0.20211005220235-67e5fabdbdba h1:szGUzQIThyKAKJDxXuL5lgUmEU4hzWUW+noas/MYD8M=
tailscale.com v1.1.1-0.20211005220235-67e5fabdbdba/go.mod h1:2ordBMiDa1Gx6r8ci5EtSS3Wl0RanS46+l8T2vwqUtI=
tailscale.com v1.1.1-0.20211008004653-1f506d23514a h1:htyjSQ+1+YeW+aapSMq8hlCPk+dJlkbWvIuWIVgbWP4=
tailscale.com v1.1.1-0.20211008004653-1f506d23514a/go.mod h1:+dISSbd6iiY6F6/dRGQRgshjYXMkhMzVvRd9En8RLfQ=
tailscale.com v1.1.1-0.20211008163715-e5dddb2b9928 h1:0d48ymcsb+yT7cHqA9OC8+CioFOCsVKXxyhBQ545MkE=
tailscale.com v1.1.1-0.20211008163715-e5dddb2b9928/go.mod h1:+dISSbd6iiY6F6/dRGQRgshjYXMkhMzVvRd9En8RLfQ=

Loading…
Cancel
Save