Open karelbilek opened 9 months ago
hmm, maybe it would be better to figure out what the gioui magic does so it can be replicated here... instead of adding the whole thing
Ah figured it out, it's actually very simple, will make a PR
gioui is great! I would not object to having an example ready to go :)
Is the additional module necessary? None of the existing examples are separate modules but afaik they don't pull their extra dependencies in for users that don't try to run the examples (eg. example/wde/
)
Hm, maybe if I rename it from example to example_test or such, it will become a test and dependents won't pull it. Otherwise I think the dependents will need to pull whole gioui with its dependencies, just for the example. (I... think)
Maybe we can just put it to a separate repo.
On Sun 18. 2. 2024 at 11:02, sqweek @.***> wrote:
gioui is great! I would not object to having an example ready to go :)
Is the additional module necessary? None of the existing examples are separate modules but afaik they don't pull their extra dependencies in for users that don't try to run the examples (eg. example/wde/)
— Reply to this email directly, view it on GitHub https://github.com/sqweek/dialog/pull/80#issuecomment-1951062930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZT4O2HVYYVOGQPAWPAYDYUHGS5AVCNFSM6AAAAABDMLIQU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJRGA3DEOJTGA . You are receiving this because you modified the open/close state.Message ID: @.***>
Look at example/wde/main.go
-- it includes these imports:
import (
"github.com/skelterjohn/go.wde" // nolint: goimports
_ "github.com/skelterjohn/go.wde/init"
)
Which are not part of dialog's go.mod
¹ and as far as I'm aware they don't get pulled in when you go get github.com/sqweek/dialog
-- can you check go.mod for your project and/or your local filesystem to see if skelterjohn/go.wde is present?
Because they are in a subdir you'd need to import (or go get
) github.com/sqweek/dialog/example/wde
for them to become relevant. ie. I'm pretty sure you can just make a new directory example/gioui/
for this code.
¹ actually dialog's go.mod
only includes Titanrain/w32
which seems wrong in the general sense because this is only a dependency on windows. Most of my experience with go was before the module system was introduced so I'm not quite sure what the correct thing to do here is
Dialog's go.mod is not really correct; if you do go mod tidy
with new go, it will get filled correctly
If you do go mod tidy
right now, you will get this in go.mod
module github.com/sqweek/dialog
go 1.22.0
require (
github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf
github.com/skelterjohn/go.wde v0.0.0-20190318181201-adc3f78cdb45
)
require (
github.com/AllenDang/w32 v0.0.0-20180428130237-ad0a36d80adc // indirect
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 // indirect
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 // indirect
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc // indirect
github.com/BurntSushi/xgbutil v0.0.0-20190907113008-ad855c713046 // indirect
)
However, you are correct that the dependents will not get it if it's just in example/. My bad.
So I will just put it in example/gioui (btw the wde example doesn't seem to work for me at all)
I put it to example/gioui in this PR (and also updated go.mod while I was at it, with go1.21.7 as it's the latest oldstable)
Haha damn, I tried to test this but:
$ go run main.go
go: errors parsing go.mod:
C:\code\go\src\github.com\sqweek\dialog\go.mod:3: invalid go version '1.21.7': must match format 1.23
I edited go.mod to read 1.21
but then:
$ go run main.go
# gioui.org/internal/debug
C:\src\go\pkg\mod\gioui.org@v0.5.0\internal\debug\debug.go:20:17: undefined: atomic.Bool
note: module requires Go 1.19
I have go 1.18 😅
If you do go mod tidy right now, you will get this in go.mod
module github.com/sqweek/dialog go 1.22.0 require ( github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf github.com/skelterjohn/go.wde v0.0.0-20190318181201-adc3f78cdb45 )
Ah ok, no that's not right either go.wde shouldn't be listed at all. Will have to look into how to do submodules properly in modern go.
For some reason, I could not run main.go on macOS from terminal. However, when I made a simple gioui gui app, it worked.
I am adding it as it's useful for quick testing and actually seeing how the dialog runs.
gioui is a simple UX framework that is multiplatform; what I like about it is you just need go with cgo to build it, the app code is just go, and there are no other steps.
(Cross-building is still not really possible, though, as it is using cgo.)
I have made example_gioui a separate module so adding dialog as a dependency doesn't grab all gioui with it, just because of the example.