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

Method Initialize

gui/folder.go:48–91  ·  view source on GitHub ↗

Initialize initializes the Folder with the specified text and initial width It is normally used when the folder is embedded in another object.

(text string, width float32, contentPanel IPanel)

Source from the content-addressed store, hash-verified

46// Initialize initializes the Folder with the specified text and initial width
47// It is normally used when the folder is embedded in another object.
48func (f *Folder) Initialize(text string, width float32, contentPanel IPanel) {
49
50 f.Panel.Initialize(f, width, 0)
51 f.styles = &StyleDefault().Folder
52
53 // Initialize label
54 f.label.initialize(text, StyleDefault().Font)
55 f.Panel.Add(&f.label)
56
57 // Create icon
58 f.icon.initialize("", StyleDefault().FontIcon)
59 f.icon.SetFontSize(StyleDefault().Label.PointSize * 1.3)
60 f.Panel.Add(&f.icon)
61
62 // Setup content panel
63 f.contentPanel = contentPanel
64 contentPanel.GetPanel().bounded = false
65 contentPanel.GetPanel().zLayerDelta = 1
66 contentPanel.GetPanel().SetVisible(false)
67 f.Panel.Add(f.contentPanel)
68
69 // Set event callbacks
70 f.Panel.Subscribe(OnMouseDown, f.onMouse)
71 f.Panel.Subscribe(OnCursorEnter, f.onCursor)
72 f.Panel.Subscribe(OnCursorLeave, f.onCursor)
73
74 f.Subscribe(OnMouseDownOut, func(s string, i interface{}) {
75 // Hide list when clicked out
76 if f.contentPanel.Visible() {
77 f.contentPanel.SetVisible(false)
78 }
79 })
80
81 f.contentPanel.Subscribe(OnCursorEnter, func(evname string, ev interface{}) {
82 f.Dispatch(OnCursorLeave, ev)
83 })
84 f.contentPanel.Subscribe(OnCursorLeave, func(evname string, ev interface{}) {
85 f.Dispatch(OnCursorEnter, ev)
86 })
87
88 f.alignRight = true
89 f.update()
90 f.recalc()
91}
92
93// SetStyles set the folder styles overriding the default style.
94func (f *Folder) SetStyles(fs *FolderStyles) {

Callers 1

NewFolderFunction · 0.45

Calls 11

updateMethod · 0.95
recalcMethod · 0.95
StyleDefaultFunction · 0.85
GetPanelMethod · 0.65
SetVisibleMethod · 0.65
SubscribeMethod · 0.65
VisibleMethod · 0.65
DispatchMethod · 0.65
initializeMethod · 0.45
AddMethod · 0.45
SetFontSizeMethod · 0.45

Tested by

no test coverage detected