package main import ( "git.wow.st/gmp/giowrap" "log" "time" "gioui.org/ui" "gioui.org/ui/app" "gioui.org/ui/layout" "gioui.org/ui/text" "golang.org/x/image/font/sfnt" "golang.org/x/image/font/gofont/goregular" ) func main() { go func() { w := app.NewWindow(nil) regular, err := sfnt.Parse(goregular.TTF) if err != nil { log.Fatal("Cannot parse font.") } ctx := giowrap.NewContext(w) t := time.NewTicker(time.Second/30) e1 := giowrap.NewEditor(ctx.Faces.For(regular, ui.Sp(24)), true) e1.SetText("hi there") e1.Focus() e2 := giowrap.NewEditor(ctx.Faces.For(regular, ui.Sp(24)), true) e2.SetText("ok bye") f := giowrap.NewFlex(layout.Vertical, layout.Start, layout.Start) OuterInset := giowrap.NewInset(ui.Dp(10),ui.Dp(10),ui.Dp(10),ui.Dp(10)) InnerInset := giowrap.NewInset(ui.Dp(10),ui.Dp(10),ui.Dp(10),ui.Dp(10)) lbl := giowrap.NewButton( ctx.Faces.For(regular, ui.Sp(24)), "centered", text.Center, ) bg := giowrap.NewBackground(giowrap.Rgb(0x3c98c6), ui.Dp(4)) btn := bg(lbl) for { select { case <-t.C: w.Invalidate() case e := <-w.Events(): switch e := e.(type) { case app.DestroyEvent: return case app.DrawEvent: ctx.Reset(e) ctx = giowrap.LayoutWithContext(ctx, OuterInset( f( e1, giowrap.Flexible(5), InnerInset(e2), giowrap.Flexible(10), btn, ))) ctx.Draw() if lbl.Clicked(ctx) { log.Print("Clicked: " + e2.Text() ) } } } } }() app.Main() }