From 8e307b40a6f4989545089eba10a72c4342d86fb4 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 12 Jul 2019 20:04:02 +0200 Subject: [PATCH] apps: update to new NewWindow API Signed-off-by: Elias Naur --- apps/go.mod | 2 +- apps/gophers/main.go | 25 ++++++++++--------------- apps/hello/hello.go | 18 +++++++----------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/apps/go.mod b/apps/go.mod index 6e388e7c..ac66e13d 100644 --- a/apps/go.mod +++ b/apps/go.mod @@ -3,7 +3,7 @@ module gioui.org/apps go 1.12 require ( - gioui.org/ui v0.0.0-20190712135441-2296393471ae + gioui.org/ui v0.0.0-20190712184729-a3b9c7818fa7 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 diff --git a/apps/gophers/main.go b/apps/gophers/main.go index b8b9bc3d..4332c3d7 100644 --- a/apps/gophers/main.go +++ b/apps/gophers/main.go @@ -137,14 +137,6 @@ func main() { fmt.Println("The quota for anonymous GitHub API access is very low. Specify a token with -token to avoid quota errors.") fmt.Println("See https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line.") } - err := app.CreateWindow(&app.WindowOptions{ - Width: ui.Dp(400), - Height: ui.Dp(800), - Title: "Gophers", - }) - if err != nil { - log.Fatal(err) - } app.Main() } @@ -169,14 +161,17 @@ func init() { theme.tertText = colorMaterial(&ops, rgb(0xbbbbbb)) theme.brand = colorMaterial(&ops, rgb(0x62798c)) theme.white = colorMaterial(&ops, rgb(0xffffff)) + w, err := app.NewWindow(&app.WindowOptions{ + Width: ui.Dp(400), + Height: ui.Dp(800), + Title: "Gophers", + }) + if err != nil { + log.Fatal(err) + } go func() { - for w := range app.Windows() { - w := w - go func() { - if err := newApp(w).run(); err != nil { - log.Fatal(err) - } - }() + if err := newApp(w).run(); err != nil { + log.Fatal(err) } }() } diff --git a/apps/hello/hello.go b/apps/hello/hello.go index 1aa9b417..571b99eb 100644 --- a/apps/hello/hello.go +++ b/apps/hello/hello.go @@ -20,24 +20,20 @@ import ( ) func main() { - 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() } // On iOS and Android main will never be called, so // setting up the window must run in an init function. func init() { + wopt := app.WindowOptions{Width: ui.Dp(800), Height: ui.Dp(600), Title: "Hello"} + w, err := app.NewWindow(&wopt) + if err != nil { + log.Fatal(err) + } go func() { - for w := range app.Windows() { - w := w - go func() { - if err := loop(w); err != nil { - log.Fatal(err) - } - }() + if err := loop(w); err != nil { + log.Fatal(err) } }() }