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/tomo/input"
|
||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
|
|
||||||
|
var _ tomo.Object = new(TabbedContainer)
|
||||||
|
|
||||||
|
// TODO doc this!
|
||||||
|
|
||||||
type TabbedContainer struct {
|
type TabbedContainer struct {
|
||||||
tomo.ContainerBox
|
box tomo.ContainerBox
|
||||||
|
|
||||||
leftSpacer tomo.Box
|
leftSpacer tomo.Box
|
||||||
rightSpacer tomo.Box
|
rightSpacer tomo.Box
|
||||||
@ -15,36 +19,41 @@ type TabbedContainer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTabbedContainer () *TabbedContainer {
|
func NewTabbedContainer () *TabbedContainer {
|
||||||
container := &TabbedContainer {
|
tabbedContainer := &TabbedContainer {
|
||||||
ContainerBox: tomo.NewContainerBox(),
|
box: tomo.NewContainerBox(),
|
||||||
}
|
}
|
||||||
container.SetRole(tomo.R("objects", "TabbedContainer"))
|
tabbedContainer.box.SetRole(tomo.R("objects", "TabbedContainer"))
|
||||||
container.SetAttr(tomo.ALayout(layouts.Column { false, true }))
|
tabbedContainer.box.SetAttr(tomo.ALayout(layouts.Column { false, true }))
|
||||||
|
|
||||||
container.tabsRow = tomo.NewContainerBox()
|
tabbedContainer.tabsRow = tomo.NewContainerBox()
|
||||||
container.tabsRow.SetRole(tomo.R("objects", "TabRow"))
|
tabbedContainer.tabsRow.SetRole(tomo.R("objects", "TabRow"))
|
||||||
container.Add(container.tabsRow)
|
tabbedContainer.box.Add(tabbedContainer.tabsRow)
|
||||||
|
|
||||||
container.leftSpacer = tomo.NewBox()
|
tabbedContainer.leftSpacer = tomo.NewBox()
|
||||||
container.leftSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
tabbedContainer.leftSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
||||||
container.leftSpacer.SetTag("left", true)
|
tabbedContainer.leftSpacer.SetTag("left", true)
|
||||||
container.rightSpacer = tomo.NewBox()
|
tabbedContainer.rightSpacer = tomo.NewBox()
|
||||||
container.rightSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
tabbedContainer.rightSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
||||||
container.rightSpacer.SetTag("left", true)
|
tabbedContainer.rightSpacer.SetTag("left", true)
|
||||||
|
|
||||||
container.ClearTabs()
|
tabbedContainer.ClearTabs()
|
||||||
container.setTabRowLayout()
|
tabbedContainer.setTabRowLayout()
|
||||||
return container
|
return tabbedContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBox returns the underlying box.
|
||||||
|
func (this *TabbedContainer) GetBox () tomo.Box {
|
||||||
|
return this.box
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TabbedContainer) Activate (name string) {
|
func (this *TabbedContainer) Activate (name string) {
|
||||||
if _, tab := this.findTab(this.active); tab != nil {
|
if _, tab := this.findTab(this.active); tab != nil {
|
||||||
tab.setActive(false)
|
tab.setActive(false)
|
||||||
this.Remove(tab.root)
|
this.box.Remove(tab.root)
|
||||||
}
|
}
|
||||||
if _, tab := this.findTab(name); tab != nil {
|
if _, tab := this.findTab(name); tab != nil {
|
||||||
tab.setActive(true)
|
tab.setActive(true)
|
||||||
this.Add(tab.root)
|
this.box.Add(tab.root)
|
||||||
} else {
|
} else {
|
||||||
name = ""
|
name = ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user