Skip to content

Interfaces

Randall C. O'Reilly edited this page Jan 25, 2024 · 1 revision

The core infrastructure that is common and mandatory across nodes is all defined in the Node and Node2D interfaces in node.go and node2d.go files. These extend the ki.Node interface and represent somewhat of a departure from the Go philosophy of having many separate mix-n-match interfaces. However, in this case, there is a coherent set of mutually-interdependent methods that must be defined for a node to support the core functions of the GoGi GUI, so it does not make sense to separate these out.

In addition, there several more optional interfaces that are defined, which apply to a specific more narrow domain of functionality, which do make sense to break out. These are as follows:

gi.Labeler and gi.SliceLabeler in gi/labeler.go

Label() method is used to get a GUI-friendly label for any type (e.g., by returning a Name field etc).

for SliceLabeler it has an idx arg, for given slice index to return label for.

gi.Clipper and gi.DragNDropper in gi/clipper.go

Clipper defines the basic Copy Cut and Paste method interface

DragNDropper defines Drop and Dragged methods

gi.Updater in gi/updater.go

Update() method is called after any type value is changed (e.g., a struct field) from GUI action (e.g., when that type is being viewed by a giv *View widget).

gi.Completer in gi.complete.go

SetCompleter method called to set the completion function for a type -- used for complete tag -- see Tags.

gi.Styler

Style() *Style method returns Style for gui element

gi.Painter

Paint() *Paint method returns Paint for gui element