MCPcopy Create free account
hub / github.com/g3n/engine / newTab

Function newTab

gui/tabbar.go:402–427  ·  view source on GitHub ↗

newTab creates and returns a pointer to a new Tab

(text string, tb *TabBar, styles *TabStyles)

Source from the content-addressed store, hash-verified

400
401// newTab creates and returns a pointer to a new Tab
402func newTab(text string, tb *TabBar, styles *TabStyles) *Tab {
403
404 tab := new(Tab)
405 tab.tb = tb
406 tab.styles = styles
407 // Setup the header panel
408 tab.header.Initialize(&tab.header, 0, 0)
409 tab.label = NewLabel(text)
410 tab.iconClose = NewIcon(styles.IconClose)
411 tab.header.Add(tab.label)
412 tab.header.Add(tab.iconClose)
413 // Creates the bottom panel
414 tab.bottom.Initialize(&tab.bottom, 0, 0)
415 tab.bottom.SetBounded(false)
416 tab.bottom.SetColor4(&tab.styles.Selected.BgColor)
417 tab.header.Add(&tab.bottom)
418
419 // Subscribe to header panel events
420 tab.header.Subscribe(OnCursorEnter, tab.onCursor)
421 tab.header.Subscribe(OnCursorLeave, tab.onCursor)
422 tab.header.Subscribe(OnMouseDown, tab.onMouseHeader)
423 tab.iconClose.Subscribe(OnMouseDown, tab.onMouseIcon)
424
425 tab.update()
426 return tab
427}
428
429// onCursor process subscribed cursor events over the tab header
430func (tab *Tab) onCursor(evname string, ev interface{}) {

Callers 1

InsertTabMethod · 0.85

Calls 8

NewLabelFunction · 0.85
NewIconFunction · 0.85
SetBoundedMethod · 0.80
SubscribeMethod · 0.65
InitializeMethod · 0.45
AddMethod · 0.45
SetColor4Method · 0.45
updateMethod · 0.45

Tested by

no test coverage detected