From 889c691c40cba6746ef846215b7bca3a5d160abe Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 24 Aug 2024 22:15:21 -0400 Subject: [PATCH] TabbedContainer no longer embeds tomo.ContainerBox --- tabbedcontainer.go | 47 +++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/tabbedcontainer.go b/tabbedcontainer.go index d1f2cd0..784ce69 100644 --- a/tabbedcontainer.go +++ b/tabbedcontainer.go @@ -4,8 +4,12 @@ import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo/input" import "git.tebibyte.media/tomo/objects/layouts" +var _ tomo.Object = new(TabbedContainer) + +// TODO doc this! + type TabbedContainer struct { - tomo.ContainerBox + box tomo.ContainerBox leftSpacer tomo.Box rightSpacer tomo.Box @@ -15,36 +19,41 @@ type TabbedContainer struct { } func NewTabbedContainer () *TabbedContainer { - container := &TabbedContainer { - ContainerBox: tomo.NewContainerBox(), + tabbedContainer := &TabbedContainer { + box: tomo.NewContainerBox(), } - container.SetRole(tomo.R("objects", "TabbedContainer")) - container.SetAttr(tomo.ALayout(layouts.Column { false, true })) + tabbedContainer.box.SetRole(tomo.R("objects", "TabbedContainer")) + tabbedContainer.box.SetAttr(tomo.ALayout(layouts.Column { false, true })) - container.tabsRow = tomo.NewContainerBox() - container.tabsRow.SetRole(tomo.R("objects", "TabRow")) - container.Add(container.tabsRow) + tabbedContainer.tabsRow = tomo.NewContainerBox() + tabbedContainer.tabsRow.SetRole(tomo.R("objects", "TabRow")) + tabbedContainer.box.Add(tabbedContainer.tabsRow) - container.leftSpacer = tomo.NewBox() - container.leftSpacer.SetRole(tomo.R("objects", "TabSpacer")) - container.leftSpacer.SetTag("left", true) - container.rightSpacer = tomo.NewBox() - container.rightSpacer.SetRole(tomo.R("objects", "TabSpacer")) - container.rightSpacer.SetTag("left", true) + tabbedContainer.leftSpacer = tomo.NewBox() + tabbedContainer.leftSpacer.SetRole(tomo.R("objects", "TabSpacer")) + tabbedContainer.leftSpacer.SetTag("left", true) + tabbedContainer.rightSpacer = tomo.NewBox() + tabbedContainer.rightSpacer.SetRole(tomo.R("objects", "TabSpacer")) + tabbedContainer.rightSpacer.SetTag("left", true) - container.ClearTabs() - container.setTabRowLayout() - return container + tabbedContainer.ClearTabs() + tabbedContainer.setTabRowLayout() + return tabbedContainer +} + +// GetBox returns the underlying box. +func (this *TabbedContainer) GetBox () tomo.Box { + return this.box } func (this *TabbedContainer) Activate (name string) { if _, tab := this.findTab(this.active); tab != nil { tab.setActive(false) - this.Remove(tab.root) + this.box.Remove(tab.root) } if _, tab := this.findTab(name); tab != nil { tab.setActive(true) - this.Add(tab.root) + this.box.Add(tab.root) } else { name = "" }