~eliasnaur/scatter

89f24cd57db0c19d1494b0845af711a64ef586e2 — Elias Naur 4 years ago 76579da
cmd/scatter: bump gio version

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

M cmd/scatter/ui.go
M go.mod
M go.sum
M cmd/scatter/ui.go => cmd/scatter/ui.go +45 -54
@@ 177,8 177,7 @@ type (
)

func uiMain() {
	gofont.Register()
	theme = material.NewTheme()
	theme = material.NewTheme(gofont.Collection())
	theme.Color.Primary = rgb(0x3c98c6)
	iconLib.create = mustIcon(icons.ContentCreate)
	iconLib.send = mustIcon(icons.ContentSend)


@@ 251,12 250,12 @@ func (a *App) run() error {
					}
				}
			case system.FrameEvent:
				gtx := layout.NewContext(&ops, e.Queue, e.Config, e.Size)
				gtx := layout.NewContext(&ops, e)
				a.env.insets = layout.Inset{
					Top:    e.Insets.Top,
					Left:   e.Insets.Left,
					Right:  e.Insets.Right,
					Bottom: unit.Add(gtx, unit.Dp(8), e.Insets.Bottom),
					Bottom: unit.Add(gtx.Metric, unit.Dp(8), e.Insets.Bottom),
				}
				a.Layout(gtx)
				if a.profiling {


@@ 285,15 284,13 @@ func (t *Transition) Event(gtx layout.Context) interface{} {
}

func (t *Transition) Layout(gtx layout.Context) layout.Dimensions {
	var stack op.StackOp
	stack.Push(gtx.Ops)
	defer stack.Pop()
	defer op.Push(gtx.Ops).Pop()
	prev, page := t.prev, t.page
	if prev != nil {
		if t.reverse {
			prev, page = page, prev
		}
		now := gtx.Now()
		now := gtx.Now
		if t.time.IsZero() {
			t.time = now
		}


@@ 315,13 312,13 @@ func (t *Transition) Layout(gtx layout.Context) layout.Dimensions {
		op.InvalidateOp{}.Add(gtx.Ops)
		center := size.Mul(.5)
		clipCenter := f32.Point{X: diameter / 2, Y: diameter / 2}
		off := op.TransformOp{}.Offset(center.Sub(clipCenter))
		off.Add(gtx.Ops)
		off := f32.Affine2D{}.Offset(center.Sub(clipCenter))
		op.Affine(off).Add(gtx.Ops)
		clip.Rect{
			Rect: f32.Rectangle{Max: f32.Point{X: diameter, Y: diameter}},
			NE:   radius, NW: radius, SE: radius, SW: radius,
		}.Op(gtx.Ops).Add(gtx.Ops)
		off.Invert().Add(gtx.Ops)
		op.Affine(off.Invert()).Add(gtx.Ops)
		fill{rgb(0xffffff)}.Layout(gtx)
	}
	return page.Layout(gtx)


@@ 427,7 424,7 @@ func (a *App) layoutTimings(gtx layout.Context) layout.Dimensions {
	a.lastMallocs = mstats.Mallocs
	return layout.NE.Layout(gtx, func(gtx C) D {
		in := a.env.insets
		in.Top = unit.Max(gtx, unit.Dp(16), in.Top)
		in.Top = unit.Max(gtx.Metric, unit.Dp(16), in.Top)
		return in.Layout(gtx, func(gtx C) D {
			txt := fmt.Sprintf("m: %d %s", mallocs, a.profile.Timings)
			lbl := material.Caption(theme, txt)


@@ 458,7 455,7 @@ func newContactsPage(env *Env) *contactsPage {
func (p *contactsPage) Start(stop <-chan struct{}) {}

func (p *contactsPage) Event(gtx layout.Context) interface{} {
	for _, e := range p.searchEdit.Events(gtx) {
	for _, e := range p.searchEdit.Events() {
		switch e := e.(type) {
		case widget.ChangeEvent:
			p.queryContacts(p.searchEdit.Text())


@@ 538,8 535,8 @@ func (p *contactsPage) contact(gtx layout.Context, index int) layout.Dimensions 
	in := layout.Inset{
		Top:    unit.Dp(16),
		Bottom: unit.Dp(16),
		Left:   unit.Max(gtx, unit.Dp(16), p.env.insets.Left),
		Right:  unit.Max(gtx, unit.Dp(16), p.env.insets.Right),
		Left:   unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Left),
		Right:  unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Right),
	}
	contact := p.contacts[index]
	click := &p.clicks[index]


@@ 575,10 572,10 @@ func (t *Topbar) Event(gtx layout.Context) interface{} {

func (t *Topbar) Layout(gtx layout.Context, insets layout.Inset, w layout.Widget) layout.Dimensions {
	insets = layout.Inset{
		Top:    unit.Add(gtx, insets.Top, unit.Dp(16)),
		Top:    unit.Add(gtx.Metric, insets.Top, unit.Dp(16)),
		Bottom: unit.Dp(16),
		Left:   unit.Max(gtx, insets.Left, unit.Dp(16)),
		Right:  unit.Max(gtx, insets.Right, unit.Dp(16)),
		Left:   unit.Max(gtx.Metric, insets.Left, unit.Dp(16)),
		Right:  unit.Max(gtx.Metric, insets.Right, unit.Dp(16)),
	}
	return layout.Stack{Alignment: layout.SW}.Layout(gtx,
		layout.Expanded(fill{theme.Color.Primary}.Layout),


@@ 589,7 586,7 @@ func (t *Topbar) Layout(gtx layout.Context, insets layout.Inset, w layout.Widget
						if !t.Back {
							return layout.Dimensions{}
						}
						ico := (&icon{src: icons.NavigationArrowBack, size: unit.Dp(24)}).image(gtx, rgb(0xffffff))
						ico := (&icon{src: icons.NavigationArrowBack, size: unit.Dp(24)}).image(gtx.Metric, rgb(0xffffff))
						ico.Add(gtx.Ops)
						paint.PaintOp{Rect: f32.Rectangle{Max: toPointF(ico.Size())}}.Add(gtx.Ops)
						dims := layout.Dimensions{Size: ico.Size()}


@@ 639,7 636,7 @@ func (p *signInPage) Start(stop <-chan struct{}) {
}

func (p *signInPage) Event(gtx layout.Context) interface{} {
	if p.submit.Clicked(gtx) {
	if p.submit.Clicked() {
		for _, f := range p.fields {
			*f.Value = f.edit.Text()
		}


@@ 665,8 662,8 @@ func (p *signInPage) Layout(gtx layout.Context) layout.Dimensions {
func (p *signInPage) layoutSigninForm(gtx layout.Context) layout.Dimensions {
	l := p.list
	inset := layout.Inset{
		Left:  unit.Max(gtx, unit.Dp(32), p.env.insets.Left),
		Right: unit.Max(gtx, unit.Dp(32), p.env.insets.Right),
		Left:  unit.Max(gtx.Metric, unit.Dp(32), p.env.insets.Left),
		Right: unit.Max(gtx.Metric, unit.Dp(32), p.env.insets.Right),
	}
	return l.Layout(gtx, len(p.fields)+1, func(gtx C, i int) D {
		in := inset


@@ 678,7 675,7 @@ func (p *signInPage) layoutSigninForm(gtx layout.Context) layout.Dimensions {
			}
			return in.Layout(gtx, p.fields[i].Layout)
		default:
			in.Bottom = unit.Max(gtx, unit.Dp(32), p.env.insets.Bottom)
			in.Bottom = unit.Max(gtx.Metric, unit.Dp(32), p.env.insets.Bottom)
			return layout.E.Layout(gtx, func(gtx C) D {
				return in.Layout(gtx, material.Button(theme, p.submit, "Sign in").Layout)
			})


@@ 707,12 704,10 @@ type Background struct {
}

func (b *Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
	var macro op.MacroOp
	macro.Record(gtx.Ops)
	macro := op.Record(gtx.Ops)
	dims := b.Inset.Layout(gtx, w)
	macro.Stop()
	var stack op.StackOp
	stack.Push(gtx.Ops)
	call := macro.Stop()
	defer op.Push(gtx.Ops).Pop()
	size := dims.Size
	width, height := float32(size.X), float32(size.Y)
	if r := float32(gtx.Px(b.Radius)); r > 0 {


@@ 730,8 725,7 @@ func (b *Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensio
	}
	paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
	paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: width, Y: height}}}.Add(gtx.Ops)
	macro.Add()
	stack.Pop()
	call.Add(gtx.Ops)
	return dims
}



@@ 765,7 759,7 @@ func (p *threadsPage) Event(gtx layout.Context) interface{} {
		p.env.redraw()
	default:
	}
	if p.fab.Clicked(gtx) {
	if p.fab.Clicked() {
		return ShowContactsEvent{}
	}
	for i := range p.clicks {


@@ 812,8 806,8 @@ func (p *threadsPage) Layout(gtx layout.Context) layout.Dimensions {
		layout.Stacked(func(gtx C) D {
			return layout.SE.Layout(gtx, func(gtx C) D {
				return layout.Inset{
					Right:  unit.Max(gtx, unit.Dp(16), p.env.insets.Right),
					Bottom: unit.Max(gtx, unit.Dp(16), p.env.insets.Bottom),
					Right:  unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Right),
					Bottom: unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Bottom),
				}.Layout(gtx,
					material.IconButton(theme, p.fab, iconLib.create).Layout,
				)


@@ 833,7 827,7 @@ func (p *threadsPage) layoutThreads(gtx layout.Context) layout.Dimensions {
		case 0:
			in.Top = unit.Dp(4)
		case len(p.threads) - 1:
			in.Bottom = unit.Max(gtx, unit.Dp(4), p.env.insets.Bottom)
			in.Bottom = unit.Max(gtx.Metric, unit.Dp(4), p.env.insets.Bottom)
		}
		return in.Layout(gtx, func(gtx C) D {
			return p.thread(gtx, i)


@@ 860,8 854,8 @@ func (p *threadsPage) thread(gtx layout.Context, index int) layout.Dimensions {
	}
	click := &p.clicks[index]
	in := layout.Inset{
		Left:  unit.Max(gtx, unit.Dp(16), p.env.insets.Left),
		Right: unit.Max(gtx, unit.Dp(16), p.env.insets.Right),
		Left:  unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Left),
		Right: unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Right),
	}
	return in.Layout(gtx, func(gtx C) D {
		in := layout.Inset{Top: unit.Dp(8), Bottom: unit.Dp(8)}


@@ 976,20 970,20 @@ func (p *threadPage) Event(gtx layout.Context) interface{} {
		p.fetchMessages()
	default:
	}
	for _, e := range p.msgEdit.Events(gtx) {
	for _, e := range p.msgEdit.Events() {
		if _, ok := e.(widget.SubmitEvent); ok {
			p.sendMessage()
		}
	}
	if p.send.Clicked(gtx) {
	if p.send.Clicked() {
		p.sendMessage()
	}
	if p.invite.Clicked(gtx) {
	if p.invite.Clicked() {
		if err := p.env.client.Send(p.thread.ID, "Invitation sent"); err != nil {
			log.Printf("failed to send invitation: %v", err)
		}
	}
	if p.accept.Clicked(gtx) {
	if p.accept.Clicked() {
		if err := p.env.client.Send(p.thread.ID, "Invitation accepted"); err != nil {
			log.Printf("failed to send invitation accept: %v", err)
		}


@@ 1034,9 1028,9 @@ func (p *threadPage) Layout(gtx layout.Context) layout.Dimensions {
		layout.Rigid(func(gtx C) D {
			return layout.Inset{
				Top:    unit.Dp(16),
				Left:   unit.Max(gtx, unit.Dp(16), p.env.insets.Left),
				Right:  unit.Max(gtx, unit.Dp(16), p.env.insets.Right),
				Bottom: unit.Max(gtx, unit.Dp(16), p.env.insets.Bottom),
				Left:   unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Left),
				Right:  unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Right),
				Bottom: unit.Max(gtx.Metric, unit.Dp(16), p.env.insets.Bottom),
			}.Layout(gtx, func(gtx C) D {
				switch {
				case p.thread.PendingInvitation:


@@ 1104,8 1098,8 @@ func (p *threadPage) message(gtx layout.Context, index int) layout.Dimensions {
		msgCol = theme.Color.Text
		timecol = rgb(0x888888)
	}
	in.Left = unit.Max(gtx, in.Left, p.env.insets.Left)
	in.Right = unit.Max(gtx, in.Right, p.env.insets.Right)
	in.Left = unit.Max(gtx.Metric, in.Left, p.env.insets.Left)
	in.Right = unit.Max(gtx.Metric, in.Right, p.env.insets.Right)
	return in.Layout(gtx, func(gtx C) D {
		return align.Layout(gtx, func(gtx C) D {
			bg := Background{


@@ 1142,7 1136,7 @@ func (p *threadPage) message(gtx layout.Context, index int) layout.Dimensions {
							child := layout.Rigid(func(gtx C) D {
								in := layout.Inset{Left: unit.Dp(12)}
								return in.Layout(gtx, func(gtx C) D {
									checkmark := p.checkmark.image(gtx, timecol)
									checkmark := p.checkmark.image(gtx.Metric, timecol)
									sz := checkmark.Size()
									if msg.Sent {
										checkmark.Add(gtx.Ops)


@@ 1240,24 1234,21 @@ type clipCircle struct {
}

func (cc *clipCircle) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
	var macro op.MacroOp
	macro.Record(gtx.Ops)
	macro := op.Record(gtx.Ops)
	dims := w(gtx)
	macro.Stop()
	call := macro.Stop()
	max := dims.Size.X
	if dy := dims.Size.Y; dy > max {
		max = dy
	}
	szf := float32(max)
	rr := szf * .5
	var stack op.StackOp
	stack.Push(gtx.Ops)
	defer op.Push(gtx.Ops).Pop()
	clip.Rect{
		Rect: f32.Rectangle{Max: f32.Point{X: szf, Y: szf}},
		NE:   rr, NW: rr, SE: rr, SW: rr,
	}.Op(gtx.Ops).Add(gtx.Ops)
	macro.Add()
	stack.Pop()
	call.Add(gtx.Ops)
	return dims
}



@@ 1265,7 1256,7 @@ func toPointF(p image.Point) f32.Point {
	return f32.Point{X: float32(p.X), Y: float32(p.Y)}
}

func (ic *icon) image(c unit.Converter, col color.RGBA) paint.ImageOp {
func (ic *icon) image(c unit.Metric, col color.RGBA) paint.ImageOp {
	sz := c.Px(ic.size)
	if sz == ic.imgSize {
		return ic.op

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

require (
	gioui.org v0.0.0-20200523202849-2451750782b8
	gioui.org v0.0.0-20200621194428-9e3d3b6f5823
	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


@@ 13,5 13,5 @@ require (
	github.com/stretchr/testify v1.3.0 // indirect
	go.etcd.io/bbolt v1.3.3
	golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3
	golang.org/x/image v0.0.0-20190802002840-cff245a6509b
	golang.org/x/image v0.0.0-20200618115811-c13761719519
)

M go.sum => go.sum +4 -2
@@ 1,6 1,6 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200523202849-2451750782b8 h1:TB+F3jDAVjNemdtgc8yfvsPy1xWkyn7JLOsm5r+YUuQ=
gioui.org v0.0.0-20200523202849-2451750782b8/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200621194428-9e3d3b6f5823 h1:Pm6K6MF8VqicZJDTghBsk4lLehw2LceCj1Bkw3moaS4=
gioui.org v0.0.0-20200621194428-9e3d3b6f5823/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV+s9GbhG13KcD+gEpkU=
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=


@@ 49,6 49,8 @@ golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgn
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200618115811-c13761719519 h1:1e2ufUJNM3lCHEY5jIgac/7UTjd6cgJNdatjPdFWf34=
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=