From f4f3f9e6403ec2cb9a7f3fc59a73f4c1aa69e9fe Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 5 Apr 2019 14:59:39 +0200 Subject: [PATCH] app/hello: add explicit WindowOptions, extract message, color text Signed-off-by: Anthony Starks Signed-off-by: Elias Naur --- apps/hello/hello.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/hello/hello.go b/apps/hello/hello.go index 574e19da..89fabb0d 100644 --- a/apps/hello/hello.go +++ b/apps/hello/hello.go @@ -20,8 +20,8 @@ import ( ) func main() { - err := app.CreateWindow(nil) - if err != nil { + wopt := app.WindowOptions{Width: ui.Px(612), Height: ui.Px(792), Title: "Hello"} + if err := app.CreateWindow(&wopt); err != nil { log.Fatal(err) } app.Main() @@ -43,15 +43,16 @@ func loop(w *app.Window) { panic("failed to load font") } var faces measure.Faces - black := &image.Uniform{color.Black} - face := faces.For(regular, ui.Dp(50)) + maroon := &image.Uniform{color.RGBA{127, 0, 0, 255}} + face := faces.For(regular, ui.Sp(72)) + message := "Hello, Gio" for w.IsAlive() { e := <-w.Events() switch e := e.(type) { case app.Draw: faces.Cfg = e.Config cs := layout.ExactConstraints(w.Size()) - root, _ := (text.Label{Src: black, Face: face, Text: "Hello, World!"}).Layout(cs) + root, _ := (text.Label{Src: maroon, Face: face, Alignment: text.Center, Text: message}).Layout(cs) w.Draw(root) faces.Frame() }