-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
511 changed files
with
211 additions
and
181,893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
module github.com/esimov/diagram | ||
|
||
go 1.22 | ||
|
||
require ( | ||
gioui.org v0.7.0 | ||
github.com/fogleman/gg v1.0.1-0.20180308184255-c97f757e6f0e | ||
github.com/go-gl/gl v0.0.0-20180304232605-eafa86a81d97 | ||
github.com/go-gl/glfw v0.0.0-20170814180746-513e4f2bf85c | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 | ||
github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4 | ||
github.com/gopherjs/gopherjs v0.0.0-20180314020201-768621c88e58 | ||
github.com/goxjs/gl v0.0.0-20171128034433-dc8f4a9a3c9c | ||
github.com/goxjs/glfw v0.0.0-20171018044755-7dec05603e06 | ||
github.com/jroimartin/gocui v0.3.1-0.20170827195011-4f518eddb04b | ||
github.com/mattn/go-runewidth v0.0.3-0.20180304235428-a9d6d1e4dc51 | ||
github.com/nsf/termbox-go v0.0.0-20180303152453-e2050e41c884 | ||
golang.org/x/image v0.0.0-20180314180248-f3a9b89b59de | ||
honnef.co/go/js/dom v0.0.0-20180307180539-662b7b8f3412 | ||
) | ||
|
||
go 1.13 | ||
|
||
replace github.com/google/gxui => ./vendor/github.com/google/gxui/ | ||
require ( | ||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 // indirect | ||
gioui.org/shader v1.0.8 // indirect | ||
github.com/go-text/typesetting v0.1.1 // indirect | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect | ||
github.com/mattn/go-runewidth v0.0.3-0.20180304235428-a9d6d1e4dc51 // indirect | ||
github.com/nsf/termbox-go v0.0.0-20180303152453-e2050e41c884 // indirect | ||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect | ||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 // indirect | ||
golang.org/x/image v0.5.0 // indirect | ||
golang.org/x/sys v0.5.0 // indirect | ||
golang.org/x/text v0.9.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,57 @@ | ||
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY= | ||
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA= | ||
gioui.org v0.7.0 h1:5I+7Uu2yjTu7W5p7HWQrgsDPO3vex+8T1DsvCLGBfuI= | ||
gioui.org v0.7.0/go.mod h1:19wZxaNP+eHN4H2YdZwEfbkAAgoYB5rcIbDHo4BqUl4= | ||
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= | ||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc= | ||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= | ||
gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA= | ||
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= | ||
github.com/fogleman/gg v1.0.1-0.20180308184255-c97f757e6f0e h1:Uxa5iXmaagOoIOkp9/OjjfFfSljeMMImZsOyfycUTQE= | ||
github.com/fogleman/gg v1.0.1-0.20180308184255-c97f757e6f0e/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= | ||
github.com/go-gl/gl v0.0.0-20180304232605-eafa86a81d97 h1:On2uwhieavUE0HwIBON6O04M9nxOA7swLzkj2RtUkpU= | ||
github.com/go-gl/gl v0.0.0-20180304232605-eafa86a81d97/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= | ||
github.com/go-gl/glfw v0.0.0-20170814180746-513e4f2bf85c h1:1zCo3Fa2xy/b0b4A3U9M000k1V3JPJhLaCki4eaLfhQ= | ||
github.com/go-gl/glfw v0.0.0-20170814180746-513e4f2bf85c/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= | ||
github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo= | ||
github.com/go-text/typesetting v0.1.1/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI= | ||
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY= | ||
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o= | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= | ||
github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4 h1:OL2d27ueTKnlQJoqLW2fc9pWYulFnJYLWzomGV7HqZo= | ||
github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4/go.mod h1:Pw1H1OjSNHiqeuxAduB1BKYXIwFtsyrY47nEqSgEiCM= | ||
github.com/gopherjs/gopherjs v0.0.0-20180314020201-768621c88e58/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | ||
github.com/goxjs/gl v0.0.0-20171128034433-dc8f4a9a3c9c h1:naEGFd9BJuTM/1m2lP07Bl9O7O6Jqe+bUplBfAwdygg= | ||
github.com/goxjs/gl v0.0.0-20171128034433-dc8f4a9a3c9c/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY= | ||
github.com/goxjs/glfw v0.0.0-20171018044755-7dec05603e06 h1:6jKIS84Kj8pXaqte+73xLvaT+OGt0+fs+TbFczltZP0= | ||
github.com/goxjs/glfw v0.0.0-20171018044755-7dec05603e06/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY= | ||
github.com/jroimartin/gocui v0.3.1-0.20170827195011-4f518eddb04b h1:oXDIgfbS+8ScemPBkP9aedVduRryQvoz6U7mlfh4zhs= | ||
github.com/jroimartin/gocui v0.3.1-0.20170827195011-4f518eddb04b/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY= | ||
github.com/mattn/go-runewidth v0.0.3-0.20180304235428-a9d6d1e4dc51 h1:73DyaxlfqHF9FQireGHkut6r7OuuA0jTVjS9N0vwktI= | ||
github.com/mattn/go-runewidth v0.0.3-0.20180304235428-a9d6d1e4dc51/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= | ||
github.com/nsf/termbox-go v0.0.0-20180303152453-e2050e41c884 h1:fcs71SMqqDhUD+PbpIv9xf3EH9F9s6HfiLwr6jKm1VA= | ||
github.com/nsf/termbox-go v0.0.0-20180303152453-e2050e41c884/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= | ||
golang.org/x/image v0.0.0-20180314180248-f3a9b89b59de h1:moc8EjTGZXlnKJcoDZDWCDV1Vn3Zt/MZDpIRmIs7qt0= | ||
golang.org/x/image v0.0.0-20180314180248-f3a9b89b59de/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= | ||
honnef.co/go/js/dom v0.0.0-20180307180539-662b7b8f3412/go.mod h1:sUMDUKNB2ZcVjt92UnLy3cdGs+wDAcrPdV3JP6sVgA4= | ||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 h1:sBdrWpxhGDdTAYNqbgBLAR+ULAPPhfgncLr1X0lyWtg= | ||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= | ||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 h1:ryT6Nf0R83ZgD8WnFFdfI8wCeyqgdXWN4+CkFVNPAT0= | ||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8= | ||
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI= | ||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4= | ||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= | ||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= | ||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= | ||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package gui | ||
|
||
import ( | ||
"fmt" | ||
"image" | ||
"image/color" | ||
|
||
"gioui.org/app" | ||
"gioui.org/io/key" | ||
"gioui.org/layout" | ||
"gioui.org/op" | ||
"gioui.org/op/clip" | ||
"gioui.org/op/paint" | ||
"gioui.org/unit" | ||
"gioui.org/widget" | ||
) | ||
|
||
type GUI struct { | ||
image paint.ImageOp | ||
title string | ||
} | ||
|
||
func NewGUI(img image.Image, title string) *GUI { | ||
return &GUI{ | ||
image: paint.NewImageOp(img), | ||
title: title, | ||
} | ||
} | ||
|
||
func (ui *GUI) Draw() error { | ||
w := new(app.Window) | ||
w.Option(app.Size( | ||
unit.Dp(ui.image.Size().X), | ||
unit.Dp(ui.image.Size().Y), | ||
), app.Title(ui.title)) | ||
|
||
if err := ui.Run(w); err != nil { | ||
return fmt.Errorf("GUI rendering error: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (ui *GUI) Run(w *app.Window) error { | ||
var ops op.Ops | ||
|
||
for { | ||
switch e := w.Event().(type) { | ||
case app.FrameEvent: | ||
gtx := app.NewContext(&ops, e) | ||
ui.drawDiagram(gtx) | ||
|
||
e.Frame(gtx.Ops) | ||
case app.DestroyEvent: | ||
return e.Err | ||
case key.Event: | ||
switch e.Name { | ||
case key.NameEscape: | ||
return nil | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (ui *GUI) drawDiagram(gtx layout.Context) { | ||
layout.Stack{}.Layout(gtx, | ||
layout.Stacked(func(gtx layout.Context) layout.Dimensions { | ||
paint.FillShape(gtx.Ops, color.NRGBA{R: 0xFF, G: 0xFF, B: 0xFF, A: 0xff}, | ||
clip.Rect{Max: gtx.Constraints.Max}.Op(), | ||
) | ||
|
||
return layout.UniformInset(unit.Dp(0)).Layout(gtx, | ||
func(gtx layout.Context) layout.Dimensions { | ||
widget.Image{ | ||
Src: ui.image, | ||
Scale: 1 / float32(unit.Dp(1)), | ||
Fit: widget.Contain, | ||
}.Layout(gtx) | ||
|
||
return layout.Dimensions{Size: gtx.Constraints.Max} | ||
}) | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.