apps: updates for renamed and moved packages

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-30 15:20:02 +02:00
parent 3784ece6dd
commit 6bc5ff2479
8 changed files with 69 additions and 66 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/apps
go 1.13
require (
gioui.org v0.0.0-20190930103706-22cd88df9f7f
gioui.org v0.0.0-20190930145547-3784ece6dd65
github.com/google/go-github/v24 v24.0.1
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9
+2 -2
View File
@@ -1,6 +1,6 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
gioui.org v0.0.0-20190930103706-22cd88df9f7f h1:otoFx7x89sR0tUt1bVccsTw78tk36PbVqaoyTjUZKQ4=
gioui.org v0.0.0-20190930103706-22cd88df9f7f/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
gioui.org v0.0.0-20190930145547-3784ece6dd65 h1:XDqME1BCMzxxeEQerX17EPFeJ0hkwu16Kyv1dakLadI=
gioui.org v0.0.0-20190930145547-3784ece6dd65/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+8 -8
View File
@@ -20,11 +20,11 @@ import (
_ "net/http/pprof"
"gioui.org/ui"
"gioui.org/app"
"gioui.org/gesture"
"gioui.org/key"
"gioui.org/io/key"
"gioui.org/layout"
"gioui.org/unit"
"github.com/google/go-github/v24/github"
)
@@ -41,9 +41,9 @@ type App struct {
}
var (
profile = flag.Bool("profile", false, "serve profiling data at http://localhost:6060")
stats = flag.Bool("stats", false, "show rendering statistics")
token = flag.String("token", "", "Github authentication token")
prof = flag.Bool("profile", false, "serve profiling data at http://localhost:6060")
stats = flag.Bool("stats", false, "show rendering statistics")
token = flag.String("token", "", "Github authentication token")
)
func main() {
@@ -55,8 +55,8 @@ func main() {
}
go func() {
w := app.NewWindow(
app.WithWidth(ui.Dp(400)),
app.WithHeight(ui.Dp(800)),
app.WithWidth(unit.Dp(400)),
app.WithHeight(unit.Dp(800)),
app.WithTitle("Gophers"),
)
if err := newApp(w).run(); err != nil {
@@ -67,7 +67,7 @@ func main() {
}
func initProfiling() {
if !*profile {
if !*prof {
return
}
go func() {
+3 -2
View File
@@ -7,8 +7,9 @@ import (
"testing"
"time"
"gioui.org/io/event"
"gioui.org/layout"
"gioui.org/ui"
"gioui.org/unit"
)
type queue struct{}
@@ -28,7 +29,7 @@ func BenchmarkUI(b *testing.B) {
}
}
func (queue) Events(k ui.Key) []ui.Event {
func (queue) Events(k event.Key) []event.Event {
return nil
}
+45 -44
View File
@@ -17,16 +17,17 @@ import (
_ "net/http/pprof"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/gesture"
"gioui.org/key"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/io/profile"
"gioui.org/layout"
"gioui.org/measure"
"gioui.org/paint"
"gioui.org/pointer"
"gioui.org/system"
"gioui.org/op"
"gioui.org/op/paint"
"gioui.org/text"
"gioui.org/text/shape"
"gioui.org/unit"
"gioui.org/widget"
"golang.org/x/exp/shiny/iconvg"
@@ -41,7 +42,7 @@ import (
)
type UI struct {
faces measure.Faces
faces shape.Faces
fab *ActionButton
usersList *layout.List
users []*user
@@ -52,12 +53,12 @@ type UI struct {
// Profiling.
profiling bool
profile system.ProfileEvent
profile profile.Event
lastMallocs uint64
}
type userPage struct {
faces measure.Faces
faces shape.Faces
user *user
commitsList *layout.List
commits []*github.Commit
@@ -72,7 +73,7 @@ type user struct {
type icon struct {
src []byte
size ui.Value
size unit.Value
// Cached values.
img image.Image
@@ -94,14 +95,14 @@ var fonts struct {
}
var theme struct {
text ui.MacroOp
tertText ui.MacroOp
brand ui.MacroOp
white ui.MacroOp
text op.MacroOp
tertText op.MacroOp
brand op.MacroOp
white op.MacroOp
}
func colorMaterial(ops *ui.Ops, color color.RGBA) ui.MacroOp {
var mat ui.MacroOp
func colorMaterial(ops *op.Ops, color color.RGBA) op.MacroOp {
var mat op.MacroOp
mat.Record(ops)
paint.ColorOp{Color: color}.Add(ops)
mat.Stop()
@@ -113,7 +114,7 @@ func init() {
fonts.bold = mustLoadFont(gobold.TTF)
fonts.italic = mustLoadFont(goitalic.TTF)
fonts.mono = mustLoadFont(gomono.TTF)
var ops ui.Ops
var ops op.Ops
theme.text = colorMaterial(&ops, rgb(0x333333))
theme.tertText = colorMaterial(&ops, rgb(0xbbbbbb))
theme.brand = colorMaterial(&ops, rgb(0x62798c))
@@ -129,7 +130,7 @@ func newUI(fetchCommits func(string)) *UI {
}
u.fab = &ActionButton{
face: u.face(fonts.regular, 11),
sendIco: &icon{src: icons.ContentSend, size: ui.Dp(24)},
sendIco: &icon{src: icons.ContentSend, size: unit.Dp(24)},
icons: []*icon{},
}
u.edit2 = &text.Editor{
@@ -168,7 +169,7 @@ func argb(c uint32) color.RGBA {
}
func (u *UI) face(f *sfnt.Font, size float32) text.Face {
return u.faces.For(f, ui.Sp(size))
return u.faces.For(f, unit.Sp(size))
}
func (u *UI) layoutTimings(gtx *layout.Context) {
@@ -176,17 +177,17 @@ func (u *UI) layoutTimings(gtx *layout.Context) {
return
}
for _, e := range gtx.Events(u) {
if e, ok := e.(system.ProfileEvent); ok {
if e, ok := e.(profile.Event); ok {
u.profile = e
}
}
system.ProfileOp{Key: u}.Add(gtx.Ops)
profile.Op{Key: u}.Add(gtx.Ops)
var mstats runtime.MemStats
runtime.ReadMemStats(&mstats)
mallocs := mstats.Mallocs - u.lastMallocs
u.lastMallocs = mstats.Mallocs
layout.Align(layout.NE).Layout(gtx, func() {
layout.Inset{Top: ui.Dp(16)}.Layout(gtx, func() {
layout.Inset{Top: unit.Dp(16)}.Layout(gtx, func() {
txt := fmt.Sprintf("m: %d %s", mallocs, u.profile.Timings)
text.Label{Material: theme.text, Face: u.face(fonts.mono, 10), Text: txt}.Layout(gtx)
})
@@ -234,12 +235,12 @@ func (up *userPage) Layout(gtx *layout.Context) {
func (up *userPage) commit(gtx *layout.Context, index int) {
u := up.user
msg := up.commits[index].GetMessage()
label := text.Label{Material: theme.text, Face: up.faces.For(fonts.regular, ui.Sp(12)), Text: msg}
in := layout.Inset{Top: ui.Dp(16), Right: ui.Dp(8), Left: ui.Dp(8)}
label := text.Label{Material: theme.text, Face: up.faces.For(fonts.regular, unit.Sp(12)), Text: msg}
in := layout.Inset{Top: unit.Dp(16), Right: unit.Dp(8), Left: unit.Dp(8)}
in.Layout(gtx, func() {
f := (&layout.Flex{Axis: layout.Horizontal}).Init(gtx)
c1 := f.Rigid(func() {
sz := gtx.Px(ui.Dp(48))
sz := gtx.Px(unit.Dp(48))
cc := clipCircle{}
cc.Layout(gtx, func() {
gtx.Constraints = layout.RigidConstraints(gtx.Constraints.Constrain(image.Point{X: sz, Y: sz}))
@@ -248,7 +249,7 @@ func (up *userPage) commit(gtx *layout.Context, index int) {
})
c2 := f.Flexible(1, func() {
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
layout.Inset{Left: ui.Dp(8)}.Layout(gtx, func() {
layout.Inset{Left: unit.Dp(8)}.Layout(gtx, func() {
label.Layout(gtx)
})
})
@@ -260,7 +261,7 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
st := (&layout.Stack{}).Init(gtx)
c2 := st.Rigid(func() {
layout.Align(layout.SE).Layout(gtx, func() {
in := layout.UniformInset(ui.Dp(16))
in := layout.UniformInset(unit.Dp(16))
in.Layout(gtx, func() {
u.fab.Layout(gtx)
})
@@ -272,8 +273,8 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
c1 := f.Rigid(func() {
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
layout.UniformInset(ui.Dp(16)).Layout(gtx, func() {
sz := gtx.Px(ui.Dp(200))
layout.UniformInset(unit.Dp(16)).Layout(gtx, func() {
sz := gtx.Px(unit.Dp(200))
cs := gtx.Constraints
gtx.Constraints = layout.RigidConstraints(cs.Constrain(image.Point{X: sz, Y: sz}))
u.edit.Layout(gtx)
@@ -282,7 +283,7 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
c2 := f.Rigid(func() {
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
in := layout.Inset{Bottom: ui.Dp(16), Left: ui.Dp(16), Right: ui.Dp(16)}
in := layout.Inset{Bottom: unit.Dp(16), Left: unit.Dp(16), Right: unit.Dp(16)}
in.Layout(gtx, func() {
u.edit2.Layout(gtx)
})
@@ -294,7 +295,7 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
s.Init(gtx)
c2 := s.Rigid(func() {
grey := colorMaterial(gtx.Ops, rgb(0x888888))
in := layout.Inset{Top: ui.Dp(16), Right: ui.Dp(8), Bottom: ui.Dp(8), Left: ui.Dp(8)}
in := layout.Inset{Top: unit.Dp(16), Right: unit.Dp(8), Bottom: unit.Dp(8), Left: unit.Dp(8)}
in.Layout(gtx, func() {
lbl := text.Label{Material: grey, Face: u.face(fonts.regular, 11), Text: "GOPHERS"}
lbl.Layout(gtx)
@@ -319,8 +320,8 @@ func (a *ActionButton) Layout(gtx *layout.Context) {
f := layout.Flex{Axis: layout.Vertical, Alignment: layout.End}
f.Init(gtx)
f.Layout(f.Rigid(func() {
layout.Inset{Top: ui.Dp(4)}.Layout(gtx, func() {
fab(gtx, a.sendIco.image(gtx), theme.brand, gtx.Px(ui.Dp(56)))
layout.Inset{Top: unit.Dp(4)}.Layout(gtx, func() {
fab(gtx, a.sendIco.image(gtx), theme.brand, gtx.Px(unit.Dp(56)))
pointer.EllipseAreaOp{Rect: image.Rectangle{Max: gtx.Dimensions.Size}}.Add(gtx.Ops)
})
}))
@@ -341,16 +342,16 @@ func (u *UI) user(gtx *layout.Context, index int) {
elem := layout.Flex{Axis: layout.Vertical}
elem.Init(gtx)
c1 := elem.Rigid(func() {
in := layout.UniformInset(ui.Dp(8))
in := layout.UniformInset(unit.Dp(8))
in.Layout(gtx, func() {
f := centerRowOpts()
f.Init(gtx)
c1 := f.Rigid(func() {
in := layout.Inset{Right: ui.Dp(8)}
in := layout.Inset{Right: unit.Dp(8)}
cc := clipCircle{}
in.Layout(gtx, func() {
cc.Layout(gtx, func() {
sz := image.Point{X: gtx.Px(ui.Dp(48)), Y: gtx.Px(ui.Dp(48))}
sz := image.Point{X: gtx.Px(unit.Dp(48)), Y: gtx.Px(unit.Dp(48))}
gtx.Constraints = layout.RigidConstraints(gtx.Constraints.Constrain(sz))
widget.Image{Src: user.avatar, Rect: user.avatar.Bounds()}.Layout(gtx)
})
@@ -368,7 +369,7 @@ func (u *UI) user(gtx *layout.Context, index int) {
c2 := f.Flexible(1, func() {
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
layout.Align(layout.E).Layout(gtx, func() {
layout.Inset{Left: ui.Dp(2)}.Layout(gtx, func() {
layout.Inset{Left: unit.Dp(2)}.Layout(gtx, func() {
lbl := text.Label{Material: theme.text, Face: u.face(fonts.regular, 10), Text: "3 hours ago"}
lbl.Layout(gtx)
})
@@ -377,7 +378,7 @@ func (u *UI) user(gtx *layout.Context, index int) {
f.Layout(c1, c2)
})
c2 := f.Rigid(func() {
in := layout.Inset{Top: ui.Dp(4)}
in := layout.Inset{Top: unit.Dp(4)}
in.Layout(gtx, func() {
text.Label{Material: theme.tertText, Face: u.face(fonts.regular, 12), Text: user.company}.Layout(gtx)
})
@@ -394,7 +395,7 @@ func (u *UI) user(gtx *layout.Context, index int) {
}
type fill struct {
material ui.MacroOp
material op.MacroOp
}
func (f fill) Layout(gtx *layout.Context) {
@@ -424,7 +425,7 @@ type clipCircle struct {
}
func (c *clipCircle) Layout(gtx *layout.Context, w layout.Widget) {
var m ui.MacroOp
var m op.MacroOp
m.Record(gtx.Ops)
w()
m.Stop()
@@ -435,14 +436,14 @@ func (c *clipCircle) Layout(gtx *layout.Context, w layout.Widget) {
}
szf := float32(max)
rr := szf * .5
var stack ui.StackOp
var stack op.StackOp
stack.Push(gtx.Ops)
rrect(gtx.Ops, szf, szf, rr, rr, rr, rr)
m.Add(gtx.Ops)
stack.Pop()
}
func fab(gtx *layout.Context, ico image.Image, mat ui.MacroOp, size int) {
func fab(gtx *layout.Context, ico image.Image, mat op.MacroOp, size int) {
dp := image.Point{X: (size - ico.Bounds().Dx()) / 2, Y: (size - ico.Bounds().Dy()) / 2}
dims := image.Point{X: size, Y: size}
rr := float32(size) * .5
@@ -463,7 +464,7 @@ func toRectF(r image.Rectangle) f32.Rectangle {
}
}
func (ic *icon) image(cfg ui.Config) image.Image {
func (ic *icon) image(cfg unit.Converter) image.Image {
sz := cfg.Px(ic.size)
if sz == ic.imgSize {
return ic.img
@@ -484,7 +485,7 @@ func (ic *icon) image(cfg ui.Config) image.Image {
}
// https://pomax.github.io/bezierinfo/#circles_cubic.
func rrect(ops *ui.Ops, width, height, se, sw, nw, ne float32) {
func rrect(ops *op.Ops, width, height, se, sw, nw, ne float32) {
w, h := float32(width), float32(height)
const c = 0.55228475 // 4*(sqrt(2)-1)/3
var b paint.PathBuilder
+7 -6
View File
@@ -8,12 +8,13 @@ import (
"image/color"
"log"
"gioui.org/ui"
"gioui.org/app"
"gioui.org/layout"
"gioui.org/measure"
"gioui.org/paint"
"gioui.org/op"
"gioui.org/op/paint"
"gioui.org/text"
"gioui.org/text/shape"
"gioui.org/unit"
"golang.org/x/image/font/gofont/goregular"
"golang.org/x/image/font/sfnt"
@@ -34,9 +35,9 @@ func loop(w *app.Window) error {
if err != nil {
panic("failed to load font")
}
var faces measure.Faces
var faces shape.Faces
maroon := color.RGBA{127, 0, 0, 255}
face := faces.For(regular, ui.Sp(72))
face := faces.For(regular, unit.Sp(72))
message := "Hello, Gio"
c := &layout.Context{
Queue: w.Queue(),
@@ -49,7 +50,7 @@ func loop(w *app.Window) error {
case app.UpdateEvent:
c.Reset(&e.Config, layout.RigidConstraints(e.Size))
faces.Reset(c.Config)
var material ui.MacroOp
var material op.MacroOp
material.Record(c.Ops)
paint.ColorOp{Color: maroon}.Add(c.Ops)
material.Stop()
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/cmd
go 1.13
require (
gioui.org v0.0.0-20190930103706-22cd88df9f7f
gioui.org v0.0.0-20190930145547-3784ece6dd65
github.com/chromedp/chromedp v0.4.0
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
+2 -2
View File
@@ -1,5 +1,5 @@
gioui.org v0.0.0-20190930103706-22cd88df9f7f h1:otoFx7x89sR0tUt1bVccsTw78tk36PbVqaoyTjUZKQ4=
gioui.org v0.0.0-20190930103706-22cd88df9f7f/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
gioui.org v0.0.0-20190930145547-3784ece6dd65 h1:XDqME1BCMzxxeEQerX17EPFeJ0hkwu16Kyv1dakLadI=
gioui.org v0.0.0-20190930145547-3784ece6dd65/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
github.com/chromedp/cdproto v0.0.0-20190812224334-39ef923dcb8d h1:00kLGv5nKzpFchNhGDXDRbKtYx/WoT983Ka2t8/pzRE=
github.com/chromedp/cdproto v0.0.0-20190812224334-39ef923dcb8d/go.mod h1:0YChpVzuLJC5CPr+x3xkHN6Z8KOSXjNbL7qV8Wc4GW0=
github.com/chromedp/chromedp v0.4.0 h1:0AJC5ejETuh/6n7Tcsw4u4G0eKZkI9aVRwckWaImLUE=