mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
apps/hello: update to explicit API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-3
@@ -5,12 +5,12 @@ package main
|
|||||||
// A simple Gio program. See https://gioui.org for more information.
|
// A simple Gio program. See https://gioui.org for more information.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
|
||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"gioui.org/ui"
|
"gioui.org/ui"
|
||||||
"gioui.org/ui/app"
|
"gioui.org/ui/app"
|
||||||
|
"gioui.org/ui/draw"
|
||||||
"gioui.org/ui/layout"
|
"gioui.org/ui/layout"
|
||||||
"gioui.org/ui/measure"
|
"gioui.org/ui/measure"
|
||||||
"gioui.org/ui/text"
|
"gioui.org/ui/text"
|
||||||
@@ -43,7 +43,7 @@ func loop(w *app.Window) {
|
|||||||
panic("failed to load font")
|
panic("failed to load font")
|
||||||
}
|
}
|
||||||
var faces measure.Faces
|
var faces measure.Faces
|
||||||
maroon := &image.Uniform{color.RGBA{127, 0, 0, 255}}
|
maroon := color.NRGBA{127, 0, 0, 255}
|
||||||
face := faces.For(regular, ui.Sp(72))
|
face := faces.For(regular, ui.Sp(72))
|
||||||
message := "Hello, Gio"
|
message := "Hello, Gio"
|
||||||
ops := new(ui.Ops)
|
ops := new(ui.Ops)
|
||||||
@@ -54,7 +54,8 @@ func loop(w *app.Window) {
|
|||||||
faces.Cfg = e.Config
|
faces.Cfg = e.Config
|
||||||
cs := layout.ExactConstraints(w.Size())
|
cs := layout.ExactConstraints(w.Size())
|
||||||
ops.Reset()
|
ops.Reset()
|
||||||
(text.Label{Src: maroon, Face: face, Alignment: text.Center, Text: message}).W(ops, cs)
|
draw.OpColor{Col: maroon}.Add(ops)
|
||||||
|
text.Label{Face: face, Alignment: text.Center, Text: message}.Layout(ops, cs)
|
||||||
w.Draw(ops)
|
w.Draw(ops)
|
||||||
faces.Frame()
|
faces.Frame()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user