Add Style.CheckboxBgColor

This commit is contained in:
Trevor Slocum 2024-10-31 22:13:57 -07:00
parent 7674cd8c59
commit 8fcca949ff
3 changed files with 19 additions and 14 deletions

View file

@ -23,13 +23,15 @@ type Checkbox struct {
// NewCheckbox returns a new Checkbox widget.
func NewCheckbox(onSelect func() error) *Checkbox {
return &Checkbox{
c := &Checkbox{
Box: NewBox(),
checkColor: Style.TextColorDark,
borderSize: 2,
borderColor: Style.ButtonBorderBottom,
onSelect: onSelect,
}
c.SetBackground(Style.CheckboxBgColor)
return c
}
// SetRect sets the position and size of the Checkbox. The checkbox is always

View file

@ -25,7 +25,6 @@ func newCheckboxExample() (etk.Widget, etk.Widget) {
return nil
}
chk = etk.NewCheckbox(onSelectChk)
chk.SetBackground(color.RGBA{255, 255, 255, 255})
label = etk.NewButton("Unchecked", onSelectLabel)
label.SetHorizontal(etk.AlignStart)
label.SetVertical(etk.AlignCenter)

View file

@ -18,12 +18,6 @@ type Attributes struct {
TextBgColor color.RGBA
ButtonBorderSize int
ButtonBorderTop color.RGBA
ButtonBorderRight color.RGBA
ButtonBorderBottom color.RGBA
ButtonBorderLeft color.RGBA
InputBorderSize int
InputBorderFocused color.RGBA
InputBorderUnfocused color.RGBA
@ -42,6 +36,14 @@ type Attributes struct {
ButtonTextColor color.RGBA
ButtonBgColor color.RGBA
ButtonBgColorDisabled color.RGBA
ButtonBorderSize int
ButtonBorderTop color.RGBA
ButtonBorderRight color.RGBA
ButtonBorderBottom color.RGBA
ButtonBorderLeft color.RGBA
CheckboxBgColor color.RGBA
}
// Style is the current default attribute configuration. Integer values will be scaled.
@ -53,12 +55,6 @@ var Style = &Attributes{
TextBgColor: transparent,
ButtonBorderSize: 4,
ButtonBorderTop: color.RGBA{220, 220, 220, 255},
ButtonBorderRight: color.RGBA{0, 0, 0, 255},
ButtonBorderBottom: color.RGBA{0, 0, 0, 255},
ButtonBorderLeft: color.RGBA{220, 220, 220, 255},
InputBorderSize: 2,
InputBorderFocused: color.RGBA{220, 220, 220, 255},
InputBorderUnfocused: color.RGBA{0, 0, 0, 255},
@ -76,4 +72,12 @@ var Style = &Attributes{
ButtonBgColor: color.RGBA{255, 255, 255, 255},
ButtonBgColorDisabled: color.RGBA{110, 110, 110, 255},
ButtonBorderSize: 4,
ButtonBorderTop: color.RGBA{220, 220, 220, 255},
ButtonBorderRight: color.RGBA{0, 0, 0, 255},
ButtonBorderBottom: color.RGBA{0, 0, 0, 255},
ButtonBorderLeft: color.RGBA{220, 220, 220, 255},
CheckboxBgColor: color.RGBA{255, 255, 255, 255},
}