apps: update gio version to use explicit text sizes

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-05 11:24:37 +02:00
parent b4a52d3010
commit 404a065a0e
4 changed files with 17 additions and 21 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/apps
go 1.13
require (
gioui.org v0.0.0-20191003113538-6dad034b2280
gioui.org v0.0.0-20191005092226-b4a52d301013
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-20191003113538-6dad034b2280 h1:a4zN/MoN6+nhPJFeBDQN/5+4H+wkypEWv76QNPChaVM=
gioui.org v0.0.0-20191003113538-6dad034b2280/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
gioui.org v0.0.0-20191005092226-b4a52d301013 h1:G4Mf6/6BEmE2j6poDpANVdWZ5+JM3wzgR55OqvVIo7k=
gioui.org v0.0.0-20191005092226-b4a52d301013/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=
+11 -15
View File
@@ -81,7 +81,6 @@ type icon struct {
}
type ActionButton struct {
face text.Face
Open bool
icons []*icon
sendIco *icon
@@ -129,12 +128,12 @@ func newUI(fetchCommits func(string)) *UI {
Axis: layout.Vertical,
}
u.fab = &ActionButton{
face: u.face(fonts.regular, 11),
sendIco: &icon{src: icons.ContentSend, size: unit.Dp(24)},
icons: []*icon{},
}
u.edit2 = &text.Editor{
Face: u.face(fonts.italic, 14),
Face: u.faces.For(fonts.italic),
Size: unit.Sp(14),
//Alignment: text.End,
SingleLine: true,
Hint: "Hint",
@@ -143,7 +142,8 @@ func newUI(fetchCommits func(string)) *UI {
}
u.edit2.SetText("Single line editor. Edit me!")
u.edit = &text.Editor{
Face: u.face(fonts.regular, 16),
Face: u.faces.For(fonts.regular),
Size: unit.Sp(16),
Material: theme.text,
//Alignment: text.End,
//SingleLine: true,
@@ -168,10 +168,6 @@ func argb(c uint32) color.RGBA {
return color.RGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)}
}
func (u *UI) face(f *sfnt.Font, size float32) text.Face {
return u.faces.For(f, unit.Sp(size))
}
func (u *UI) layoutTimings(gtx *layout.Context) {
if !u.profiling {
return
@@ -189,13 +185,13 @@ func (u *UI) layoutTimings(gtx *layout.Context) {
layout.Align(layout.NE).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)
text.Label{Material: theme.text, Face: u.faces.For(fonts.mono), Size: unit.Sp(10), Text: txt}.Layout(gtx)
})
})
}
func (u *UI) Layout(gtx *layout.Context) {
u.faces.Reset(gtx)
u.faces.Reset()
for i := range u.userClicks {
click := &u.userClicks[i]
for _, e := range click.Events(gtx) {
@@ -235,7 +231,7 @@ 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, unit.Sp(12)), Text: msg}
label := text.Label{Material: theme.text, Face: up.faces.For(fonts.regular), Size: 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)
@@ -297,7 +293,7 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
grey := colorMaterial(gtx.Ops, rgb(0x888888))
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 := text.Label{Material: grey, Face: u.faces.For(fonts.regular), Size: unit.Sp(11), Text: "GOPHERS"}
lbl.Layout(gtx)
})
})
@@ -364,13 +360,13 @@ func (u *UI) user(gtx *layout.Context, index int) {
f := baseline()
f.Init(gtx)
c1 := f.Rigid(func() {
text.Label{Material: theme.text, Face: u.face(fonts.regular, 13), Text: user.name}.Layout(gtx)
text.Label{Material: theme.text, Face: u.faces.For(fonts.regular), Size: unit.Sp(13), Text: user.name}.Layout(gtx)
})
c2 := f.Flexible(1, func() {
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
layout.Align(layout.E).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 := text.Label{Material: theme.text, Face: u.faces.For(fonts.regular), Size: unit.Sp(10), Text: "3 hours ago"}
lbl.Layout(gtx)
})
})
@@ -380,7 +376,7 @@ func (u *UI) user(gtx *layout.Context, index int) {
c2 := f.Rigid(func() {
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)
text.Label{Material: theme.tertText, Face: u.faces.For(fonts.regular), Size: unit.Sp(12), Text: user.company}.Layout(gtx)
})
})
f.Layout(c1, c2)
+3 -3
View File
@@ -37,7 +37,7 @@ func loop(w *app.Window) error {
}
var faces shape.Faces
maroon := color.RGBA{127, 0, 0, 255}
face := faces.For(regular, unit.Sp(72))
face := faces.For(regular)
message := "Hello, Gio"
gtx := &layout.Context{
Queue: w.Queue(),
@@ -49,12 +49,12 @@ func loop(w *app.Window) error {
return e.Err
case app.UpdateEvent:
gtx.Reset(&e.Config, e.Size)
faces.Reset(gtx.Config)
faces.Reset()
var material op.MacroOp
material.Record(gtx.Ops)
paint.ColorOp{Color: maroon}.Add(gtx.Ops)
material.Stop()
text.Label{Material: material, Face: face, Alignment: text.Middle, Text: message}.Layout(gtx)
text.Label{Material: material, Face: face, Size: unit.Sp(72), Alignment: text.Middle, Text: message}.Layout(gtx)
w.Update(gtx.Ops)
}
}