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)
| 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. |
| 48 | func (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. |
| 94 | func (f *Folder) SetStyles(fs *FolderStyles) { |
no test coverage detected