forked from jojomi/gonsole
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpanel.go
More file actions
34 lines (28 loc) · 733 Bytes
/
Copy pathpanel.go
File metadata and controls
34 lines (28 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gonsole
type Panel struct {
BaseControl
BaseContainer
}
func NewPanel(win *Window, parent Container, id string) *Panel {
panel := &Panel{}
panel.BaseControl.Init(win, parent, id, "panel")
parent.AddControl(panel)
return panel
}
func (p *Panel) Repaint() {
if !p.Dirty() {
return
}
p.BaseControl.Repaint()
p.BaseContainer.RepaintChildren()
// draw title
if p.Title() != "" {
if p.BorderType() == LineNone {
p.SetPadding(p.Padding().Plus(Sides{Top: 1}))
}
t := p.Theme()
fg, bg := t.ColorTermbox("fg"), t.ColorTermbox("bg")
DrawTextSimple(" "+p.Title()+" ", false, p.BorderBox().Minus(Sides{Left: 2}), fg, bg)
}
// content area (ContainerControl already takes care of drawing the children)
}