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] ## [Unreleased]
## 2019/02/23 ## 2019/02/28
### Added
- Add `ColumnResizer` to table which allows for custom column sizing
- Add widget padding
### Changed ### Changed
- Change various widget field names - Change various widget field names
- s/TextParse/ParseStyles - s/`TextParse`/`ParseStyles`
- Remove AddColorMap in place of modifying StyleParserColorMap directly - Remove `AddColorMap` in place of modifying `StyleParserColorMap` directly
## 2019/01/31 ## 2019/01/31

View File

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