diff --git a/component/component.go b/component/component.go index f8e5ea0..f3d6b33 100644 --- a/component/component.go +++ b/component/component.go @@ -5,10 +5,6 @@ import ( ui "github.com/sqshq/termui" ) -const ( - minDimension = 1 -) - type Component struct { Type config.ComponentType Drawable ui.Drawable @@ -31,12 +27,6 @@ func (c *Component) Resize(x, y int) { } func (c *Component) normalize() { - if c.Size.X < minDimension { - c.Size.X = minDimension - } - if c.Size.Y < minDimension { - c.Size.Y = minDimension - } if c.Position.X < 0 { c.Position.X = 0 } diff --git a/component/layout.go b/component/layout.go index d22b94c..b2e3322 100644 --- a/component/layout.go +++ b/component/layout.go @@ -33,6 +33,7 @@ const ( const ( columnsCount = 80 rowsCount = 40 + minDimension = 3 statusbarHeight = 1 ) @@ -253,6 +254,14 @@ func (l *Layout) Draw(buffer *ui.Buffer) { x2 := x1 + math.Floor(float64(component.Size.X))*columnWidth y2 := y1 + math.Floor(float64(component.Size.Y))*rowHeight + if x2-x1 < minDimension { + x2 = x1 + minDimension + } + + if y2-y1 < minDimension { + y2 = y1 + minDimension + } + component.Drawable.SetRect(int(x1), int(y1), int(x2), int(y2)) component.Drawable.Draw(buffer) }