-
Notifications
You must be signed in to change notification settings - Fork 7
/
gtigen.go
49 lines (43 loc) · 3.59 KB
/
gtigen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Code generated by "goki generate"; DO NOT EDIT.
package ki
import (
"goki.dev/gti"
"goki.dev/ordmap"
)
// NodeType is the [gti.Type] for [Node]
var NodeType = gti.AddType(>i.Type{
Name: "goki.dev/ki/v2.Node",
ShortName: "ki.Node",
IDName: "node",
Doc: "The Node implements the Ki interface and provides the core functionality\nfor the GoKi tree -- use the Node as an embedded struct or as a struct\nfield -- the embedded version supports full JSON save / load.\n\nThe desc: key for fields is used by the GoGi GUI viewer for help / tooltip\ninfo -- add these to all your derived struct's fields. See relevant docs\nfor other such tags controlling a wide range of GUI and other functionality\n-- Ki makes extensive use of such tags.",
Directives: gti.Directives{},
Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Nm", >i.Field{Name: "Nm", Type: "string", Doc: "Ki.Name() user-supplied name of this node -- can be empty or non-unique", Directives: gti.Directives{}}},
{"Flags", >i.Field{Name: "Flags", Type: "Flags", Doc: "[tableview: -] bit flags for internal node state -- can extend this using enums package", Directives: gti.Directives{}}},
{"Props", >i.Field{Name: "Props", Type: "Props", Doc: "[tableview: -] Ki.Properties() property map for arbitrary extensible properties, including style properties", Directives: gti.Directives{}}},
{"Par", >i.Field{Name: "Par", Type: "Ki", Doc: "[view: -] [tableview: -] Ki.Parent() parent of this node -- set automatically when this node is added as a child of parent", Directives: gti.Directives{}}},
{"Kids", >i.Field{Name: "Kids", Type: "Slice", Doc: "[tableview: -] Ki.Children() list of children of this node -- all are set to have this node as their parent -- can reorder etc but generally use Ki Node methods to Add / Delete to ensure proper usage", Directives: gti.Directives{}}},
{"Ths", >i.Field{Name: "Ths", Type: "Ki", Doc: "[view: -] we need a pointer to ourselves as a Ki, which can always be used to extract the true underlying type of object when Node is embedded in other structs -- function receivers do not have this ability so this is necessary. This is set to nil when deleted. Typically use This() convenience accessor which protects against concurrent access.", Directives: gti.Directives{}}},
{"NumLifetimeKids", >i.Field{Name: "NumLifetimeKids", Type: "uint64", Doc: "the number of children that have ever been added to this node, which is used for unique naming", Directives: gti.Directives{}}},
{"index", >i.Field{Name: "index", Type: "int", Doc: "[view: -] last value of our index -- used as a starting point for finding us in our parent next time -- is not guaranteed to be accurate! use IndexInParent() method", Directives: gti.Directives{}}},
{"depth", >i.Field{Name: "depth", Type: "int", Doc: "[view: -] optional depth parameter of this node -- only valid during specific contexts, not generally -- e.g., used in WalkBreadth function", Directives: gti.Directives{}}},
}),
Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}),
Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
Instance: &Node{},
})
// NewNode adds a new [Node] with the given name
// to the given parent. If the name is unspecified, it defaults
// to the ID (kebab-case) name of the type, plus the
// [Ki.NumLifetimeChildren] of the given parent.
func NewNode(par Ki, name ...string) *Node {
return par.NewChild(NodeType, name...).(*Node)
}
// KiType returns the [*gti.Type] of [Node]
func (t *Node) KiType() *gti.Type {
return NodeType
}
// New returns a new [*Node] value
func (t *Node) New() Ki {
return &Node{}
}