birowo / gi

Native Go (golang) Graphical Interface system (2D and 3D), built on GoKi tree framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gi

alt tag

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

Go Report Card GoDoc

NOTE: Requires Go version 1.10+ due to use of math.Round.

See the Wiki for more docs, discussion, etc. Install instructions (just standard go get ...).

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, 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). 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.

See Gide for a complete, complex application written in GoGi (an IDE), and the various examples in this repository for lots of useful demonstrations -- start with the Widgets example which has a bit of a tutorial introduction.

Main Features

  • 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. See gi/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.

  • 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., in Label 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 is fully Go-native with no cgo dependency on Linux and Windows, and minimal cgo (necessary) on MacOS. This is the only complete Go GUI framework that is entirely Go-based, without dependency on other C-based toolkits.

  • Fully self-contained -- does not use OS-specific native widgets -- results in simple, elegant, consistent code across platforms, and is fully HiDPI capable and scalable using standard Ctrl/Cmd+Plus or Minus key, and in Preferences.

  • SVG element (in svg sub-package) supports full SVG rendering -- used for Icons internally and available for advanced graphics displays -- see gi/examples/svg for 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 giv sub-package), from individual types (e.g., int, float display in a SpinBox, "enum" const int types in a ComboBox chooser) to composite data structures, including StructView editor of struct fields, MapView and SliceView displays of map and slice elements (including full editing / adding / deleting of elements), and full-featured TableView for a slice-of-struct and TreeView for GoKi trees.

    • TreeView enables a built-in GUI editor / inspector for designing gui elements themselves. Just press Control+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..

Screenshot of Widgets demo

Screenshot of Widgets demo, Darker

Code Overview

There are three main types of 2D nodes:

  • Viewport2D nodes that manage their own oswin.Image bitmap and can upload that directly to the oswin.Texture that then uploads directly to the oswin.Window. The parent Window has a master Viewport2D that backs the entire window, and is what most Widget's render into. + Popup Dialog and Menu's have their own viewports that are layered on top of the main window viewport. + SVG and its subclass Icon are containers for SVG-rendering nodes.

  • Widget nodes that use the full CSS-based styling (e.g., the Box model etc), are typically placed within a Layout -- they use units system 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).

  • SVG rendering nodes that directly set properties on the Paint object and typically have their own geometry etc -- they should be within a parent SVG 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 in UpdateStart / End, but do NOT emit a signal
  • SetValueAction calls SetValue 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.

Status

As of 11/2018 it is now at a beta level:

  • All major functionality is in place, and API is stable and only very 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.

About

Native Go (golang) Graphical Interface system (2D and 3D), built on GoKi tree framework

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 98.2%Language:Objective-C 1.7%Language:Assembly 0.1%Language:Makefile 0.0%