|
|
@ -48,15 +48,21 @@ func (p *Pages) SetChangedFunc(handler func()) *Pages {
|
|
|
|
return p
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AddPage adds a new page with the given name and primitive. Leaving the name
|
|
|
|
// AddPage adds a new page with the given name and primitive. If there was
|
|
|
|
// empty or using the same name for multiple items may cause conflicts in other
|
|
|
|
// previously a page with the same name, it is overwritten. Leaving the name
|
|
|
|
// functions.
|
|
|
|
// empty may cause conflicts in other functions.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Visible pages will be drawn in the order they were added (unless that order
|
|
|
|
// Visible pages will be drawn in the order they were added (unless that order
|
|
|
|
// was changed in one of the other functions). If "resize" is set to true, the
|
|
|
|
// was changed in one of the other functions). If "resize" is set to true, the
|
|
|
|
// primitive will be set to the size available to the Pages primitive whenever
|
|
|
|
// primitive will be set to the size available to the Pages primitive whenever
|
|
|
|
// the pages are drawn.
|
|
|
|
// the pages are drawn.
|
|
|
|
func (p *Pages) AddPage(name string, item Primitive, resize, visible bool) *Pages {
|
|
|
|
func (p *Pages) AddPage(name string, item Primitive, resize, visible bool) *Pages {
|
|
|
|
|
|
|
|
for index, pg := range p.pages {
|
|
|
|
|
|
|
|
if pg.Name == name {
|
|
|
|
|
|
|
|
p.pages = append(p.pages[:index], p.pages[index+1:]...)
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
p.pages = append(p.pages, &page{Item: item, Name: name, Resize: resize, Visible: visible})
|
|
|
|
p.pages = append(p.pages, &page{Item: item, Name: name, Resize: resize, Visible: visible})
|
|
|
|
if p.changed != nil {
|
|
|
|
if p.changed != nil {
|
|
|
|
p.changed()
|
|
|
|
p.changed()
|
|
|
@ -65,6 +71,14 @@ func (p *Pages) AddPage(name string, item Primitive, resize, visible bool) *Page
|
|
|
|
return p
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AddAndSwitchToPage calls AddPage(), then SwitchToPage() on that newly added
|
|
|
|
|
|
|
|
// page.
|
|
|
|
|
|
|
|
func (p *Pages) AddAndSwitchToPage(name string, item Primitive, resize bool) *Pages {
|
|
|
|
|
|
|
|
p.AddPage(name, item, resize, true)
|
|
|
|
|
|
|
|
p.SwitchToPage(name)
|
|
|
|
|
|
|
|
return p
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RemovePage removes the page with the given name.
|
|
|
|
// RemovePage removes the page with the given name.
|
|
|
|
func (p *Pages) RemovePage(name string) *Pages {
|
|
|
|
func (p *Pages) RemovePage(name string) *Pages {
|
|
|
|
for index, page := range p.pages {
|
|
|
|
for index, page := range p.pages {
|
|
|
|