AllenDang/giu: Cross platform rapid GUI framework ... - GitHub
文章推薦指數: 80 %
A rapid cross-platform GUI framework for Go based on Dear ImGui and the great Go binding imgui-go. Any contribution (features, widgets, tutorials, ...
Skiptocontent
{{message}}
AllenDang
/
giu
Public
Notifications
Star
1.1k
Fork
72
CrossplatformrapidGUIframeworkforgolangbasedonDearImGui.
MITLicense
1.1k
stars
72
forks
Star
Notifications
Code
Issues
23
Pullrequests
1
Discussions
Actions
Projects
0
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Discussions
Actions
Projects
Wiki
Security
Insights
master
Branches
Tags
Couldnotloadbranches
Nothingtoshow
Loading
{{refName}}
default
Couldnotloadtags
Nothingtoshow
{{refName}}
default
Loading
2
branches
10
tags
Code
Loading
Latestcommit
Gitstats
969
commits
Files
Permalink
Failedtoloadlatestcommitinformation.
Type
Name
Latestcommitmessage
Committime
.github
cmd/gmdeploy
examples
screenshots
.gitignore
.golangci.yml
.travis.yml
Alignment.go
Canvas.go
ClickableWidgets.go
CodeEditor.go
Context.go
Context_test.go
Direction.go
EventHandler.go
Events.go
ExtraWidgets.go
Flags.go
FontAtlasProsessor.go
ImageWidgets.go
InputHandler.go
InputHandler_test.go
Keycode.go
LICENSE
Layout.go
Layout_test.go
ListClipper.go
Markdown.go
MasterWindow.go
MemoryEditor.go
Msgbox.go
Plot.go
Popups.go
ProgressIndicator.go
README.md
SliderWidgets.go
SplitLayout.go
StackWidget.go
Style.go
TableWidgets.go
TextWidgets.go
Texture.go
TextureFilters.go
Utils.go
Utils_test.go
Widgets.go
Window.go
doc.go
go.mod
go.sum
Viewcode
giu
Sponsor
SupportedPlatforms
Features
Helloworld
Quickintroduction
WhatisimmediatemodeGUI?
Thelayoutandsizingsystem
Containers
MasterWindow
Window
Child
Widgets
Install
MacOS
Windows
Linux
Deploying
BuildMacOSversiononMacOS.
BuildWindowsversiononWindows.
BuildWindowsversiononMacOS.
Documentation
Contribution
README.md
giu
Arapidcross-platformGUIframeworkforGobasedonDearImGuiandthegreatGobindingimgui-go.
Anycontribution(features,widgets,tutorials,documents,etc...)isappreciated!
Sponsor
(Thislibraryisavailableunderafreeandpermissivelicense,butneedsfinancialsupporttosustainitscontinuedimprovements.Inadditiontomaintenanceandstabilitytherearemanydesirablefeaturesyettobeadded.Ifyouareusinggiu,pleaseconsiderreachingout.)
Businesses:supportcontinueddevelopmentandmaintenanceviainvoicedtechnicalsupport,maintenance,sponsoringcontracts:
E-mail:[email protected]
Individuals:supportcontinueddevelopmentandmaintenancehere.
SupportedPlatforms
giuisbuiltuponGLFWv3.3,soideallygiucouldsupportallplatformsthatGLFWv3.3supports.
Windows(Windows10x64andWindows11x64)
macOS(macOSv10.15andmacOSBigSur)
Linux(thanksremehfortestingit)
RaspberryPi3B(thankssndvapsfortestingit)
Features
ComparedtootherDearImGuigolangbindings,giuhasthefollowingfeatures:
Smallexecutablefilesize(<3MBafterUPXcompressionfortheexample/helloworlddemo).
Live-updatingduringtheresizingoftheOSwindow(implementedonGLFW3.3andOpenGL3.2).
Supportfordisplayingvariouslanguageswithoutanyfontsetting.GiuwillrebuildfontatlasincrementallyaccordingtotextsinUIbetweenframes.
Redrawsonlywhenusereventoccurs.Costsonly0.5%CPUusagewith60FPS.
DeclarativeUI(seeexamplesformoredetails).
DPIawareness(autoscalingfontandUItoadapttohighDPImonitors).
Dropinusage;noneedtoimplementrenderandplatform.
OSclipboardsupport.
Helloworld
packagemain
import(
"fmt"
g"github.com/AllenDang/giu"
)
funconClickMe(){
fmt.Println("Helloworld!")
}
funconImSoCute(){
fmt.Println("Imsooooooocute!!")
}
funcloop(){
g.SingleWindow().Layout(
g.Label("Helloworldfromgiu"),
g.Row(
g.Button("ClickMe").OnClick(onClickMe),
g.Button("I'msocute").OnClick(onImSoCute),
),
)
}
funcmain(){
wnd:=g.NewMasterWindow("Helloworld",400,200,g.MasterWindowFlagsNotResizable,nil)
wnd.Run(loop)
}
Hereistheresult:
Quickintroduction
WhatisimmediatemodeGUI?
ImmediatemodeGUIsystemmeanstheUIcontroldoesn'tretainitsstateandvalue.Forexample,callinggiu.InputText("ID",&str)willdisplayainputtextboxonscreen,andtheuserenteredvaluewillbestoredin&str.Inputtextboxdoesn'tknowanythingaboutit.
AndtheloopmethodintheHelloworldexampleisinchargeofdrawingallwidgetsbasedontheparameterspassedintothem.Thismethodwillbeinvoked30timespersecondtoreflectinteractivestates(likeclicked,hovered,value-changed,etc.).ItwillbetheplaceyoudefinetheUIstructure.
Thelayoutandsizingsystem
Bydefault,anywidgetplacedinsideacontainer'sLayoutwillbeplacedvertically.
Tocreatearowofwidgets(i.e.placewidgetsonebyonehorizontally),usetheRow()method.Forexamplegiu.Row(Label(...),Button(...))willcreateaLabelnexttoaButton.
Tocreateacolumnofwidgets(i.e.placewidgetsonebyonevertically)insidearow,usetheColumn()method.
AnywidgetthathasaSize()method,cansetitssizeexplicitly.NotethatyoucanpassanegativevaluetoSize(),whichwillfilltheremainingwidth/heightvalue.Forexample,InputText(...).Size(giu.Auto)willcreateaninputtextboxwiththelongestwidththatitscontainerhasleft.
Containers
MasterWindow
AMasterWindowmeanstheplatformnativewindowimplementedbytheOS.Allsubwindowsandwidgetswillbeplacedinsideit.
Window
AWindowisacontainerwithatitlebar,andcanbecollapsed.SingleWindowisaspecialkindofwindowthatwilloccupyalltheavailablespaceofMasterWindow.
Child
AChildislikeapanelinotherGUIframeworks-itcanhaveabackgroundcolorandborder.
Widgets
Checkexamples/widgetsforallkindsofwidgets.
Install
ThebackendofgiudependsonOpenGL3.3,makesureyourenvironmentsupportsit(asfarasIknow,someVirtualMachineslikeVirtualBoxdoesn'tsupportit).
MacOS
xcode-select--install
gogetgithub.com/AllenDang/giu
Windows
Installmingwdownloadhere.Thanks@alchem1ster!
Addthebinariesfolderofmingwtothepath(usuallyis\mingw64\bin).
gogetgithub.com/AllenDang/giu
Or,installTDM-GCC.
Linux
Firstyouneedtoinstalltherequireddependencies:
#aptinstalllibx11-devlibxcursor-devlibxrandr-devlibxinerama-devlibxi-devlibglx-devlibgl1-mesa-devlibxxf86vm-dev
Then,asimplegobuildwillwork.
Cross-compilingisabitmorecomplicated.Let'ssaythatyouwanttobuildforarm64.Thisiswhatyouwouldneedtodo:
#dpkg--add-architecturearm64
#aptupdate
#aptinstallgcc-aarch64-linux-gnug++-aarch64-linux-gnu\
libx11-dev:arm64libxcursor-dev:arm64libxrandr-dev:arm64libxinerama-dev:arm64libxi-dev:arm64libglx-dev:arm64libgl1-mesa-dev:arm64libxxf86vm-dev:arm64
$GOOS=linuxGOARCH=arm64CGO_ENABLED=1CC=aarch64-linux-gnu-gccCXX=aarch64-linux-gnu-g++HOST=aarch64-linux-gnugobuild-v
Deploying
BuildMacOSversiononMacOS.
gobuild-ldflags"-s-w".
BuildWindowsversiononWindows.
gobuild-ldflags"-s-w-H=windowsgui-extldflags=-static".
BuildWindowsversiononMacOS.
Installmingw-64.
brewinstallmingw-w64
Prepareandembedtheapplicationiconintotheexecutableandbuild.
cat>YourExeName.rc<
延伸文章資訊
- 1基于imgui的Golang跨平台快速GUI - Go开发社区 | CTOLib码库
Cross platform rapid GUI framework for golang based on Dear ImGui and the great golang binding im...
- 2Implementing DearImgui to a Vulkan engine
Those 2 are covered by the example implementations, so we are going to use those. Compiling. If y...
- 3Cross platform rapid GUI framework for golang based on Dear ...
AllenDang/giu, giu Cross platform rapid GUI framework for golang based on Dear ImGui and the grea...
- 4Best 16 Dear Imgui Open Source Projects
Check out the best 16Dear Imgui free open source projects. ... Imgui Go. Go wrapper library for "...
- 5imgui - pkg.dev
Package imgui contains subpackages which implement the core.IMGUISystem interface. ... Valid go.m...