Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a3bb4098fb | |||
c30ac90577 | |||
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 () {
|
||||
|
@ -12,9 +12,9 @@ type Pegboard struct {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
if layout == nil { layout = layouts.FlowHorizontal }
|
||||
if layout == nil { layout = layouts.FlowVertical }
|
||||
pegboard := &Pegboard { }
|
||||
pegboard.init(layout, children...)
|
||||
pegboard.box.SetRole(tomo.R("objects", "Pegboard"))
|
||||
|
4
root.go
4
root.go
@ -11,8 +11,8 @@ type Root struct {
|
||||
}
|
||||
|
||||
// NewRoot creates a new container.
|
||||
func NewRoot (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
this := &Container { }
|
||||
func NewRoot (layout tomo.Layout, children ...tomo.Object) *Root {
|
||||
this := &Root { }
|
||||
this.init(layout, children...)
|
||||
this.box.SetRole(tomo.R("objects", "Root"))
|
||||
this.box.SetTag("outer", true)
|
||||
|
Loading…
Reference in New Issue
Block a user