diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index f18810233947..218198d36b18 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -1590,20 +1590,27 @@ void Slider::Clamp() { void Slider::Draw(UIContext &dc) { bool focus = HasFocus(); - uint32_t linecolor = dc.theme->itemStyle.fgColor; - Style knobStyle = (down_ || focus) ? dc.theme->itemStyle : dc.theme->popupStyle; + uint32_t sliderColor; + + if (down_) { + sliderColor = popupStyle_ ? dc.theme->popupSliderFocusedColor : dc.theme->itemDownStyle.fgColor; + } else if (focus) { + sliderColor = popupStyle_ ? dc.theme->popupSliderFocusedColor : dc.theme->itemFocusedStyle.fgColor; + } else { + sliderColor = popupStyle_ ? dc.theme->popupSliderColor : dc.theme->itemStyle.fgColor; + } float knobX = ((float)(*value_) - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_); - dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); + dc.FillRect(Drawable(sliderColor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); dc.FillRect(Drawable(0xFF808080), Bounds(knobX, bounds_.centerY() - 2, (bounds_.x + bounds_.w - paddingRight_ - knobX), 4)); - dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobStyle.fgColor, ALIGN_CENTER); + dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, sliderColor, ALIGN_CENTER); char temp[64]; if (showPercent_) snprintf(temp, sizeof(temp), "%d%%", *value_); else snprintf(temp, sizeof(temp), "%d", *value_); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); + dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), sliderColor, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); } std::string Slider::DescribeText() const { @@ -1743,17 +1750,24 @@ void SliderFloat::Clamp() { void SliderFloat::Draw(UIContext &dc) { bool focus = HasFocus(); - uint32_t linecolor = dc.theme->itemStyle.fgColor; - Style knobStyle = (down_ || focus) ? dc.theme->itemStyle : dc.theme->popupStyle; + uint32_t sliderColor; + + if (down_) { + sliderColor = popupStyle_ ? dc.theme->popupSliderFocusedColor : dc.theme->itemDownStyle.fgColor; + } else if (focus) { + sliderColor = popupStyle_ ? dc.theme->popupSliderFocusedColor : dc.theme->itemFocusedStyle.fgColor; + } else { + sliderColor = popupStyle_ ? dc.theme->popupSliderColor : dc.theme->itemStyle.fgColor; + } float knobX = (*value_ - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_); - dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); + dc.FillRect(Drawable(sliderColor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); dc.FillRect(Drawable(0xFF808080), Bounds(knobX, bounds_.centerY() - 2, (bounds_.x + bounds_.w - paddingRight_ - knobX), 4)); - dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobStyle.fgColor, ALIGN_CENTER); + dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, sliderColor, ALIGN_CENTER); char temp[64]; snprintf(temp, sizeof(temp), "%0.2f", *value_); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER); + dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), sliderColor, ALIGN_CENTER); } std::string SliderFloat::DescribeText() const { diff --git a/Common/UI/View.h b/Common/UI/View.h index a63fd34e6094..09f5762ed42a 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -116,6 +116,8 @@ struct Theme { uint32_t backgroundColor; uint32_t scrollbarColor; + uint32_t popupSliderColor; + uint32_t popupSliderFocusedColor; }; // The four cardinal directions should be enough, plus Prev/Next in "element order". diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 9ab731dcfbd1..1e15f1419e5e 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -59,6 +59,8 @@ struct ThemeInfo { uint32_t uCollapsibleHeaderStyleBg = 0x55000000; uint32_t uBackgroundColor = 0xFF754D24; uint32_t uScrollbarColor = 0x80FFFFFF; + uint32_t uPopupSliderColor = 0xFFFFFFFF; + uint32_t uPopupSliderFocusedColor = 0xFFEDC24C; std::string sUIAtlas = "ui_atlas"; @@ -154,6 +156,8 @@ static void LoadThemeInfo(const std::vector &directories) { section.Get("CollapsibleHeaderStyleBg", &info.uCollapsibleHeaderStyleBg, info.uItemStyleBg); section.Get("BackgroundColor", &info.uBackgroundColor, info.uBackgroundColor); section.Get("ScrollbarColor", &info.uScrollbarColor, info.uScrollbarColor); + section.Get("PopupSliderColor", &info.uPopupSliderColor, info.uPopupSliderColor); + section.Get("PopupSliderFocusedColor", &info.uPopupSliderFocusedColor, info.uPopupSliderFocusedColor); std::string tmpPath; section.Get("UIAtlas", &tmpPath, ""); @@ -263,6 +267,9 @@ void UpdateTheme(UIContext *ctx) { ui_theme.backgroundColor = themeInfo.uBackgroundColor; ui_theme.scrollbarColor = themeInfo.uScrollbarColor; + ui_theme.popupSliderColor = themeInfo.uPopupSliderColor; + ui_theme.popupSliderFocusedColor = themeInfo.uPopupSliderFocusedColor; + // Load any missing atlas metadata (the images are loaded from UIContext). LoadAtlasMetadata(ui_atlas, (themeInfo.sUIAtlas + ".meta").c_str(), true); #if !(PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID)) diff --git a/assets/themes/defaultthemes.ini b/assets/themes/defaultthemes.ini index c8e8a0a14fe7..2d681f000ff7 100644 --- a/assets/themes/defaultthemes.ini +++ b/assets/themes/defaultthemes.ini @@ -22,6 +22,8 @@ TooltipStyleFg = "#FFFFFFFF" TooltipStyleBg = "#303030C0" BackgroundColor = "#244D75FF" ScrollbarColor = "#FFFFFF80" +PopupSliderColor = "#FFFFFFFF" +PopupSliderFocusedColor = "#4CC2EDFF" UIAtlas = "../ui_atlas" # Colors are either in the format "#RGBA" or 0xABGR (e.g. green is "#00FF00FF" or 0xFF00FF00) @@ -52,4 +54,6 @@ TooltipStyleFg = "#FFFFFFFF" TooltipStyleBg = "#303030C0" BackgroundColor = "#000000FF" ScrollbarColor = "#FFFFFF80" +PopupSliderColor = "#FFFFFFFF" +PopupSliderFocusedColor = "#3799bdFF" UIAtlas = "../ui_atlas"