MCPcopy
hub / github.com/g3n/engine / newTreeNode

Function newTreeNode

gui/tree.go:196–221  ·  view source on GitHub ↗

TreeNode methods newTreeNode creates and returns a pointer to a new TreeNode with the specified text, tree and parent node

(text string, tree *Tree, parNode *TreeNode)

Source from the content-addressed store, hash-verified

194// newTreeNode creates and returns a pointer to a new TreeNode with
195// the specified text, tree and parent node
196func newTreeNode(text string, tree *Tree, parNode *TreeNode) *TreeNode {
197
198 n := new(TreeNode)
199 n.Panel.Initialize(n, 0, 0)
200
201 // Initialize node label
202 n.label.initialize(text, StyleDefault().Font)
203 n.Panel.Add(&n.label)
204
205 // Create node icon
206 n.icon.initialize("", StyleDefault().FontIcon)
207 n.icon.SetFontSize(StyleDefault().Label.PointSize * 1.3)
208 n.Panel.Add(&n.icon)
209
210 // Subscribe to events
211 n.Panel.Subscribe(OnMouseDown, n.onMouse)
212 n.Panel.Subscribe(OnListItemResize, func(evname string, ev interface{}) {
213 n.recalc()
214 })
215 n.tree = tree
216 n.parNode = parNode
217
218 n.update()
219 n.recalc()
220 return n
221}
222
223// Len returns the number of immediate children of this node
224func (n *TreeNode) Len() int {

Callers 3

InsertNodeAtMethod · 0.85
AddNodeMethod · 0.85
InsertNodeAtMethod · 0.85

Calls 8

StyleDefaultFunction · 0.85
SubscribeMethod · 0.65
InitializeMethod · 0.45
initializeMethod · 0.45
AddMethod · 0.45
SetFontSizeMethod · 0.45
recalcMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected