fix up boxes to actually work when moved around the screen

This commit is contained in:
2021-07-03 21:25:32 -04:00
parent 6cd94df521
commit 40b4cd3668
3 changed files with 217 additions and 10 deletions

View File

@@ -59,10 +59,10 @@ func (c *Container) SetSize(x, y, h, w int) {
if c.layoutMethod == LayoutVerticalEven {
num := len(c.contents)
for r := range c.contents {
x := c.x
y := c.y + (num * (r + 1))
h := c.h / num
w := c.w
h := c.h / num
x := c.x
y := c.y + (h * r)
c.contents[r].Container.SetSize(x, y, h, w)
}
} else if c.layoutMethod == LayoutHorizontalEven {
@@ -124,18 +124,18 @@ func (b *Box) SetSize(x, y, h, w int) {
}
func (b *Box) Draw(s tcell.Screen) {
for m := 1; m < b.w-1; m++ {
for m := b.x + 1; m < b.x+b.w-1; m++ {
s.SetContent(m, b.y, tcell.RuneHLine, nil, tcell.StyleDefault)
s.SetContent(m, b.h-1, tcell.RuneHLine, nil, tcell.StyleDefault)
s.SetContent(m, b.y+b.h-1, tcell.RuneHLine, nil, tcell.StyleDefault)
}
for m := 1; m < b.h-1; m++ {
for m := b.y + 1; m < b.y+b.h-1; m++ {
s.SetContent(b.x, m, tcell.RuneVLine, nil, tcell.StyleDefault)
s.SetContent(b.w-1, m, tcell.RuneVLine, nil, tcell.StyleDefault)
s.SetContent(b.x+b.w-1, m, tcell.RuneVLine, nil, tcell.StyleDefault)
}
s.SetContent(b.x, b.y, tcell.RuneULCorner, nil, tcell.StyleDefault)
s.SetContent(b.w-1, b.y, tcell.RuneURCorner, nil, tcell.StyleDefault)
s.SetContent(b.x, b.h-1, tcell.RuneLLCorner, nil, tcell.StyleDefault)
s.SetContent(b.w-1, b.h-1, tcell.RuneLRCorner, nil, tcell.StyleDefault)
s.SetContent(b.x+b.w-1, b.y, tcell.RuneURCorner, nil, tcell.StyleDefault)
s.SetContent(b.x, b.y+b.h-1, tcell.RuneLLCorner, nil, tcell.StyleDefault)
s.SetContent(b.x+b.w-1, b.y+b.h-1, tcell.RuneLRCorner, nil, tcell.StyleDefault)
if b.title != nil {
b.title.Draw(s)
@@ -215,6 +215,9 @@ func (p *PaddedText) SetSize(x, y, _, _ int) {
}
func (p *PaddedText) Draw(s tcell.Screen) {
if p.text == "" {
return
}
t := p.x
s.SetContent(t, p.y, ' ', nil, tcell.StyleDefault)
t++