TabbedContainer no longer embeds tomo.ContainerBox

This commit is contained in:
Sasha Koshka 2024-08-24 22:26:00 -04:00
parent 889c691c40
commit 1a2449d2b7

View File

@ -6,8 +6,8 @@ import "git.tebibyte.media/tomo/objects/layouts"
var _ tomo.Object = new(TabbedContainer)
// TODO doc this!
// TabbedContainer holds multiple objects, each in their own tab. The user can
// click the tab bar at the top to choose which one is activated.
type TabbedContainer struct {
box tomo.ContainerBox
@ -18,6 +18,7 @@ type TabbedContainer struct {
tabs []*tab
}
// NewTabbedContainer creates a new tabbed container.
func NewTabbedContainer () *TabbedContainer {
tabbedContainer := &TabbedContainer {
box: tomo.NewContainerBox(),
@ -46,6 +47,7 @@ func (this *TabbedContainer) GetBox () tomo.Box {
return this.box
}
// Activate switches to a named tab.
func (this *TabbedContainer) Activate (name string) {
if _, tab := this.findTab(this.active); tab != nil {
tab.setActive(false)
@ -60,6 +62,7 @@ func (this *TabbedContainer) Activate (name string) {
this.active = name
}
// AddTab adds an object as a tab with the specified name.
func (this *TabbedContainer) AddTab (name string, root tomo.Object) {
tab := &tab {
TextBox: tomo.NewTextBox(),
@ -88,6 +91,7 @@ func (this *TabbedContainer) AddTab (name string, root tomo.Object) {
}
}
// RemoveTab removes the named tab.
func (this *TabbedContainer) RemoveTab (name string) {
index, tab := this.findTab(name)
if index < 0 { return }
@ -106,6 +110,7 @@ func (this *TabbedContainer) RemoveTab (name string) {
}
}
// ClearTabs removes all tabs.
func (this *TabbedContainer) ClearTabs () {
this.tabs = nil
this.tabsRow.Clear()