diff --git a/CHANGELOG b/CHANGELOG index d1d339e..e760041 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ v1.5.6 (WIP) - Draw additional accents when rendering a list divider - Update List, Table and TreeView to not handle Tab or Backtab - Allow specifying TabbedPanels switcher height +- Change default colors (focused buttons and fields are now blue) - When resetting color with "-" tag, set background color to primitive background color, rather than the terminal background color diff --git a/button.go b/button.go index 4ba6303..9587808 100644 --- a/button.go +++ b/button.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/gdamore/tcell/v2" + "github.com/lucasb-eyer/go-colorful" ) // Button is labeled box that triggers an action when selected. @@ -35,14 +36,25 @@ type Button struct { // NewButton returns a new input field. func NewButton(label string) *Button { box := NewBox() - box.SetBackgroundColor(Styles.ContrastBackgroundColor) box.SetRect(0, 0, TaggedStringWidth(label)+4, 1) + bg := Styles.PrimaryTextColor + if bg == tcell.ColorDefault { + r, g, b := Styles.InverseTextColor.RGB() + c := colorful.Color{R: float64(r) / 255, G: float64(g) / 255, B: float64(b) / 255} + _, _, li := c.Hcl() + if li < .5 { + bg = tcell.ColorWhite.TrueColor() + } else { + bg = tcell.ColorBlack.TrueColor() + } + } + box.SetBackgroundColor(bg) return &Button{ Box: box, label: []byte(label), - labelColor: Styles.PrimaryTextColor, - labelColorFocused: Styles.InverseTextColor, - backgroundColorFocused: Styles.PrimaryTextColor, + labelColor: Styles.InverseTextColor, + labelColorFocused: Styles.PrimaryTextColor, + backgroundColorFocused: Styles.ContrastBackgroundColor, } } diff --git a/form.go b/form.go index 71109d1..d8580b3 100644 --- a/form.go +++ b/form.go @@ -151,15 +151,15 @@ func NewForm() *Form { Box: box, itemPadding: 1, labelColor: Styles.SecondaryTextColor, - fieldBackgroundColor: Styles.ContrastBackgroundColor, - fieldTextColor: Styles.PrimaryTextColor, - fieldTextColorFocused: Styles.ContrastPrimaryTextColor, - buttonBackgroundColor: Styles.ContrastBackgroundColor, - buttonBackgroundColorFocused: Styles.PrimaryTextColor, - buttonTextColor: Styles.PrimaryTextColor, - buttonTextColorFocused: Styles.InverseTextColor, + fieldBackgroundColor: Styles.PrimaryTextColor, + fieldBackgroundColorFocused: Styles.ContrastBackgroundColor, + fieldTextColor: Styles.ContrastPrimaryTextColor, + fieldTextColorFocused: Styles.PrimaryTextColor, + buttonBackgroundColor: Styles.PrimaryTextColor, + buttonBackgroundColorFocused: Styles.ContrastBackgroundColor, + buttonTextColor: Styles.InverseTextColor, + buttonTextColorFocused: Styles.PrimaryTextColor, labelColorFocused: ColorUnset, - fieldBackgroundColorFocused: ColorUnset, } f.focus = f diff --git a/inputfield.go b/inputfield.go index c768095..7534309 100644 --- a/inputfield.go +++ b/inputfield.go @@ -144,18 +144,18 @@ func NewInputField() *InputField { return &InputField{ Box: NewBox(), labelColor: Styles.SecondaryTextColor, - fieldBackgroundColor: Styles.ContrastBackgroundColor, - fieldTextColor: Styles.PrimaryTextColor, + fieldBackgroundColor: Styles.PrimaryTextColor, + fieldBackgroundColorFocused: Styles.ContrastBackgroundColor, + fieldTextColor: Styles.ContrastPrimaryTextColor, + fieldTextColorFocused: Styles.PrimaryTextColor, placeholderTextColor: Styles.ContrastSecondaryTextColor, autocompleteListTextColor: Styles.PrimitiveBackgroundColor, autocompleteListBackgroundColor: Styles.MoreContrastBackgroundColor, autocompleteListSelectedTextColor: Styles.PrimitiveBackgroundColor, autocompleteListSelectedBackgroundColor: Styles.PrimaryTextColor, - autocompleteSuggestionTextColor: Styles.ContrastPrimaryTextColor, + autocompleteSuggestionTextColor: Styles.ContrastSecondaryTextColor, fieldNoteTextColor: Styles.SecondaryTextColor, labelColorFocused: ColorUnset, - fieldBackgroundColorFocused: ColorUnset, - fieldTextColorFocused: ColorUnset, placeholderTextColorFocused: ColorUnset, } } diff --git a/styles.go b/styles.go index c32bd24..8f005a4 100644 --- a/styles.go +++ b/styles.go @@ -56,7 +56,7 @@ var Styles = Theme{ TertiaryTextColor: tcell.ColorGreen.TrueColor(), InverseTextColor: tcell.ColorBlack.TrueColor(), ContrastPrimaryTextColor: tcell.ColorBlack.TrueColor(), - ContrastSecondaryTextColor: tcell.ColorDimGray.TrueColor(), + ContrastSecondaryTextColor: tcell.ColorLightSlateGray.TrueColor(), PrimitiveBackgroundColor: tcell.ColorBlack.TrueColor(), ContrastBackgroundColor: tcell.ColorBlue.TrueColor(),