newTab creates and returns a pointer to a new Tab
(text string, tb *TabBar, styles *TabStyles)
| 400 | |
| 401 | // newTab creates and returns a pointer to a new Tab |
| 402 | func 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 |
| 430 | func (tab *Tab) onCursor(evname string, ev interface{}) { |
no test coverage detected