Allow specifying color of scroll bar area and handle

This commit is contained in:
Trevor Slocum 2023-10-28 00:30:09 -07:00
parent 07b308bcc0
commit 8912fc06fd
5 changed files with 19 additions and 12 deletions

View file

@ -17,7 +17,7 @@ type Button struct {
func NewButton(label string, onSelected func() error) *Button {
textColor := Style.ButtonTextColor
if textColor == nil {
if textColor.A == 0 {
textColor = Style.TextColorDark
}

2
go.mod
View file

@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/etk
go 1.18
require (
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028071036-9bb769038e79
github.com/hajimehoshi/ebiten/v2 v2.6.2
golang.org/x/image v0.13.0
)

4
go.sum
View file

@ -1,5 +1,5 @@
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278 h1:ef5eeSgFSQnLA17pGv/VEBW1mC3qLTjOZ/yTTc1rhzo=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028071036-9bb769038e79 h1:xmjdzoJfcQBAgcFhdr/Uy37J3mMvDBLmuTiSiHWnxOg=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028071036-9bb769038e79/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/hajimehoshi/bitmapfont/v3 v3.0.0 h1:r2+6gYK38nfztS/et50gHAswb9hXgxXECYgE8Nczmi4=

View file

@ -31,18 +31,21 @@ func defaultFont() font.Face {
type Attributes struct {
TextFont font.Face
TextColorLight color.Color
TextColorDark color.Color
TextColorLight color.RGBA
TextColorDark color.RGBA
TextBgColor color.Color
TextBgColor color.RGBA
BorderColor color.Color
ScrollAreaColor color.RGBA
ScrollHandleColor color.RGBA
InputBgColor color.Color
BorderColor color.RGBA
ButtonTextColor color.Color
ButtonBgColor color.Color
ButtonBgColorDisabled color.Color
InputBgColor color.RGBA
ButtonTextColor color.RGBA
ButtonBgColor color.RGBA
ButtonBgColorDisabled color.RGBA
}
var Style = &Attributes{
@ -53,6 +56,9 @@ var Style = &Attributes{
TextBgColor: transparent,
ScrollAreaColor: color.RGBA{200, 200, 200, 255},
ScrollHandleColor: color.RGBA{108, 108, 108, 255},
BorderColor: color.RGBA{0, 0, 0, 255},
InputBgColor: color.RGBA{0, 128, 0, 255},

View file

@ -22,6 +22,7 @@ func NewText(text string) *Text {
l.SetText(text)
l.SetForegroundColor(textColor)
l.SetBackgroundColor(Style.TextBgColor)
l.SetScrollBarColors(Style.ScrollAreaColor, Style.ScrollHandleColor)
l.SetHandleKeyboard(true)
return &Text{