diff --git a/Common/Data/Color/RGBAUtil.cpp b/Common/Data/Color/RGBAUtil.cpp index 8b93a0fc96..8e376daab5 100644 --- a/Common/Data/Color/RGBAUtil.cpp +++ b/Common/Data/Color/RGBAUtil.cpp @@ -44,19 +44,21 @@ uint32_t colorBlend(uint32_t rgb1, uint32_t rgb2, float alpha) { } uint32_t alphaMul(uint32_t color, float alphaMul) { - uint32_t rgb = color & 0xFFFFFF; + const uint32_t rgb = color & 0xFFFFFF; int32_t alpha = color >> 24; alpha = (int32_t)(alpha * alphaMul); - if (alpha < 0) alpha = 0; - if (alpha > 255) alpha = 255; - return (alpha << 24) | (rgb & 0xFFFFFF); + if (alpha < 0) + alpha = 0; + if (alpha > 255) + alpha = 255; + return (alpha << 24) | rgb; } uint32_t rgba(float r, float g, float b, float alpha) { - uint32_t color = (int)(alpha*255)<<24; - color |= (int)(b*255)<<16; - color |= (int)(g*255)<<8; - color |= (int)(r*255); + uint32_t color = (int)(alpha * 255.0f) << 24; + color |= (int)(b * 255.0f) << 16; + color |= (int)(g * 255.0f) << 8; + color |= (int)(r * 255.0f); return color; } diff --git a/Common/UI/View.h b/Common/UI/View.h index 7b24ea4f53..10040b00c4 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -111,6 +111,8 @@ struct Theme { Style popupStyle; Style popupHeaderStyle; + Style tooltipStyle; + uint32_t backgroundColor; uint32_t scrollbarColor; }; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 4ff667afdd..e2d8e2fb08 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -1096,13 +1096,14 @@ void SettingInfoMessage::Draw(UIContext &dc) { alpha = MAX_ALPHA - MAX_ALPHA * (float)((sinceShow - timeToShow) / FADE_TIME); } - if (alpha >= 0.1f) { - UI::Style style = dc.theme->popupStyle; - style.background.color = colorAlpha(style.background.color, alpha - 0.1f); - dc.FillRect(style.background, bounds_); + UI::Style style = dc.theme->tooltipStyle; + + if (alpha >= 0.001f) { + uint32_t bgColor = alphaMul(style.background.color, alpha); + dc.FillRect(UI::Drawable(bgColor), bounds_); } - uint32_t textColor = colorAlpha(dc.GetTheme().itemStyle.fgColor, alpha); + uint32_t textColor = alphaMul(style.fgColor, alpha); text_->SetTextColor(textColor); ViewGroup::Draw(dc); showing_ = sinceShow <= timeToShow; // Don't consider fade time diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 4cf1b544da..3f73e6a4c4 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -53,6 +53,8 @@ struct ThemeInfo { uint32_t uPopupStyleBg = 0xFF303030; uint32_t uPopupHeaderStyleFg = 0xFFFFFFFF; uint32_t uPopupHeaderStyleBg = 0x00000000; // default to invisible + uint32_t uTooltipStyleFg = 0xFFFFFFFF; + uint32_t uTooltipStyleBg = 0xC0303030; uint32_t uBackgroundColor = 0xFF754D24; uint32_t uScrollbarColor = 0x80FFFFFF; @@ -142,6 +144,8 @@ static void LoadThemeInfo(const std::vector &directories) { section.Get("InfoStyleBg", &info.uInfoStyleBg, info.uInfoStyleBg); section.Get("PopupStyleFg", &info.uPopupStyleFg, info.uItemStyleFg); // Backwards compat section.Get("PopupStyleBg", &info.uPopupStyleBg, info.uPopupStyleBg); + section.Get("TooltipStyleFg", &info.uTooltipStyleFg, info.uTooltipStyleFg); // Backwards compat + section.Get("TooltipStyleBg", &info.uTooltipStyleBg, info.uTooltipStyleBg); section.Get("PopupHeaderStyleFg", &info.uPopupHeaderStyleFg, info.uItemStyleFg); // Backwards compat section.Get("PopupHeaderStyleBg", &info.uPopupHeaderStyleBg, info.uPopupHeaderStyleBg); section.Get("BackgroundColor", &info.uBackgroundColor, info.uBackgroundColor); @@ -237,6 +241,9 @@ 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.tooltipStyle = MakeStyle(themeInfos[i].uTooltipStyleFg, themeInfos[i].uTooltipStyleBg); + ui_theme.backgroundColor = themeInfos[i].uBackgroundColor; ui_theme.scrollbarColor = themeInfos[i].uScrollbarColor; diff --git a/assets/themes/1995.ini b/assets/themes/1995.ini index 3f43c0d0fd..4a45b16a3c 100644 --- a/assets/themes/1995.ini +++ b/assets/themes/1995.ini @@ -26,8 +26,10 @@ InfoStyleFg = "#FFFFFFFF" InfoStyleBg = "#00000000" PopupStyleFg = "#000000FF" PopupStyleBg = "#FFFFAAFF" -PopupHeaderStyleFg = "#c0c0c0FF" +PopupHeaderStyleFg = "#FFFFFFFF" PopupHeaderStyleBg = "#000080FF" +TooltipStyleFg = "#FFFFFFFF" +TooltipStyleBg = "#000080D0" BackgroundColor = "#008080FF" ScrollbarColor = "#00000080" UIAtlas = "../ui_atlas" diff --git a/assets/themes/defaultthemes.ini b/assets/themes/defaultthemes.ini index 345d92ede2..5bd26b4882 100644 --- a/assets/themes/defaultthemes.ini +++ b/assets/themes/defaultthemes.ini @@ -16,6 +16,8 @@ PopupStyleFg = "#FFFFFFFF" PopupStyleBg = "#1f4d5eFF" PopupHeaderStyleFg = "#FFFFFFFF" PopupHeaderStyleBg = "#00000000" +TooltipStyleFg = "#FFFFFFFF" +TooltipStyleBg = "#303030C0" BackgroundColor = "#244D75FF" ScrollbarColor = "#FFFFFF80" UIAtlas = "../ui_atlas" @@ -42,6 +44,8 @@ PopupStyleFg = "#FFFFFFFF" PopupStyleBg = "#0c1d24FF" PopupHeaderStyleFg = "#FFFFFFFF" PopupHeaderStyleBg = "#00000000" +TooltipStyleFg = "#FFFFFFFF" +TooltipStyleBg = "#303030C0" BackgroundColor = "#000000FF" ScrollbarColor = "#FFFFFF80" UIAtlas = "../ui_atlas" diff --git a/assets/themes/slateforest.ini b/assets/themes/slateforest.ini index a939d803ba..3972d00224 100644 --- a/assets/themes/slateforest.ini +++ b/assets/themes/slateforest.ini @@ -26,6 +26,8 @@ PopupStyleFg = "#FFFFFFFF" PopupStyleBg = "#9498A1FF" PopupHeaderStyleFg = "#FFFFFFFF" PopupHeaderStyleBg = "#00000000" +TooltipStyleFg = "#FFFFFFFF" +TooltipStyleBg = "#303030C0" BackgroundColor = "#122537FF" ScrollbarColor = "#FFFFFF80" UIAtlas = "../ui_atlas" diff --git a/assets/themes/vinewood.ini b/assets/themes/vinewood.ini index 3d168f3b12..8771bca3c4 100644 --- a/assets/themes/vinewood.ini +++ b/assets/themes/vinewood.ini @@ -27,6 +27,8 @@ PopupStyleFg = "#C3D7A4FF" PopupStyleBg = "#94B185FF" PopupHeaderStyleFg = "#FFFFFFFF" PopupHeaderStyleBg = "#00000000" +TooltipStyleFg = "#FFFFFFFF" +TooltipStyleBg = "#303030C0" BackgroundColor = "#62865AFF" ScrollbarColor = "#FFFFFF80" UIAtlas = "../ui_atlas"