~eliasnaur/scatter

f1cf9f0bfec533fda6ddb22a63b67c3dd7fdfb3e — Elias Naur 11 months ago 811d851
cmd/scatter: don't preserve button clicks across layouts

text.Editor flush its events at Layout out of necessity, so buttons
should do so as well for consistency.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 files changed, 9 insertions(+), 8 deletions(-)

M cmd/scatter/ui.go
M go.mod
M go.sum
M cmd/scatter/ui.go => cmd/scatter/ui.go +6 -5
@@ 751,17 751,17 @@ func (b *buttonState) Clicked(gtx *layout.Context) bool {
	}
	if b.clicks > 0 {
		b.clicks--
		if b.clicks > 0 {
			// Ensure remaining clicks are delivered in the next frame
			// in the worst case.
			ui.InvalidateOp{}.Add(gtx.Ops)
		}
		return true
	}
	return false
}

func (b *buttonState) clear() {
	b.clicks = 0
}

func (b *Button) Layout(gtx *layout.Context, env *Env) {
	b.buttonState.clear()
	bg := Background{
		Material: theme.brand,
		Radius:   ui.Dp(4),


@@ 1281,6 1281,7 @@ func formatTime(t time.Time) string {
}

func (b *IconButton) Layout(gtx *layout.Context) {
	b.buttonState.clear()
	ico := b.Icon.image(gtx, rgb(0xffffff))
	bg := Background{
		Material: theme.brand,

M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module scatter.im
go 1.13

require (
	gioui.org/ui v0.0.0-20190926164321-90e2a119c04b
	gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea
	github.com/eliasnaur/libsignal-protocol-go v0.0.0-20190626062856-3295f72b181e
	github.com/emersion/go-imap v1.0.0-rc.1
	github.com/emersion/go-imap-idle v0.0.0-20190519112320-2704abd7050e

M go.sum => go.sum +2 -2
@@ 1,5 1,5 @@
gioui.org/ui v0.0.0-20190926164321-90e2a119c04b h1:oMl/FgQRgYkQkv6U72L80UKT0RovlAZX9weefmgyKSQ=
gioui.org/ui v0.0.0-20190926164321-90e2a119c04b/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE=
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea h1:rv21Wx1Inf27NY453rrrP6tuEG65PyWPhnP2Jx+Qb8k=
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/RadicalApp/complete v0.0.0-20170329192659-17e6c0ee499b h1:cAULFohNVfNzco0flF4okSPg3s7/tCj+hMIldtYZo4c=
github.com/RadicalApp/complete v0.0.0-20170329192659-17e6c0ee499b/go.mod h1:zZ3+l0EkpT2ZPnoamPBG50PBUtQrXwwyJ6elQZMmqgk=