summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-30 11:20:23 +0200
committerxengineering <me@xengineering.eu>2023-07-30 11:20:23 +0200
commit678f263ed5d698a8af579025787f917457a39bc0 (patch)
treea6c69530b6f71644859b88df70f2f2b477a61df7
parent17301c7a8bc6a5a0663d302b061fbbdfff12e73f (diff)
downloadlimox-678f263ed5d698a8af579025787f917457a39bc0.tar
limox-678f263ed5d698a8af579025787f917457a39bc0.tar.zst
limox-678f263ed5d698a8af579025787f917457a39bc0.zip
playground: Add Gio UI hello worldroster-gui
This is a starting point to experiment with Gio list views.
-rw-r--r--playground/list.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/playground/list.go b/playground/list.go
new file mode 100644
index 0000000..5c4c213
--- /dev/null
+++ b/playground/list.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "image/color"
+ "log"
+ "os"
+
+ "gioui.org/app"
+ "gioui.org/font/gofont"
+ "gioui.org/io/system"
+ "gioui.org/layout"
+ "gioui.org/op"
+ "gioui.org/text"
+ "gioui.org/widget/material"
+)
+
+func main() {
+ go func() {
+ w := app.NewWindow()
+ err := run(w)
+ if err != nil {
+ log.Fatal(err)
+ }
+ os.Exit(0)
+ }()
+ app.Main()
+}
+
+func run(w *app.Window) error {
+ th := material.NewTheme(gofont.Collection())
+ var ops op.Ops
+ for {
+ e := <-w.Events()
+ switch e := e.(type) {
+ case system.DestroyEvent:
+ return e.Err
+ case system.FrameEvent:
+ gtx := layout.NewContext(&ops, e)
+
+ title := material.H1(th, "Hello, Gio")
+ maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
+ title.Color = maroon
+ title.Alignment = text.Middle
+ title.Layout(gtx)
+
+ e.Frame(gtx.Ops)
+ }
+ }
+}