mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Themes: Add tooltip style
This commit is contained in:
parent
dc52c62d1a
commit
9a42c4aa7a
8 changed files with 36 additions and 14 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ struct Theme {
|
|||
Style popupStyle;
|
||||
Style popupHeaderStyle;
|
||||
|
||||
Style tooltipStyle;
|
||||
|
||||
uint32_t backgroundColor;
|
||||
uint32_t scrollbarColor;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Path> &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;
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -26,6 +26,8 @@ PopupStyleFg = "#FFFFFFFF"
|
|||
PopupStyleBg = "#9498A1FF"
|
||||
PopupHeaderStyleFg = "#FFFFFFFF"
|
||||
PopupHeaderStyleBg = "#00000000"
|
||||
TooltipStyleFg = "#FFFFFFFF"
|
||||
TooltipStyleBg = "#303030C0"
|
||||
BackgroundColor = "#122537FF"
|
||||
ScrollbarColor = "#FFFFFF80"
|
||||
UIAtlas = "../ui_atlas"
|
||||
|
|
|
@ -27,6 +27,8 @@ PopupStyleFg = "#C3D7A4FF"
|
|||
PopupStyleBg = "#94B185FF"
|
||||
PopupHeaderStyleFg = "#FFFFFFFF"
|
||||
PopupHeaderStyleBg = "#00000000"
|
||||
TooltipStyleFg = "#FFFFFFFF"
|
||||
TooltipStyleBg = "#303030C0"
|
||||
BackgroundColor = "#62865AFF"
|
||||
ScrollbarColor = "#FFFFFF80"
|
||||
UIAtlas = "../ui_atlas"
|
||||
|
|
Loading…
Add table
Reference in a new issue