Add widget padding

This commit is contained in:
Caleb Bassi 2019-02-28 18:47:54 -08:00
parent 9735f6dda8
commit 9513fa11a1
2 changed files with 21 additions and 11 deletions

View File

@ -6,13 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## 2019/02/23
## 2019/02/28
### Added
- Add `ColumnResizer` to table which allows for custom column sizing
- Add widget padding
### Changed
- Change various widget field names
- s/TextParse/ParseStyles
- Remove AddColorMap in place of modifying StyleParserColorMap directly
- s/`TextParse`/`ParseStyles`
- Remove `AddColorMap` in place of modifying `StyleParserColorMap` directly
## 2019/01/31

View File

@ -13,12 +13,12 @@ import (
// It implements all 3 of the methods needed for the `Drawable` interface.
// Custom widgets will override the Draw method.
type Block struct {
Border bool
BorderStyle Style
BorderLeft bool
BorderRight bool
BorderTop bool
BorderBottom bool
Border bool
BorderStyle Style
BorderLeft, BorderRight, BorderTop, BorderBottom bool
PaddingLeft, PaddingRight, PaddingTop, PaddingBottom int
image.Rectangle
Inner image.Rectangle
@ -76,7 +76,7 @@ func (self *Block) drawBorder(buf *Buffer) {
// Draw implements the Drawable interface.
func (self *Block) Draw(buf *Buffer) {
if self.Border {
self.drawBorder(buf)
self.drawBorder(buf)
}
buf.SetString(
self.Title,
@ -88,7 +88,12 @@ func (self *Block) Draw(buf *Buffer) {
// SetRect implements the Drawable interface.
func (self *Block) SetRect(x1, y1, x2, y2 int) {
self.Rectangle = image.Rect(x1, y1, x2, y2)
self.Inner = image.Rect(self.Min.X+1, self.Min.Y+1, self.Max.X-1, self.Max.Y-1)
self.Inner = image.Rect(
self.Min.X+1+self.PaddingLeft,
self.Min.Y+1+self.PaddingTop,
self.Max.X-1+self.PaddingRight,
self.Max.Y-1+self.PaddingBottom,
)
}
// GetRect implements the Drawable interface.