package main import ( "git.wow.st/gmp/giowrap" "image/color" "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("text 1") e1.Focus() e2 := giowrap.NewEditor(ctx.Faces.For(regular, ui.Sp(24)), true) e2.SetText("text 2") 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.NewLabel( ctx.Faces.For(regular, ui.Sp(24)), "push", text.Center, ) bg := giowrap.NewBackground(color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6}, ui.Dp(4)) btn := giowrap.Clickable(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 = ctx.Reset(e) ctx = OuterInset( f( e1, giowrap.Flexible(5), InnerInset(e2), giowrap.Flexible(10), btn, )).Layout(ctx) ctx.Draw() if btn.Clicked(ctx) { log.Print("Clicked: " + e2.Text() ) } } } } }() app.Main() }