GoGi is part of the GoKi Go language (golang) full strength tree structure system (ki = ๆจ = tree in Japanese)
package gi
is a scenegraph-based 2D and 3D GUI / graphics interface (Gi) in Go.
NOTE: Requires Go version 1.11+
due to use of math.Round
and os.UserCacheDir
.
See the Wiki for more docs (increasingly extensive), Install instructions (mostly just standard go get ...
, but does now depend on cgo
so see details for each platform), and Google Groups goki-gi emailing list.
GoGi uses the GoKi tree infrastructure to implement a scenegraph-based GUI framework in full native idiomatic Go, with minimal OS-specific backend interfaces based originally on the Shiny drivers, now using go-gl/glfw, and supporting MacOS, Linux, and Windows. The overall design is an attempt to integrate existing standards and conventions from widely-used frameworks, including Qt (overall widget design), HTML / CSS (styling), and SVG (rendering). The main 2D framework also integrates with an (in progress) 3D scenegraph, supporting interesting combinations of these frameworks. Currently GoGi is focused on desktop systems, but nothing should prevent adaptation to mobile.
See Gide for a complete, complex application written in GoGi (an IDE), and likewise the Emergent neural network simulation environment, along with the various examples in this repository for lots of useful demonstrations -- start with the Widgets example which has a bit of a tutorial introduction.
-
Has all the standard widgets:
Button
,Menu
,Slider
,TextField
,SpinBox
,ComboBox
etc, with tooltips, hover, focus, copy / paste (full native clipboard support), drag-n-drop -- the full set of standard GUI functionality. Seegi/examples/widgets
for a demo of all the widgets. -
Powerful
Layout
logic auto-sizes everything -- very easy to configure interfaces that just work across different scales, resolutions, platforms. Automatically remembers and reinstates window positions and sizes across sessions, and supports standardCtrl+
andCtrl-
zooming of display scale. -
CSS-based styling allows easy customization of everything -- native style properties are fully HTML compatible (with all standard
em
,px
,pct
etc units), including full HTML "rich text" styling for all text rendering (e.g., inLabel
widget) -- can decorate any text with inline tags (<strong>
,<em>
etc), and even include links. -
Compiles in seconds, compared to many minutes to hours for comparable alternatives such as Qt, and with minimal cgo dependency. As of April 2019 we now depend on the glfw cross-platform GUI infrastructure system, and the go-gl/gl OpenGL bindings, to support the 3D (
gi3d
) aspect of the framework. -
Fully self-contained -- does not use OS-specific native widgets -- results in simpler, consistent code across platforms, and is fully
HiDPI
capable and scalable using standardCtrl/Cmd+Plus or Minus
key, and inPreferences
. -
SVG
element (insvg
sub-package) supports full SVG rendering -- used for Icons internally and available for advanced graphics displays -- seegi/examples/svg
for viewer and start on editor, along with a number of test .svg files. -
Powerful Model / View paradigm with
reflect
ion-based view elements that display and manipulate all the standard Go types (ingiv
sub-package), from individual types (e.g., int, float display in aSpinBox
, "enum" const int types in aComboBox
chooser) to composite data structures, includingStructView
editor ofstruct
fields,MapView
andSliceView
displays ofmap
andslice
elements (including full editing / adding / deleting of elements), and full-featuredTableView
for aslice
-of-struct
andTreeView
for GoKi trees.TreeView
enables a built-in GUI editor / inspector for designing gui elements themselves. Just pressControl+Alt+I
in any window to pull up this editor / inspector. Scene graphs can be automatically saved / loaded from JSON files, to provide a basic GUI designer framework -- just load and add appropriate connections..
There are three main types of 2D nodes:
-
Viewport2D
nodes that manage their ownoswin.Image
bitmap and can upload that directly to theoswin.Texture
that then uploads directly to theoswin.Window
. The parentWindow
has a masterViewport2D
that backs the entire window, and is what mostWidget
's render into.- Popup
Dialog
andMenu
's have their own viewports that are layered on top of the main window viewport. SVG
and its subclassIcon
are containers for SVG-rendering nodes.
- Popup
-
Widget
nodes that use the full CSS-based styling (e.g., the Box model etc), are typically placed within aLayout
-- they useunits
system with arbitrary DPI to transform sizes into actual rendereddots
(term for actual raw resolution-dependent pixels -- "pixel" has been effectively co-opted as a 96dpi display-independent unit at this point). Widgets have non-overlapping bounding boxes (BBox
-- cached for all relevant reference frames). -
SVG
rendering nodes that directly set properties on thePaint
object and typically have their own geometry etc -- they should be within a parentSVG
viewport, and their geom units are determined entirely by the transforms etc and we do not support any further unit specification -- just raw float values.
General Widget method conventions:
SetValue
kinds of methods are wrapped inUpdateStart
/End
, but do NOT emit a signal.SetValueAction
callsSetValue
and emits the signal. This allows other users of the widget that also recv the signal to not trigger themselves, but typically you want the update, so it makes sense to have that in the basic version.ValueView
in particular requires this kind of behavior.
The best way to see how the system works are in the examples
directory, and by interactively modifying any existing gui using the interactive reflective editor via Control+Alt+I
.
- As of 6/6/2019 the 3D
gi3d
component of the framework is integrated at a basic, first-pass level, and the backend switch to usingglfw
is stable, if not perfect. Significant performance improvements, simplifications / cleanups, etc have been incorporated -- getting close to a 1.0 release level once the 3D is more feature-complete and integrated. Active users should join Google Groups goki-gi emailing list to receive more detailed status updates.
For the 2D framework:
-
All major functionality is in place, and API is stable and only minor changes are anticipated going forward. The system is now ready for wider adoption.
-
Everything has been thoroughly tested, but generally only by a small number of core developers / users.
-
Please file Issues for anything that does not work.
-
3/2019:
python
wrapper is now available! you can do most of GoGi from python now. See README.md file there for more details.