TabbedContainer no longer embeds tomo.ContainerBox
This commit is contained in:
parent
32eae0bcca
commit
889c691c40
@ -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 = ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user