TabbedContainer no longer embeds tomo.ContainerBox
This commit is contained in:
parent
889c691c40
commit
1a2449d2b7
@ -6,8 +6,8 @@ import "git.tebibyte.media/tomo/objects/layouts"
|
|||||||
|
|
||||||
var _ tomo.Object = new(TabbedContainer)
|
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 {
|
type TabbedContainer struct {
|
||||||
box tomo.ContainerBox
|
box tomo.ContainerBox
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ type TabbedContainer struct {
|
|||||||
tabs []*tab
|
tabs []*tab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTabbedContainer creates a new tabbed container.
|
||||||
func NewTabbedContainer () *TabbedContainer {
|
func NewTabbedContainer () *TabbedContainer {
|
||||||
tabbedContainer := &TabbedContainer {
|
tabbedContainer := &TabbedContainer {
|
||||||
box: tomo.NewContainerBox(),
|
box: tomo.NewContainerBox(),
|
||||||
@ -46,6 +47,7 @@ func (this *TabbedContainer) GetBox () tomo.Box {
|
|||||||
return this.box
|
return this.box
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activate switches to a named tab.
|
||||||
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)
|
||||||
@ -60,6 +62,7 @@ func (this *TabbedContainer) Activate (name string) {
|
|||||||
this.active = name
|
this.active = name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTab adds an object as a tab with the specified name.
|
||||||
func (this *TabbedContainer) AddTab (name string, root tomo.Object) {
|
func (this *TabbedContainer) AddTab (name string, root tomo.Object) {
|
||||||
tab := &tab {
|
tab := &tab {
|
||||||
TextBox: tomo.NewTextBox(),
|
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) {
|
func (this *TabbedContainer) RemoveTab (name string) {
|
||||||
index, tab := this.findTab(name)
|
index, tab := this.findTab(name)
|
||||||
if index < 0 { return }
|
if index < 0 { return }
|
||||||
@ -106,6 +110,7 @@ func (this *TabbedContainer) RemoveTab (name string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearTabs removes all tabs.
|
||||||
func (this *TabbedContainer) ClearTabs () {
|
func (this *TabbedContainer) ClearTabs () {
|
||||||
this.tabs = nil
|
this.tabs = nil
|
||||||
this.tabsRow.Clear()
|
this.tabsRow.Clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user