Gio

Gio implements portable immediate mode GUI programs in Go. Gio programs run on all the major platforms: iOS/tvOS, Android, Linux (Wayland/X11), macOS, Windows, FreeBSD, OpenBSD, and experimental support for browsers (Webassembly/WebGL). There is a unikernel port for running Gio programs in virtual machines.

Gio includes an efficient vector renderer based on the Pathfinder project (https://github.com/servo/pathfinder), implemented on OpenGL ES and Direct3D 11. Text and other shapes are rendered using only their outlines without baking them into texture images, to support efficient animations, transformed drawing and pixel resolution independence.

This is a screenshot of the Kitchen example. If your browser supports WebAssembly and WebGL, run the example by pressing the run button.

Kitchen screenshot

Documentation

The architecture document is a good introduction to Gio concepts and API.

The examples give a feel of the structure of typical Gio programs.

The “Immediate Mode GUI Programming” article compares Gio’s immediate mode design with the traditional retained mode APIs such as the browser DOM.

Reference documentation

Operations and stateful operation lists are the low-level primitives of Gio. The important operations are for drawing and clipping, as well as pointer and keyboard input.

The layout package implements useful layouts, while the widget and widget/material packages implement common user interface widgets. The gesture package detects common gestures from lower-level input events.

Layouts, widgets and gestures are all implemented in terms of operations.

Package app is for creating windows and apply operations to them. Only the app package and its sub-packages have native dependencies, making Gio highly portable.

GoDoc

Installation

Gio is designed to work with very few dependencies. It depends only on the platform libraries for window management, input and GPU drawing.

Gio supports the latest released version of Go in module mode. Earlier versions of Go and GOPATH mode might work, but no effort is made to keep them working.

Running Gio programs

Use the go tool to initialize a new module and run the “hello” example:

$ go mod init example.com
$ go run gioui.org/example/hello

should display a simple message in a window.

The command

$ go run gioui.org/example/kitchen

is another example that demonstrates the material design widgets.

Running on mobiles

For Android, iOS, tvOS the gogio tool can build and package a Gio program for you.

To build an Android .apk file from the gophers example:

$ go run gioui.org/cmd/gogio -target android gioui.org/example/kitchen

To build for the iOS simulator:

$ go run gioui.org/cmd/gogio -target ios -appid <bundle-id> gioui.org/example/gophers

See the running on mobile page for more information.

Webassembly/WebGL

To run a Gio program in a compatible browser, the gogio tool can output a directory ready to serve. With the goxec tool you don’t even need a web server:

$ go run gioui.org/cmd/gogio -target js gioui.org/example/gophers
$ go get github.com/shurcooL/goexec
$ goexec 'http.ListenAndServe(":8080", http.FileServer(http.Dir("gophers")))'

Open http://localhost:8080 in a browser to run the program.

Integration with existing projects

See the integration guide for details on using Gio with existing projects.

Programs using Gio

Resources

Source code

The source code, mailing lists and issue tracker for Gio are hosted on sourcehut.

Issues

File bugs and TODOs through the issue tracker or send an email to ~eliasnaur/gio@todo.sr.ht. For general discussion, use the ~eliasnaur/gio@lists.sr.ht mailing list or the #gioui Gophers Slack channel.

Contributing

Post patches to the gio-patches list. No Sourcehut account is required and you can post without being subscribed.

You can also use the Sourcehut web-based flow for submitting patches, similar to other source forges. See the contribution guide for more details.

Sponsors

Gio’s main developer is working full-time on Gio, 100% supported by sponsorships. Please consider sponsoring Gio if you find it useful. Sponsorships are handled by GitHub Sponsors and are easy to set up.

Donations

Bitcoin donations are gladly accepted to bc1q8xw95urett00f4xs3v66p2l6xp2mfk5erpe5ug. Donations will go toward hosting expenses and for supporting the author’s full time work on Gio.