Themes: Add configurable color for the scrollbar bob

This commit is contained in:
Henrik Rydgård 2025-02-14 14:47:47 -06:00
parent 513558b6cd
commit dc52c62d1a
7 changed files with 10 additions and 1 deletions

View file

@ -250,7 +250,7 @@ void ScrollView::Draw(UIContext &dc) {
if (bob.show) {
Bounds bobBounds(bounds_.x2() - bob.thickness, bounds_.y + bob.offset, bob.thickness, bob.size);
dc.FillRect(Drawable(0x80FFFFFF), bobBounds);
dc.FillRect(Drawable(dc.GetTheme().scrollbarColor), bobBounds);
}
}

View file

@ -112,6 +112,7 @@ struct Theme {
Style popupHeaderStyle;
uint32_t backgroundColor;
uint32_t scrollbarColor;
};
// The four cardinal directions should be enough, plus Prev/Next in "element order".

View file

@ -54,6 +54,7 @@ struct ThemeInfo {
uint32_t uPopupHeaderStyleFg = 0xFFFFFFFF;
uint32_t uPopupHeaderStyleBg = 0x00000000; // default to invisible
uint32_t uBackgroundColor = 0xFF754D24;
uint32_t uScrollbarColor = 0x80FFFFFF;
std::string sUIAtlas = "ui_atlas";
@ -144,6 +145,7 @@ static void LoadThemeInfo(const std::vector<Path> &directories) {
section.Get("PopupHeaderStyleFg", &info.uPopupHeaderStyleFg, info.uItemStyleFg); // Backwards compat
section.Get("PopupHeaderStyleBg", &info.uPopupHeaderStyleBg, info.uPopupHeaderStyleBg);
section.Get("BackgroundColor", &info.uBackgroundColor, info.uBackgroundColor);
section.Get("ScrollbarColor", &info.uScrollbarColor, info.uScrollbarColor);
std::string tmpPath;
section.Get("UIAtlas", &tmpPath, "");
@ -236,6 +238,7 @@ void UpdateTheme(UIContext *ctx) {
ui_theme.popupStyle = MakeStyle(themeInfos[i].uPopupStyleFg, themeInfos[i].uPopupStyleBg);
ui_theme.popupHeaderStyle = MakeStyle(themeInfos[i].uPopupHeaderStyleFg, themeInfos[i].uPopupHeaderStyleBg);
ui_theme.backgroundColor = themeInfos[i].uBackgroundColor;
ui_theme.scrollbarColor = themeInfos[i].uScrollbarColor;
// Load any missing atlas metadata (the images are loaded from UIContext).
LoadAtlasMetadata(ui_atlas, (themeInfos[i].sUIAtlas + ".meta").c_str(), true);

View file

@ -29,4 +29,5 @@ PopupStyleBg = "#FFFFAAFF"
PopupHeaderStyleFg = "#c0c0c0FF"
PopupHeaderStyleBg = "#000080FF"
BackgroundColor = "#008080FF"
ScrollbarColor = "#00000080"
UIAtlas = "../ui_atlas"

View file

@ -17,6 +17,7 @@ PopupStyleBg = "#1f4d5eFF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
BackgroundColor = "#244D75FF"
ScrollbarColor = "#FFFFFF80"
UIAtlas = "../ui_atlas"
# Colors are either in the format "#RGBA" or 0xABGR (e.g. green is "#00FF00FF" or 0xFF00FF00)
@ -42,4 +43,5 @@ PopupStyleBg = "#0c1d24FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
BackgroundColor = "#000000FF"
ScrollbarColor = "#FFFFFF80"
UIAtlas = "../ui_atlas"

View file

@ -27,4 +27,5 @@ PopupStyleBg = "#9498A1FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
BackgroundColor = "#122537FF"
ScrollbarColor = "#FFFFFF80"
UIAtlas = "../ui_atlas"

View file

@ -28,4 +28,5 @@ PopupStyleBg = "#94B185FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
BackgroundColor = "#62865AFF"
ScrollbarColor = "#FFFFFF80"
UIAtlas = "../ui_atlas"