Skip to content

Instantly share code, notes, and snippets.

@inkeliz

inkeliz/go.mod Secret

Created July 11, 2023 13:41
Show Gist options
  • Save inkeliz/11c071ec4bf8f922a3cb48fd0cbb3b95 to your computer and use it in GitHub Desktop.
Save inkeliz/11c071ec4bf8f922a3cb48fd0cbb3b95 to your computer and use it in GitHub Desktop.
module demo
go 1.19
replace gioui.org => ../gio
replace gioui.org/cmd => ../../gio-cmd
require gioui.org v0.0.0-20230429160049-0e5ec18a82e9
require (
gioui.org/cmd v0.0.0-20230701070152-940364d3e94a // indirect
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect
gioui.org/shader v1.0.6 // indirect
github.com/akavel/rsrc v0.10.1 // indirect
github.com/go-text/typesetting v0.0.0-20230602202114-9797aefac433 // indirect
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect
golang.org/x/exp/shiny v0.0.0-20220921164117-439092de6870 // indirect
golang.org/x/image v0.5.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.6.0 // indirect
)
package main
import (
"gioui.org/app"
"gioui.org/font"
"gioui.org/font/gofont"
"gioui.org/io/deeplink"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
"gioui.org/text"
"gioui.org/widget"
"image"
"image/color"
"os"
)
func main() {
w := app.NewWindow()
lt := text.NewShaper(gofont.Collection())
var texts = []string{"Schemes:"}
ops := new(op.Ops)
go func() {
for e := range w.Events() {
switch e := e.(type) {
case deeplink.Event:
if e.URL != nil {
texts = append(texts, e.URL.String())
}
w.Invalidate()
case system.DestroyEvent:
os.Exit(0)
return
case system.FrameEvent:
gtx := layout.NewContext(ops, e)
_ = gtx
s := clip.RRect{Rect: image.Rectangle{Max: gtx.Constraints.Max}}.Push(gtx.Ops)
paint.ColorOp{Color: color.NRGBA{R: 255, G: 255, A: 255}}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
s.Pop()
offset := image.Pt(0, 0)
p := op.Record(gtx.Ops)
paint.ColorOp{Color: color.NRGBA{A: 255}}.Add(gtx.Ops)
painter := p.Stop()
for _, txt := range texts {
gtx.Constraints.Min.Y = 0
gtx.Constraints.Min.X = 0
o := op.Offset(offset).Push(gtx.Ops)
dims := widget.Label{}.Layout(gtx, lt, font.Font{}, 16, txt, painter)
o.Pop()
offset.Y += dims.Size.Y
}
e.Frame(ops)
}
}
}()
app.Main()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment