Skip to content

Commit

Permalink
add new theme ColorNameScrollBarBackground
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 2, 2025
1 parent 6f34467 commit f11f183
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/widget/scroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (r *scrollBarAreaRenderer) MinSize() fyne.Size {
func (r *scrollBarAreaRenderer) Refresh() {
th := theme.CurrentForWidget(r.area)
r.bar.Refresh()
r.background.FillColor = th.Color(theme.ColorNameInputBackground, fyne.CurrentApp().Settings().ThemeVariant())
r.background.FillColor = th.Color(theme.ColorNameScrollBarBackground, fyne.CurrentApp().Settings().ThemeVariant())
r.background.Hidden = !r.area.isLarge()
r.layoutWithTheme(th, r.area.Size())
canvas.Refresh(r.bar)
Expand Down Expand Up @@ -244,7 +244,7 @@ func (a *scrollBarArea) CreateRenderer() fyne.WidgetRenderer {
th := theme.CurrentForWidget(a)
v := fyne.CurrentApp().Settings().ThemeVariant()
bar := newScrollBar(a)
background := canvas.NewRectangle(th.Color(theme.ColorNameInputBackground, v))
background := canvas.NewRectangle(th.Color(theme.ColorNameScrollBarBackground, v))
background.Hidden = !a.isLarge()
return &scrollBarAreaRenderer{BaseRenderer: NewBaseRenderer([]fyne.CanvasObject{background, bar}), area: a, bar: bar, background: background}
}
Expand Down
2 changes: 2 additions & 0 deletions test/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var knownColorNames = []fyne.ThemeColorName{
theme.ColorNamePressed,
theme.ColorNamePrimary,
theme.ColorNameScrollBar,
theme.ColorNameScrollBarBackground,
theme.ColorNameSelection,
theme.ColorNameSeparator,
theme.ColorNameShadow,
Expand Down Expand Up @@ -111,6 +112,7 @@ func NewTheme() fyne.Theme {
theme.ColorNamePressed: blue(250),
theme.ColorNamePrimary: green(255),
theme.ColorNameScrollBar: blue(220),
theme.ColorNameScrollBarBackground: red(20),
theme.ColorNameSelection: red(55),
theme.ColorNameSeparator: gray(30),
theme.ColorNameShadow: blue(150),
Expand Down
7 changes: 7 additions & 0 deletions theme/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ const (
// Since: 2.0
ColorNameScrollBar fyne.ThemeColorName = "scrollBar"

// ColorNameScrollBarBackground is the name of theme lookup for scrollbar background color.
//
// Since: 2.6
ColorNameScrollBarBackground fyne.ThemeColorName = "scrollBarBackground"

// ColorNameSelection is the name of theme lookup for selection color.
//
// Since: 2.1
Expand Down Expand Up @@ -197,6 +202,7 @@ var (
colorDarkPlaceholder = color.NRGBA{R: 0xb2, G: 0xb2, B: 0xb2, A: 0xff}
colorDarkPressed = color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0x66}
colorDarkScrollBar = color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0x99}
colorDarkScrollBarBackground = color.NRGBA{R: 0x20, G: 0x20, B: 0x23, A: 0xff}
colorDarkSeparator = color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}
colorDarkShadow = color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x66}
colorDarkSuccess = color.NRGBA{R: 0x43, G: 0xf4, B: 0x36, A: 0xff}
Expand Down Expand Up @@ -228,6 +234,7 @@ var (
colorLightPlaceholder = color.NRGBA{R: 0x88, G: 0x88, B: 0x88, A: 0xff}
colorLightPressed = color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x19}
colorLightScrollBar = color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x99}
colorLightScrollBarBackground = color.NRGBA{R: 0xdb, G: 0xdb, B: 0xdb, A: 0xff}
colorLightSelectionBlue = color.NRGBA{R: 0x00, G: 0x6c, B: 0xff, A: 0x40}
colorLightSelectionBrown = color.NRGBA{R: 0x79, G: 0x55, B: 0x48, A: 0x3f}
colorLightSelectionGray = color.NRGBA{R: 0x9e, G: 0x9e, B: 0x9e, A: 0x3f}
Expand Down
2 changes: 2 additions & 0 deletions theme/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func (l *legacyWrapper) Color(n fyne.ThemeColorName, v fyne.ThemeVariant) color.
return l.old.PrimaryColor()
case ColorNameScrollBar:
return l.old.ScrollBarColor()
case ColorNameScrollBarBackground:
return l.old.BackgroundColor()
case ColorNameShadow:
return l.old.ShadowColor()
default:
Expand Down
4 changes: 4 additions & 0 deletions theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ func darkPaletteColorNamed(name fyne.ThemeColorName) color.Color {
return colorDarkPressed
case ColorNameScrollBar:
return colorDarkScrollBar
case ColorNameScrollBarBackground:
return colorDarkScrollBarBackground
case ColorNameSeparator:
return colorDarkSeparator
case ColorNameShadow:
Expand Down Expand Up @@ -334,6 +336,8 @@ func lightPaletteColorNamed(name fyne.ThemeColorName) color.Color {
return colorLightPressed
case ColorNameScrollBar:
return colorLightScrollBar
case ColorNameScrollBarBackground:
return colorLightScrollBarBackground
case ColorNameSeparator:
return colorLightSeparator
case ColorNameShadow:
Expand Down

0 comments on commit f11f183

Please sign in to comment.