|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
type page struct {
|
|
|
|
type page struct {
|
|
|
|
Name string // The page's name.
|
|
|
|
Name string // The page's name.
|
|
|
|
Item Primitive // The page's primitive.
|
|
|
|
Item Primitive // The page's primitive.
|
|
|
|
|
|
|
|
Resize bool // Whether or not to resize the page when it is drawn.
|
|
|
|
Visible bool // Whether or not this page is visible.
|
|
|
|
Visible bool // Whether or not this page is visible.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -50,9 +51,11 @@ func (p *Pages) SetChangedFunc(handler func()) *Pages {
|
|
|
|
// functions.
|
|
|
|
// 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).
|
|
|
|
// was changed in one of the other functions). If "resize" is set to true, the
|
|
|
|
func (p *Pages) AddPage(name string, item Primitive, visible bool) *Pages {
|
|
|
|
// primitive will be set to the size available to the Pages primitive whenever
|
|
|
|
p.pages = append(p.pages, &page{Item: item, Name: name, Visible: visible})
|
|
|
|
// the pages are drawn.
|
|
|
|
|
|
|
|
func (p *Pages) AddPage(name string, item Primitive, resize, visible bool) *Pages {
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -207,6 +210,10 @@ func (p *Pages) Draw(screen tcell.Screen) {
|
|
|
|
if !page.Visible {
|
|
|
|
if !page.Visible {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if page.Resize {
|
|
|
|
|
|
|
|
x, y, width, height := p.GetInnerRect()
|
|
|
|
|
|
|
|
page.Item.SetRect(x, y, width, height)
|
|
|
|
|
|
|
|
}
|
|
|
|
page.Item.Draw(screen)
|
|
|
|
page.Item.Draw(screen)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|