Compare commits

..

3 Commits

3 changed files with 18 additions and 10 deletions

View File

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

View File

@ -12,9 +12,9 @@ type Pegboard struct {
} }
// NewPegboard creates a new pegboard. If the provided layout is nil, it will // NewPegboard creates a new pegboard. If the provided layout is nil, it will
// use a FlowHorizontal layout. // use a FlowVertical layout.
func NewPegboard (layout tomo.Layout, children ...tomo.Object) *Pegboard { func NewPegboard (layout tomo.Layout, children ...tomo.Object) *Pegboard {
if layout == nil { layout = layouts.FlowHorizontal } if layout == nil { layout = layouts.FlowVertical }
pegboard := &Pegboard { } pegboard := &Pegboard { }
pegboard.init(layout, children...) pegboard.init(layout, children...)
pegboard.box.SetRole(tomo.R("objects", "Pegboard")) pegboard.box.SetRole(tomo.R("objects", "Pegboard"))

View File

@ -11,8 +11,8 @@ type Root struct {
} }
// NewRoot creates a new container. // NewRoot creates a new container.
func NewRoot (layout tomo.Layout, children ...tomo.Object) *Container { func NewRoot (layout tomo.Layout, children ...tomo.Object) *Root {
this := &Container { } this := &Root { }
this.init(layout, children...) this.init(layout, children...)
this.box.SetRole(tomo.R("objects", "Root")) this.box.SetRole(tomo.R("objects", "Root"))
this.box.SetTag("outer", true) this.box.SetTag("outer", true)