AllenDang/giu, giu Cross platform rapid GUI framework for golang based on Dear ImGui and the great golang binding imgui-go.
Actualmiddlewares
Argo
Audio&Music
Authentication&OAuth
Benchmarks
MoreCategories
BotBuilding
BuildTools
Caching
CloudComputing
CodeAnalysis
CommandLine
Command-lineOptionParsers
Compiler
Compression
Configuration
ConsoleUserInterface
ContinuousIntegration
Cryptography
DataProcessing
DataStructures
DataVisualization
Database
DatabaseDrivers
Databaseschemamigration.
Databasetools
DateandTime
DependencyInjection
DevelopmentTools
DevOpsTools
DistributedSystems
Editor
Email
EmbeddableScriptingLanguages
EncodingsandCharacterSets
ErrorHandling
FileHandling
FileSystem
Financial
Forms
FrameworksandToolkits
GameDevelopment
GIS
Git
Goroutines
GUIsandWidgetToolkits
HTTPClients
HTTPmiddlewares
Imagestools
InstantMessaging
IoT(InternetofThings)
JobScheduler
JSON
Key-ValueStore
LanguageandLinguistics
LearningTutorial
Librariesforvalidation
LoggingandMonitoring
MachineLearning
Mathematics
Messaging
Microservices
MicrosoftExcel
Miscellaneous
NaturalLanguageProcessing
Network
NetworkingDNS
ORM
P2PandFileSharing
PackageManagement
Performance
ProjectLayout
PublicAPIWrappers
QueryLanguage
ResourceEmbedding
Routers
ScienceandDataAnalysis
Security
Serialization
ServerApplications
SourceCodeManagement
SQLQueryBuilder
StorageServer
TemplateEngines
TestingFrameworks
TextProcessing
Utilities
UUIDLibraries
Video
VirtualMachinesandLanguages
WebApplications
WebCrawling
WebFrameworks
WebAssembly
Websockets
XMLLibraries
PopularRepo
LatestRepo
Resources
All
Article
News
Book
Tutorial
Overview
Issues
8
Releases
v0.5.6
MITLicense
Star1.1k
Watch26
Fork72
CrossplatformrapidGUIframeworkforgolangbasedonDearImGui.
AllenDang
Lastupdate:Dec8,2021
Relatedtags
GUIsandWidgetToolkits
golang
gui
ui
cross-platform
uikit
imgui
dear-imgui
Overview
giu
CrossplatformrapidGUIframeworkforgolangbasedonDearImGuiandthegreatgolangbindingimgui-go.
Anycontribution(features,widgets,tutorials,documentsandetc...)isappreciated!
SupportedPlatforms
giuisbuiltuponGLFWv3.3,soidealygiucouldsupportallplatformsthatGLFWv3.3supports.
Windows(onlytestedonWindows10x64)
MacOS(onlytestedonMacOSv10.15)
Linux(thanksremehtotestit)
Raspberrypi3b(thankssndvapstotestit)
Features
ComparetootherDearImGuigolangbindings,giuhasfollowingfeatures:
Smallexecutablefilesize(<3mbafterupxcompressionfortheexample/helloworlddemo).
Live-updateduringtheresizingofOSwindow(implementedonGLFW3.3andOpenGL3.2).
Redrawonlywhenusereventoccurred.Costsonly0.5%CPUusagewith60FPS.
DeclarativeUI(seeexamplesformoredetail).
DPIawareness(autoscalefontandUItoadaptehighDPImonitor).
Dropinusage,noneedtoimplementrenderandplatform.
OSclipboardsupport.
Helloworld
packagemain
import(
"fmt"
g"github.com/AllenDang/giu"
)
funconClickMe(){
fmt.Println("Helloworld!")
}
funconImSoCute(){
fmt.Println("Imsooooooocute!!")
}
funcloop(){
g.SingleWindow("helloworld").Layout(
g.Label("Helloworldfromgiu"),
g.Line(
g.Button("ClickMe").OnClick(onClickMe),
g.Button("I'msocute").OnClick(onImSoCute),
),
)
}
funcmain(){
wnd:=g.NewMasterWindow("Helloworld",400,200,g.MasterWindowFlagsNotResizable,nil)
wnd.Run(loop)
}
Hereisresult.
Install
ThebackendofgiudependsonOpenGL3.3,makesureyourenvironmentsupportsit(sofarasIknownsomeVirualMachinelikeVirualBoxdoesn'tsupportit).
MacOS
xcode-select--install
gogetgithub.com/AllenDang/[email protected]
Windows
Installmingwdownloadhere.Thanks@alchem1ster!
Addthebinariesfolderofmingwtothepath(usuallyis\mingw64\bin).
gogetgithub.com/AllenDang/[email protected]
Linux
NeedhelpherecauseIdon'thaveanylinuxexperience.
Deploy
BuildMacOSversiononMacOS.
gobuild-ldflags"-s-w".
BuildWindowsversiononWindows.
gobuild-ldflags"-s-w-H=windowsgui-extldflags=-static".
BuildWindowsversiononMacOS.
Installmingw-64.
brewinstallmingw-w64
Prepareandembedapplicationicontoexecutableandbuild.
cat>YourExeName.rc<Fonts[0]->IsLoaded()&&"FontAtlasnotbuilt.Didyoucallio.Fonts->GetTexDataAsRGBA32()/GetTexDataAsAlpha8()?"'failed.
SIGABRT:abort
PC=0x7f31fc71b9e5m=0sigcode=18446744073709551610
signalarrivedduringcgoexecution
goroutine1[syscall,lockedtothread]:
runtime.cgocall(0x634e60,0xc00011fda0,0x4000)
/usr/local/go/src/runtime/cgocall.go:154+0x5bfp=0xc00011fd70sp=0xc00011fd38pc=0x48673b
github.com/AllenDang/imgui-go._Cfunc_iggNewFrame()
_cgo_gotypes.go:4742+0x3cfp=0xc00011fda0sp=0xc00011fd70pc=0x57d1dc
github.com/AllenDang/imgui-go.NewFrame(...)
/home/username/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui.go:30
github.com/AllenDang/giu.(*MasterWindow).render(0xc00031a000)
/run/media/username/SALATKA/mystuff/test/giu/MasterWindow.go:182+0x9bfp=0xc00011fe10sp=0xc00011fda0pc=0x62505b
github.com/AllenDang/giu.(*MasterWindow).run.func1()
/run/media/username/SALATKA/mystuff/test/giu/MasterWindow.go:201+0x59fp=0xc00011fe50sp=0xc00011fe10pc=0x629eb9
github.com/faiface/mainthread.Call.func1()
/home/username/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:63+0x2ffp=0xc00011fe80sp=0xc00011fe50pc=0x58b48f
github.com/faiface/mainthread.Run(0xc0003184e0)
/home/username/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:44+0xb1fp=0xc00011ff08sp=0xc00011fe80pc=0x58b211
github.com/AllenDang/giu.(*MasterWindow).Run(0xc00031a000,0x8dcd58)
/run/media/username/SALATKA/mystuff/test/giu/MasterWindow.go:258+0x65fp=0xc00011ff28sp=0xc00011ff08pc=0x625305
main.main()
/run/media/username/SALATKA/mystuff/test/giu/examples/widgets/widgets.go:211+0x18ffp=0xc00011ff88sp=0xc00011ff28pc=0x63196f
runtime.main()
/usr/local/go/src/runtime/proc.go:225+0x256fp=0xc00011ffe0sp=0xc00011ff88pc=0x4bb4f6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1371+0x1fp=0xc00011ffe8sp=0xc00011ffe0pc=0x4ed101
goroutine18[chanreceive]:
github.com/faiface/mainthread.Call(0xc000240ba0)
/home/username/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:66+0xc5
github.com/AllenDang/giu.(*MasterWindow).run(0xc00031a000)
/run/media/username/SALATKA/mystuff/test/giu/MasterWindow.go:199+0xa5
github.com/AllenDang/giu.(*MasterWindow).Run.func1()
/run/media/username/SALATKA/mystuff/test/giu/MasterWindow.go:263+0x4d
github.com/faiface/mainthread.Run.func1(0xc0003184e0,0xc000320000)
/home/username/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:37+0x27
createdbygithub.com/faiface/mainthread.Run
/home/username/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:36+0xa5
rax0x0
rbx0x7f31fc593740
rcx0x7f31fc71b9e5
rdx0x0
rdi0x2
rsi0x7ffd630b7c70
rbp0x7f31fc871680
rsp0x7ffd630b7c70
r80x0
r90x7ffd630b7c70
r100x8
r110x246
r120x91a372
r130x1c18
r140x91e618
r150xffffffffffffffff
rip0x7f31fc71b9e5
rflags0x246
cs0x33
fs0x0
gs0x0
exitstatus2
I'mrunningexamples/widgets.
mysystem:
OS:Fedora33
desktop:gnome-shell3.38.4
openedbygucio32119
examples/dynamicloadfont:examplecrashes
Hi!
Iwantedtorunexamples/dynmiacloadfont butitpanics:
dynamicloadfont:imgui.cpp:7112:voidImGui::ErrorCheckNewFrameSanityChecks():Assertion`g.IO.Fonts->Fonts[0]->IsLoaded()&&"FontAtlasnotbuilt.Didyoucallio.Fonts->GetTexDataAsRGBA32()/GetTexDataAsAlpha8()?"'failed.
SIGABRT:abort
PC=0x7f43aff019d5m=0sigcode=18446744073709551610
signalarrivedduringcgoexecution
goroutine1[syscall,lockedtothread]:
runtime.cgocall(0x6131f0,0xc0000cddb8,0x4000)
/usr/local/go/src/runtime/cgocall.go:154+0x5bfp=0xc0000cdd88sp=0xc0000cdd50pc=0x48567b
github.com/AllenDang/imgui-go._Cfunc_iggNewFrame()
_cgo_gotypes.go:4546+0x3cfp=0xc0000cddb8sp=0xc0000cdd88pc=0x571d5c
github.com/AllenDang/imgui-go.NewFrame(...)
/home/user/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui.go:28
github.com/AllenDang/giu.(*MasterWindow).render(0xc000186000)
/home/user/git/d2/me/giu/MasterWindow.go:174+0x96fp=0xc0000cde28sp=0xc0000cddb8pc=0x60faf6
github.com/AllenDang/giu.(*MasterWindow).run.func1()
/home/user/git/d2/me/giu/MasterWindow.go:193+0x59fp=0xc0000cde68sp=0xc0000cde28pc=0x610219
github.com/faiface/mainthread.Call.func1()
/home/user/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:63+0x2ffp=0xc0000cde98sp=0xc0000cde68pc=0x57804f
github.com/faiface/mainthread.Run(0xc00000e4c8)
/home/user/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:44+0xb1fp=0xc0000cdf20sp=0xc0000cde98pc=0x577dd1
github.com/AllenDang/giu.(*MasterWindow).Run(0xc000186000,0x8aca58)
/home/user/git/d2/me/giu/MasterWindow.go:250+0x65fp=0xc0000cdf40sp=0xc0000cdf20pc=0x60fda5
main.main()
/home/user/git/d2/me/giu/examples/dynmiacloadfont/dynamicloadfont.go:34+0x73fp=0xc0000cdf88sp=0xc0000cdf40pc=0x6108f3
runtime.main()
/usr/local/go/src/runtime/proc.go:225+0x256fp=0xc0000cdfe0sp=0xc0000cdf88pc=0x4ba0f6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1371+0x1fp=0xc0000cdfe8sp=0xc0000cdfe0pc=0x4ebb81
goroutine5[chanreceive]:
github.com/faiface/mainthread.Call(0xc00009af60)
/home/user/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:66+0xc5
github.com/AllenDang/giu.(*MasterWindow).run(0xc000186000)
/home/user/git/d2/me/giu/MasterWindow.go:191+0xa5
github.com/AllenDang/giu.(*MasterWindow).Run.func1()
/home/user/git/d2/me/giu/MasterWindow.go:255+0x4d
github.com/faiface/mainthread.Run.func1(0xc00000e4c8,0xc000024120)
/home/user/go/pkg/mod/github.com/faiface/[email protected]3/mainthread.go:37+0x27
createdbygithub.com/faiface/mainthread.Run
/home/user/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:36+0xa5
rax0x0
rbx0x7f43afd79740
rcx0x7f43aff019d5
rdx0x0
rdi0x2
rsi0x7fff653957b0
rbp0x7f43b0057680
rsp0x7fff653957b0
r80x0
r90x7fff653957b0
r100x8
r110x246
r120x8e48b2
r130x1bc8
r140x8e8978
r150xffffffffffffffff
rip0x7f43aff019d5
rflags0x246
cs0x33
fs0x0
gs0x0
exitstatus2
openedbygucio32119
DPIscale-unexpectedbehavior
Thiscommithttps://github.com/AllenDang/giu/commit/27ecca73d762cacc8bdd23e12dd18c07b76623ab
breaksUIrenderingonhighmonitorresolution.
Before:
After:
openedbyaleksandrzhiliaev17
Removeimgui-go,implot,imnodes,ImGuiColorTextEditfromrepo
@AllenDangwhatareyourthoughtsonmergingthesechangesupstream?
Iremovedallofthehardcopiesofthedependenciesinfavorofimportingthemviaaforkofimgui-go:https://github.com/ianling/imgui-go--thisforkisup-to-datewiththeupstreamimgui-gorepoasofyesterday,andalsohasallofthechangesyou'vemadeinthegiurepo.
Ifyouareinterestedinchangingtothisstyle,wecouldmergethisPRandIcantransfertheforkianling/imgui-gotoyouraccount.AllinstancesofianlingwouldalsoneedtobechangedbacktoAllenDang
Ithinkthemainbenefitsofmakingthischangeare:
reducesclutterbyhavingaclearseparationbetweenthelow-levelCGowrappersinimgui-go/implot/imnodes/ImGuiColorTextEditandthecleanhigh-levelAPIprovidedbygiu
easiertomaintain.Ifyouneedtomakecustomchangestoimgui-go(oroneoftheotherC++libraries),yousimplycommitthechangeintheforkandimportthenewcommitingiu.Iftheofficialimgui-goreporeleasesanupdate,orImGuiitselfreceivesanupdate,itisverysimpletoupdatethisfork.
youcanalsoupdatetheimgui-goforkseparatelyfromgiu,andcontinuebuildinggiufromthepreviouscommitiftherearebreakingchangesandyoudon'thavetimetoupdatebothreposatonce.
openedbyianling15
[Windows]gogetgithub.com/AllenDang/giufails
Notsurewhattherequirementsare,justfollowingalongwiththeREADME.
Error:
#github.com/AllenDang/giu/imgui
C:\Users\#####\AppData\Local\Temp\go-build3633627171\b001\_x039.o:Infunction`ImeSetInputScreenPosFn_DefaultImpl':
..\..\..\go\pkg\mod\github.com\!allen!dang\[email protected]\imgui/imgui.cpp:10724:undefinedreferenceto`ImmGetContext'
..\..\..\go\pkg\mod\github.com\!allen!dang\[email protected]\imgui/imgui.cpp:10730:undefinedreferenceto`ImmSetCompositionWindow'
..\..\..\go\pkg\mod\github.com\!allen!dang\[email protected]\imgui/imgui.cpp:10731:undefinedreferenceto`ImmReleaseContext'
collect2.exe:error:ldreturned1exitstatus
openedbybartimus-primed15
testpullrequests
@allenDangwhataboutagithubworkflow,whichwillcheckifprojectisabletobuild?
oryoucanaddbranchprotectionruletomasterwithRequireteststatusfromtravisCItopreventunbuildablePRtobemerged.
Originallypostedby@gucio321inhttps://github.com/AllenDang/giu/issues/314#issuecomment-912970533
openedbygucio32115
Raceconditionbetweentexturecreationanddeletion(viafinalizer)
Texturecreationcanrandomlyfailifanothertexturehappenstobefinalizinginthebackground.
Thisiscausingdeadlocksinourproject.
~~ThedeadlockishappeningbetweenTexture.releaseandNewTextureFromRgba.~~readbelow
openedbygravestench15
addwrapperforimguiPlotLineswidget
ThispatchonlywrapsthePlotLineswidgetfromimgui,butthehistogram
andotherplottingwidgetscouldbewrappedalso.
Thisalsoaddsanexampleinexamples/plotshowingbothg.PlotLines()
andg.PlotLinesV().
Futurework:theimguiplottingwidgetisalittlelimited,itwouldbe
niceforGIUtosupportamorerobustplottingsystem.Thiscould
perhapsbedonefromscratchbasedonaCanvaswidget,possiblyby
writingaback-endforgonum/plot.
openedbycharlesdaniels13
Moredetailedcrashlogs
Relatedproblem
whenIusegmdeploydeployedmyapp,itworks.Butsometimesitwillcrashaccordingtosomeuseractions.Inmacconsoleapp,Icanonlyseesomelogslikebelow:
Nov1818:23:31172-11-2-103com.apple.xpc.launchd[1](com.yourcompany.ImStock.142800.B51455B5-8491-4229-BACE-10E765B6C578[56465]):Serviceexitedwithabnormalcode:2
Yourrequest
Iwishsomemoredetailedlogscanbecollected.
Alternativesolution
Noresponse
Additionalcontext
Noresponse
enhancement
openedbydaiwhea2
[FeatureRequest]ArethereplansforArm64onMacOS?
Relatedproblem
Noresponse
Yourrequest
Itwouldbenice-ifitisfeasible-tobeabletoprovideUniversalbinariesonMacOS.IbelievethetheM1processorrunsbinariesbuiltfromGiuwithouttroublesoIdon'tthinkthere'sanythinglikeadeadlineforthis.
Alternativesolution
Noresponse
Additionalcontext
Noresponse
enhancement
openedbymacbutch1
splitLayoutsometimescrasheswhileresizingwindow.
Hithere!
democode
packagemain
import(
g"github.com/AllenDang/giu"
)
funcloop(){
g.Window("wnd").Size(80,80).Layout(
g.SplitLayout(g.DirectionHorizontal,true,80,
g.Layout{
g.Label("Test1"),
},
g.Layout{
g.Label("Test2"),
},
),
)
}
funcmain(){
w:=g.NewMasterWindow("Splitter",640,480,0)
w.Run(loop)
}
panicmessage
main:imgui_widgets.cpp:731:boolImGui::InvisibleButton(constchar*,constImVec2&,ImGuiButtonFlags):Assertion`size_arg.x!=0.0f&&size_arg.y!=0.0f'failed.
SIGABRT:abort
PC=0x7f4cc779f2a2m=0sigcode=18446744073709551610
signalarrivedduringcgoexecution
goroutine1[syscall,lockedtothread]:
runtime.cgocall(0x5e96a0,0xc0000cb9a0)
/usr/local/go/src/runtime/cgocall.go:156+0x5cfp=0xc0000cb978sp=0xc0000cb940pc=0x485f9c
github.com/AllenDang/imgui-go._Cfunc_iggInvisibleButton(0x304e170,0xc000298ef0)
_cgo_gotypes.go:4084+0x4cfp=0xc0000cb9a0sp=0xc0000cb978pc=0x550a6c
github.com/AllenDang/imgui-go.InvisibleButton({0xc000298e40,0x200000003},{0x40800000,0x0})
/home/username/git/d2/me/giu/vendor/github.com/AllenDang/imgui-go/imgui.go:392+0x8dfp=0xc0000cb9e0sp=0xc0000cb9a0pc=0x55886d
github.com/AllenDang/giu.(*VSplitterWidget).Build(0xc0002886e0)
/home/username/git/d2/me/giu/Widgets.go:2137+0xc5fp=0xc0000cba70sp=0xc0000cb9e0pc=0x5e5e45
github.com/AllenDang/giu.(*RowWidget).Build.func1({0x8ba160,0xc0002886e0})
/home/username/git/d2/me/giu/Widgets.go:59+0x159fp=0xc0000cba98sp=0xc0000cba70pc=0x5e5339
github.com/AllenDang/giu.Layout.Range({0xc000280f60,0x3,0x552265},0xc00028b0b0)
/home/username/git/d2/me/giu/Layout.go:48+0x9cfp=0xc0000cbaf0sp=0xc0000cba98pc=0x5e2bfc
github.com/AllenDang/giu.(*RowWidget).Build(0xc0002858c0)
/home/username/git/d2/me/giu/Widgets.go:41+0x85fp=0xc0000cbb28sp=0xc0000cbaf0pc=0x5e51a5
github.com/AllenDang/giu.Layout.Build({0xc0000cbc30,0x1,0x8ba500})
/home/username/git/d2/me/giu/Layout.go:28+0x58fp=0xc0000cbb50sp=0xc0000cbb28pc=0x5e2b18
github.com/AllenDang/giu.(*SplitLayoutWidget).Build(0xc00028c410)
/home/username/git/d2/me/giu/SplitLayout.go:130+0x5fdfp=0xc0000cbc80sp=0xc0000cbb50pc=0x5e4b3d
github.com/AllenDang/giu.Layout.Build({0xc0002886c0,0x2,0x0})
/home/username/git/d2/me/giu/Layout.go:28+0x58fp=0xc0000cbca8sp=0xc0000cbc80pc=0x5e2b18
github.com/AllenDang/giu.(*WindowWidget).Layout(0xc0000cbd90,{0xc0000cbd80,0x1,0x1})
/home/username/git/d2/me/giu/Window.go:139+0x23efp=0xc0000cbd30sp=0xc0000cbca8pc=0x5e62fe
main.loop()
/home/username/git/d2/me/giu/examples/split-layout-bug/main.go:8+0x2a5fp=0xc0000cbdd8sp=0xc0000cbd30pc=0x5e6fe5
github.com/AllenDang/giu.(*MasterWindow).render(0xc00007e000)
/home/username/git/d2/me/giu/MasterWindow.go:192+0xa5fp=0xc0000cbe48sp=0xc0000cbdd8pc=0x5e3a65
github.com/AllenDang/giu.(*MasterWindow).run.func1()
/home/username/git/d2/me/giu/MasterWindow.go:210+0x48fp=0xc0000cbe80sp=0xc0000cbe48pc=0x5e3cc8
github.com/faiface/mainthread.Call.func1()
/home/username/git/d2/me/giu/vendor/github.com/faiface/mainthread/mainthread.go:63+0x26fp=0xc0000cbeb0sp=0xc0000cbe80pc=0x55cde6
github.com/faiface/mainthread.Run(0xc00000e4c8)
/home/username/git/d2/me/giu/vendor/github.com/faiface/mainthread/mainthread.go:44+0xc9fp=0xc0000cbf28sp=0xc0000cbeb0pc=0x55cba9
github.com/AllenDang/giu.(*MasterWindow).Run(0xc00007e000,0x890580)
/home/username/git/d2/me/giu/MasterWindow.go:283+0x72fp=0xc0000cbf48sp=0xc0000cbf28pc=0x5e3d72
main.main()
/home/username/git/d2/me/giu/examples/split-layout-bug/main.go:22+0x3dfp=0xc0000cbf80sp=0xc0000cbf48pc=0x5e703d
runtime.main()
/usr/local/go/src/runtime/proc.go:255+0x227fp=0xc0000cbfe0sp=0xc0000cbf80pc=0x4b7fa7
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1581+0x1fp=0xc0000cbfe8sp=0xc0000cbfe0pc=0x4e39a1
goroutine5[chanreceive]:
github.com/faiface/mainthread.Call(0xc000280e70)
/home/username/git/d2/me/giu/vendor/github.com/faiface/mainthread/mainthread.go:66+0xb1
github.com/AllenDang/giu.(*MasterWindow).run(0xc00007e000)
/home/username/git/d2/me/giu/MasterWindow.go:208+0x87
github.com/AllenDang/giu.(*MasterWindow).Run.func1()
/home/username/git/d2/me/giu/MasterWindow.go:288+0x4b
github.com/faiface/mainthread.Run.func1()
/home/username/git/d2/me/giu/vendor/github.com/faiface/mainthread/mainthread.go:37+0x26
createdbygithub.com/faiface/mainthread.Run
/home/username/git/d2/me/giu/vendor/github.com/faiface/mainthread/mainthread.go:36+0xbd
rax0x0
rbx0x7f4cc7615740
rcx0x7f4cc779f2a2
rdx0x0
rdi0x2
rsi0x7ffe40acb370
rbp0x7f4cc79278f0
rsp0x7ffe40acb370
r80x0
r90x7ffe40acb370
r100x8
r110x246
r120x8e8ed5
r130x2db
r140x8e6fe8
r150xef
rip0x7f4cc779f2a2
rflags0x246
cs0x33
fs0x0
gs0x0
exitstatus2
toreproduce
runthedemo
playwithwindowresizing(catchbottom-rightcorner)
appwillcrash
openedbygucio3210
SplitLayout.go:SetStyleChildBGseemstobeunnecessary
Hithere,
whatdoesexactlydothisline?
Style().SetColor(StyleColorChildBg,Vec4ToRGBA(imgui.CurrentStyle().GetColor(imgui.StyleColorChildBg))).To(
wecanfinditinSplitLayout.go:https://github.com/AllenDang/giu/blob/7a1a262cf0eb925dd66f6604d724506ba32023e0/SplitLayout.go#L78
openedbygucio3211
CalcTextSizeWidthis2timestoobig
IfImakeaprogramthatsetsitemspacingandframepaddingto0,setsamonospacefont,thencallsGetAvailableRegionandCalcTextSizeandtriestofillthescreenwithcharacters,onlyhalfthewidthofthescreenisactuallyfilled.ItseemsthatCalcTextSizereturnsawidththatis2timestoobig?
Belowisanexampleprogramthattriestofillthescreenwith"."'s,butonlysucceedsinfillingthelefthalf.
packagemain
import(
"fmt"
G"github.com/AllenDang/giu"
I"github.com/AllenDang/imgui-go"
)
funcdraw(){
G.SingleWindow().Layout(
G.Child().Layout(
G.Custom(func(){
I.PushStyleVarVec2(I.StyleVarFramePadding,I.Vec2{X:0,Y:0})
I.PushStyleVarVec2(I.StyleVarItemSpacing,I.Vec2{X:0,Y:0})
w,h:=G.GetAvailableRegion()
cw,ch:=G.CalcTextSize(".")
numline:=int(h/ch)
numchar:=int(w/cw)
fmt.Printf("w=%f,h=%f,cw=%f,ch=%f,numline=%d,numchar=%d\n",w,h,cw,ch,numline,numchar)
fori:=0;i