forked from tslocum/cview
Change default colors
Focused buttons and fields are now blue.
This commit is contained in:
parent
011f4decc0
commit
f8d1b2c63c
|
@ -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
|
||||
|
||||
|
|
20
button.go
20
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
form.go
16
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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue