From 29d673af0ce2281f8b517d1bd14aab453b8fc8ef Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 24 Jun 2021 18:53:35 +0200 Subject: [PATCH] Added SetListStyles() to DropDown. Resolves #621 --- dropdown.go | 11 +++++++++++ grid.go | 6 ------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dropdown.go b/dropdown.go index 3813cbf5..65995ded 100644 --- a/dropdown.go +++ b/dropdown.go @@ -200,6 +200,17 @@ func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown { return d } +// SetListStyles sets the styles of the items in the drop-down list (unselected +// as well as selected items). Style attributes are currently ignored but may be +// used in the future. +func (d *DropDown) SetListStyles(unselected, selected tcell.Style) *DropDown { + fg, bg, _ := unselected.Decompose() + d.list.SetMainTextColor(fg).SetBackgroundColor(bg) + fg, bg, _ = selected.Decompose() + d.list.SetSelectedTextColor(fg).SetSelectedBackgroundColor(bg) + return d +} + // SetFormAttributes sets attributes shared by all form items. func (d *DropDown) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem { d.labelWidth = labelWidth diff --git a/grid.go b/grid.go index 5825df63..60417f37 100644 --- a/grid.go +++ b/grid.go @@ -412,9 +412,6 @@ func (g *Grid) Draw(screen tcell.Screen) { row = g.rows[index] } if row > 0 { - if row < g.minHeight { - row = g.minHeight - } continue // Not proportional. We already know the width. } else if row == 0 { row = 1 @@ -435,9 +432,6 @@ func (g *Grid) Draw(screen tcell.Screen) { column = g.columns[index] } if column > 0 { - if column < g.minWidth { - column = g.minWidth - } continue // Not proportional. We already know the height. } else if column == 0 { column = 1