|
|
|
@ -88,7 +88,8 @@ func (b *Box) GetRect() (int, int, int, int) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetInnerRect returns the position of the inner rectangle (x, y, width,
|
|
|
|
|
// height), without the border and without any padding.
|
|
|
|
|
// height), without the border and without any padding. Width and height values
|
|
|
|
|
// will clamp to 0 and thus never be negative.
|
|
|
|
|
func (b *Box) GetInnerRect() (int, int, int, int) {
|
|
|
|
|
if b.innerX >= 0 {
|
|
|
|
|
return b.innerX, b.innerY, b.innerWidth, b.innerHeight
|
|
|
|
@ -100,10 +101,17 @@ func (b *Box) GetInnerRect() (int, int, int, int) {
|
|
|
|
|
width -= 2
|
|
|
|
|
height -= 2
|
|
|
|
|
}
|
|
|
|
|
return x + b.paddingLeft,
|
|
|
|
|
y + b.paddingTop,
|
|
|
|
|
width - b.paddingLeft - b.paddingRight,
|
|
|
|
|
height - b.paddingTop - b.paddingBottom
|
|
|
|
|
x, y, width, height = x+b.paddingLeft,
|
|
|
|
|
y+b.paddingTop,
|
|
|
|
|
width-b.paddingLeft-b.paddingRight,
|
|
|
|
|
height-b.paddingTop-b.paddingBottom
|
|
|
|
|
if width < 0 {
|
|
|
|
|
width = 0
|
|
|
|
|
}
|
|
|
|
|
if height < 0 {
|
|
|
|
|
height = 0
|
|
|
|
|
}
|
|
|
|
|
return x, y, width, height
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetRect sets a new position of the primitive. Note that this has no effect
|
|
|
|
@ -318,6 +326,12 @@ func (b *Box) Draw(screen tcell.Screen) {
|
|
|
|
|
b.innerHeight += b.innerY
|
|
|
|
|
b.innerY = 0
|
|
|
|
|
}
|
|
|
|
|
if b.innerWidth < 0 {
|
|
|
|
|
b.innerWidth = 0
|
|
|
|
|
}
|
|
|
|
|
if b.innerHeight < 0 {
|
|
|
|
|
b.innerHeight = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Focus is called when this primitive receives focus.
|
|
|
|
|