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.10+ due to use of
See the Wiki for more docs, discussion, etc.
GoGi uses the GoKi tree infrastructure to implement a simple, elegant GUI framework in full native idiomatic Go (with minimal OS-specific backend interfaces based on the Shiny drivers). 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). This 2D framework also integrates with a (planned) 3D scenegraph, supporting interesting combinations of these frameworks. Currently GoGi is focused on desktop systems, but nothing prevents adaptation to mobile.
Has all the standard widgets:
ComboBoxetc, with tooltips, hover, focus, copy / paste (full native clipboard support), drag-n-drop -- the full set of standard GUI functionality. See
gi/examples/widgetsfor a demo.
Layoutlogic 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.
CSS-based styling allows easy customization of everything -- native style properties are fully HTML compatible (with all standard
pctetc units), including full HTML "rich text" styling for all text rendering (e.g., in
Labelwidget) -- can decorate any text with inline tags (
<em>etc), and even include links.
Compiles in second(s), compared to hour(s) for Qt, and is fully native with no cgo dependency on Linux and Windows, and minimal cgo (necessary) on MacOS.
Fully self-contained -- does not use OS-specific native widgets -- results in simple, elegant, consistent code across platforms, and is fully
HiDPIcapable and scalable using standard
Shift+Ctrl/Cmd+Plus or Minuskey, and in
Ctrl+Alt+Pin any window to get Prefs editor).
svgsub-package) supports full SVG rendering -- used for Icons internally and available for advanced graphics displays -- see
gi/examples/svgfor viewer and start on editor, along with a number of test .svg files.
Advanced Model / View paradigm with
reflection-based view elements that display and manipulate all the standard Go types (in
givsub-package), from individual types (e.g., int, float display in a
SpinBox, "enum" const int types in a
ComboBoxchooser) to composite data structures, including
sliceelements (including full editing / adding / deleting of elements), and full-featured
TreeViewfor GoKi trees.
TreeViewenables a built-in GUI editor / inspector for designing gui elements themselves. Just press
Control+Alt+Iin 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..
examples/widgets-- main example widget gallery --
go get ...
go buildin there to give it a try -- see README there for more info. Many other demos / tests in
3Dstructs and interfaces -- all Gi nodes are of this type.
Vec2Dis main geom type used for 2D, plus transform
Paintstruct that does all the direct rendering, uses
gg-based API but now uses the
srwiley/renderxrendering system which supports SVG 2.0, and is very fast.
FillStylestructs for stroke, fill settings
ColorSpecfor full gradient support,
color.Colorcompatible RGBA type with many additional useful methods, including support for
HSLcolorspace -- see Wiki Color for more info.
Styleand associated structs for CSS-based
Viewport2Dthat has an
Windowis the top-level window that manages an OS-specific
oswin.Windowand handles the event loop.
oswinis a modified version of the back-end OS-specific code from Shiny: https://github.com/golang/exp/tree/master/shiny -- originally used https://github.com/skelterjohn/go.wde but shiny is much faster for updating the window because it is gl-based, and doesn't have any other dependencies (removed dependencies on mobile, changed the event structure to better fit needs here).
TextRenderthat manages rich-text rendering in a powerful, efficient manner (layered on
FontStylecontains the global
opacityvalues, to make these easily avail to the
Layoutobject with various ways of arranging widget elements, and
Framewhich does layout and renders a surrounding frame.
WidgetBasefor all widgets.
Buttonand other basic button types.
Actionis a Button-type used in menus and toolbars, with a simplified
Label, etc -- also defines the
ToLabelconverter method (which falls back on kit.ToString using Stringer), which is used for generating a gui-appropriate label for an object -- e.g., for reflect.Type it just presents the raw type name without prefix.
Iconwrapper around svg icons (in
svg-- has all the SVG nodes (
giv-- has all the
gimain-- provides a meta-package wrapper to simplify imports for
mainapps -- also does relevant final platform-specific customization
units-- CSS unit representation
There are three main types of 2D nodes:
Viewport2Dnodes that manage their own
oswin.Imagebitmap and can upload that directly to the
oswin.Texturethat then uploads directly to the
oswin.Window. The parent
Windowhas a master
Viewport2Dthat backs the entire window, and is what most
Widget's render into. + Popup
Menu's have their own viewports that are layered on top of the main window viewport. +
SVGand its subclass
Iconare containers for SVG-rendering nodes.
Widgetnodes that use the full CSS-based styling (e.g., the Box model etc), are typically placed within a
Layout-- they use
unitssystem with arbitrary DPI to transform sizes into actual rendered
dots(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).
SVGrendering nodes that directly set properties on the
Paintobject and typically have their own geometry etc -- they should be within a parent
SVGviewport, 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:
SetValuekinds of methods are wrapped in
End, but do NOT emit a signal
SetValueand 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.
ValueViewin 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
Currently at a pre-beta level (DON'T RECOMMEND USING RIGHT NOW -- come back in a few weeks after announcement on go-nuts email list).
Major push underway to get to the following target for a beta level release:
All major functionality is in place, and API is stable and only very minor changes will be allowed 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 (except as noted below under TODO)
would be a lot faster if textbuf held the markup text and views just read off of that -- then switching buffers would be instant. might make it easier to protect the updating too -- views don't get a crack at anything until it is updated.. -- also ideally do a diff for re-open, and only re-highlight areas that are changed. as a first pass, at least testing for identity would save a lot of time for most post-save actions.
focus issues in tableview: real! but very hard to reproduce!
closing a buffer, and more generally sometimes, renders too-narrow box width. init is also too narrow at start actually.
also more generally the select logic for resetting the start of select needs to be fixed to work like emacs..
fix embedded tags in pre html parser -- just need a simple stack..
NOT getting mysterious crashes in clearClip and closewindow on mac in cocoa.m -- once I turned off mainmenu updating -- will try to re-activate and debug..
drag on textview should prevent DND -- dnd not getting "processed"
- select / space / return on links in inactive mode should activate link, and why is typing working on inactive mode anyway!?
- word-level functions: forward, back, delete etc. ctrl+ backspace is back.
- clipboard history
- clipboard "registers" (C-x x , C-x g )
- gide resize textview not re-drawing (still?)
- some lowpri keyfuns for collapsing and expanding -- this goes in gide -- need multi-key.
CSS class = x should bring in properties for that class into top-level CSS for all below -- not sure it does that - nested classes. need to figure that out really.
slice of ki: do proper add so it works directly by editing children -- requires accessing owner info from valueview recs -- that is what the ki.Slice by itself does not have
see if ubuntu and windows have a decent unicode fallback font https://unix.stackexchange.com/questions/14027/what-fonts-are-good-for-unicode-glyphs
windows: arialuni.ttf https://docs.microsoft.com/en-us/typography/font-list/arial-unicode-ms
textfield should scroll layout so that cursor is always in view, when editing..
fileview should add extension to filename if only one extension provided, if user types in a new filename..
fix text scrolling-off-top rendering finally
fix the style-props context -- need an overall prop on objects -- in type presumably. completer needs to know about this too. in mapview proximally.
update gi/doc.go with final readme notes etc! add docs to this README about "what can you do with demos?" kind of thing..
update widgets README
Reminder: grep all todo: in code