mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
3a27bcea2e
Signed-off-by: Elias Naur <mail@eliasnaur.com>
50 lines
849 B
Go
50 lines
849 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package main
|
|
|
|
// A simple Gio program. See https://gioui.org for more information.
|
|
|
|
import (
|
|
"image/color"
|
|
"log"
|
|
|
|
"gioui.org/app"
|
|
"gioui.org/io/system"
|
|
_ "gioui.org/font/gofont"
|
|
"gioui.org/layout"
|
|
"gioui.org/text"
|
|
"gioui.org/widget/material"
|
|
)
|
|
|
|
func main() {
|
|
go func() {
|
|
w := app.NewWindow()
|
|
if err := loop(w); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}()
|
|
app.Main()
|
|
}
|
|
|
|
func loop(w *app.Window) error {
|
|
th := material.NewTheme()
|
|
gtx := &layout.Context{
|
|
Queue: w.Queue(),
|
|
}
|
|
for {
|
|
e := <-w.Events()
|
|
switch e := e.(type) {
|
|
case system.DestroyEvent:
|
|
return e.Err
|
|
case system.FrameEvent:
|
|
gtx.Reset(e.Config, e.Size)
|
|
l := th.H1("Hello, Gio")
|
|
maroon := color.RGBA{127, 0, 0, 255}
|
|
l.Color = maroon
|
|
l.Alignment = text.Middle
|
|
l.Layout(gtx)
|
|
e.Frame(gtx.Ops)
|
|
}
|
|
}
|
|
}
|