Add PageWrapper sub-component to Notebook
This commit is contained in:
parent
ce08487eff
commit
7628903e59
20
notebook.go
20
notebook.go
@ -14,6 +14,7 @@ var _ tomo.Object = new(Notebook)
|
||||
// - TabSpacer sits at either end of the tab row, bookending the list of tabs.
|
||||
// - Tab appears in the tab row for each tab in the notebook. The user can
|
||||
// click on the tab to switch to it.
|
||||
// - PageWrapper sits underneath the TabRow and contains the active page.
|
||||
//
|
||||
// TabSpacer tags:
|
||||
// - [left] The spacer is on the left.
|
||||
@ -27,6 +28,7 @@ type Notebook struct {
|
||||
leftSpacer tomo.Box
|
||||
rightSpacer tomo.Box
|
||||
tabsRow tomo.ContainerBox
|
||||
pageWrapper tomo.ContainerBox
|
||||
active string
|
||||
pages []*page
|
||||
}
|
||||
@ -39,10 +41,6 @@ func NewNotebook () *Notebook {
|
||||
notebook.box.SetRole(tomo.R("objects", "Notebook"))
|
||||
notebook.box.SetAttr(tomo.ALayout(layouts.Column { false, true }))
|
||||
|
||||
notebook.tabsRow = tomo.NewContainerBox()
|
||||
notebook.tabsRow.SetRole(tomo.R("objects", "TabRow"))
|
||||
notebook.box.Add(notebook.tabsRow)
|
||||
|
||||
notebook.leftSpacer = tomo.NewBox()
|
||||
notebook.leftSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
||||
notebook.leftSpacer.SetTag("left", true)
|
||||
@ -50,6 +48,15 @@ func NewNotebook () *Notebook {
|
||||
notebook.rightSpacer.SetRole(tomo.R("objects", "TabSpacer"))
|
||||
notebook.rightSpacer.SetTag("right", true)
|
||||
|
||||
notebook.tabsRow = tomo.NewContainerBox()
|
||||
notebook.tabsRow.SetRole(tomo.R("objects", "TabRow"))
|
||||
notebook.box.Add(notebook.tabsRow)
|
||||
|
||||
notebook.pageWrapper = tomo.NewContainerBox()
|
||||
notebook.pageWrapper.SetRole(tomo.R("objects", "PageWrapper"))
|
||||
notebook.pageWrapper.SetAttr(tomo.ALayout(layouts.Column { true }))
|
||||
notebook.box.Add(notebook.pageWrapper)
|
||||
|
||||
notebook.Clear()
|
||||
notebook.setTabRowLayout()
|
||||
return notebook
|
||||
@ -64,11 +71,11 @@ func (this *Notebook) GetBox () tomo.Box {
|
||||
func (this *Notebook) Activate (name string) {
|
||||
if _, tab := this.findTab(this.active); tab != nil {
|
||||
tab.setActive(false)
|
||||
this.box.Remove(tab.root)
|
||||
this.pageWrapper.Remove(tab.root)
|
||||
}
|
||||
if _, tab := this.findTab(name); tab != nil {
|
||||
tab.setActive(true)
|
||||
this.box.Add(tab.root)
|
||||
this.pageWrapper.Add(tab.root)
|
||||
} else {
|
||||
name = ""
|
||||
}
|
||||
@ -129,6 +136,7 @@ func (this *Notebook) Clear () {
|
||||
this.tabsRow.Clear()
|
||||
this.tabsRow.Add(this.leftSpacer)
|
||||
this.tabsRow.Add(this.rightSpacer)
|
||||
this.pageWrapper.Clear()
|
||||
}
|
||||
|
||||
func (this *Notebook) setTabRowLayout () {
|
||||
|
Loading…
Reference in New Issue
Block a user