Merge pull request #19995 from hrydgard/theme-work

More theming work
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-02-17 14:04:17 -06:00
commit 41de9c744a
14 files changed
+50 -45

No files matched your search

+2 -3
View File
@@ -20,7 +20,7 @@ void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
std::vector<std::string_view> messageLines;
SplitString(message_, '\n', messageLines);
for (auto lineOfText : messageLines)
parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false))->SetTextColor(dc.theme->popupStyle.fgColor);
parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false));
}
void MessagePopupScreen::OnCompleted(DialogResult result) {
@@ -374,7 +374,6 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
edit_ = new TextEdit("", Title(), "", new LinearLayoutParams(1.0f));
edit_->SetMaxLen(16);
edit_->SetTextColor(dc.theme->itemStyle.fgColor);
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
edit_->OnTextChange.Handle(this, &SliderPopupScreen::OnTextChange);
changing_ = true;
@@ -383,7 +382,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
lin->Add(edit_);
if (!units_.empty())
lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor);
lin->Add(new TextView(units_));
if (defaultValue_ != NO_DEFAULT_FLOAT) {
auto di = GetI18NCategory(I18NCat::DIALOG);
+1 -7
View File
@@ -1,4 +1,4 @@
#include "Common/Data/Color/RGBAUtil.h"
#include "Common/Data/Color/RGBAUtil.h"
#include "Common/UI/Tween.h"
#include "Common/UI/View.h"
#include "Common/UI/ViewGroup.h"
@@ -73,12 +73,6 @@ uint32_t ColorTween::Current(float pos) {
return colorBlend(to_, from_, pos);
}
void TextColorTween::DoApply(View *view, float pos) {
// TODO: No validation without RTTI?
TextView *tv = (TextView *)view;
tv->SetTextColor(Current(pos));
}
void CallbackColorTween::DoApply(View *view, float pos) {
if (callback_) {
callback_(view, Current(pos));
-8
View File
@@ -151,14 +151,6 @@ protected:
uint32_t Current(float pos) override;
};
class TextColorTween : public ColorTween {
public:
using ColorTween::ColorTween;
protected:
void DoApply(View *view, float pos) override;
};
class CallbackColorTween : public ColorTween {
public:
using ColorTween::ColorTween;
+5 -1
View File
@@ -430,11 +430,15 @@ void PopupScreen::CreateViews() {
box_->SetSpacing(0.0f);
if (HasTitleBar()) {
View* title = new PopupHeader(title_);
View *title = new PopupHeader(title_);
box_->Add(title);
}
CreatePopupContents(box_);
root_->Recurse([](View *view) {
view->SetPopupStyle(true);
});
root_->SetDefaultFocusView(box_);
if (ShowButtons() && !button1_.empty()) {
// And the two buttons at the bottom.
+7 -5
View File
@@ -711,11 +711,11 @@ void PopupHeader::Draw(UIContext &dc) {
}
// Header background
dc.FillRect(dc.theme->popupHeaderStyle.background, bounds_);
dc.FillRect(dc.theme->popupTitleStyle.background, bounds_);
// Header title text
dc.DrawText(text_, bounds_.x + tx, bounds_.centerY(), dc.theme->popupHeaderStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.DrawText(text_, bounds_.x + tx, bounds_.centerY(), dc.theme->popupTitleStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
// Underline
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupHeaderStyle.fgColor);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitleStyle.fgColor);
if (availableWidth < tw) {
dc.PopScissor();
@@ -1055,7 +1055,7 @@ void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz
}
void TextView::Draw(UIContext &dc) {
uint32_t textColor = hasTextColor_ ? textColor_ : dc.theme->infoStyle.fgColor;
uint32_t textColor = hasTextColor_ ? textColor_ : (popupStyle_ ? dc.theme->popupStyle.fgColor : dc.theme->infoStyle.fgColor);
if (!(textColor & 0xFF000000))
return;
@@ -1130,9 +1130,11 @@ void TextEdit::FocusChanged(int focusFlags) {
void TextEdit::Draw(UIContext &dc) {
dc.PushScissor(bounds_);
dc.SetFontStyle(dc.theme->uiFont);
// TODO: make background themeable?
dc.FillRect(HasFocus() ? UI::Drawable(0x80000000) : UI::Drawable(0x30000000), bounds_);
uint32_t textColor = hasTextColor_ ? textColor_ : dc.theme->infoStyle.fgColor;
uint32_t textColor = popupStyle_ ? dc.theme->popupStyle.fgColor : dc.theme->infoStyle.fgColor;
float textX = bounds_.x;
float w, h;
+8 -3
View File
@@ -110,7 +110,7 @@ struct Theme {
Style collapsibleHeaderStyle;
Style popupStyle;
Style popupHeaderStyle;
Style popupTitleStyle;
Style tooltipStyle;
@@ -429,6 +429,8 @@ public:
virtual bool CanBeFocused() const { return true; }
virtual bool SubviewFocused(View *view) { return false; }
void SetPopupStyle(bool popupStyle) { popupStyle_ = popupStyle; }
bool HasFocus() const {
return GetFocusedView() == this;
}
@@ -480,6 +482,8 @@ public:
return t;
}
virtual void Recurse(void (*func)(View *view)) {}
protected:
// Inputs to layout
std::unique_ptr<LayoutParams> layoutParams_;
@@ -496,6 +500,9 @@ protected:
std::vector<Tween *> tweens_;
// Whether to use popup colors for styling.
bool popupStyle_ = false;
private:
std::function<bool()> enabledFunc_;
bool *enabledPtr_ = nullptr;
@@ -851,11 +858,9 @@ public:
std::string DescribeText() const override;
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
void SetLarge(bool large) { large_ = large; }
void SetPopupStyle(bool popupStyle) { popupStyle_ = popupStyle; }
private:
std::string text_;
bool large_ = false;
bool popupStyle_ = false;
};
class PopupHeader : public Item {
+7
View File
@@ -48,6 +48,13 @@ ViewGroup::~ViewGroup() {
Clear();
}
void ViewGroup::Recurse(void (*func)(View *view)) {
for (View *view : views_) {
func(view);
view->Recurse(func);
}
}
void ViewGroup::RemoveSubview(View *subView) {
// loop counter needed, so can't convert loop.
for (size_t i = 0; i < views_.size(); i++) {
+2
View File
@@ -82,6 +82,8 @@ public:
std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); }
std::string DescribeText() const override;
void Recurse(void (*func)(View *view)) override;
protected:
std::string DescribeListUnordered(std::string_view heading) const;
std::string DescribeListOrdered(std::string_view heading) const;
+3 -3
View File
@@ -1738,16 +1738,16 @@ void GridSettingsPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
static const char *defaultTabs[] = { "Recent", "Games", "Homebrew & Demos" };
PopupMultiChoice *beziersChoice = items->Add(new PopupMultiChoice(&g_Config.iDefaultTab, sy->T("Default tab"), defaultTabs, 0, ARRAY_SIZE(defaultTabs), I18NCat::MAINMENU, screenManager()));
items->Add(new ItemHeader(sy->T("Grid icon size")))->SetPopupStyle(true);
items->Add(new ItemHeader(sy->T("Grid icon size")));
items->Add(new Choice(sy->T("Increase size")))->OnClick.Handle(this, &GridSettingsPopupScreen::GridPlusClick);
items->Add(new Choice(sy->T("Decrease size")))->OnClick.Handle(this, &GridSettingsPopupScreen::GridMinusClick);
items->Add(new ItemHeader(sy->T("Display Extra Info")))->SetPopupStyle(true);
items->Add(new ItemHeader(sy->T("Display Extra Info")));
items->Add(new CheckBox(&g_Config.bShowIDOnGameIcon, sy->T("Show ID")));
items->Add(new CheckBox(&g_Config.bShowRegionOnGameIcon, sy->T("Show region flag")));
if (g_Config.iMaxRecent > 0) {
items->Add(new ItemHeader(sy->T("Clear Recent")))->SetPopupStyle(true);
items->Add(new ItemHeader(sy->T("Clear Recent")));
items->Add(new Choice(sy->T("Clear Recent Games List")))->OnClick.Handle(this, &GridSettingsPopupScreen::OnRecentClearClick);
}
+5 -5
View File
@@ -51,8 +51,8 @@ struct ThemeInfo {
uint32_t uInfoStyleBg = 0x00000000;
uint32_t uPopupStyleFg = 0xFFFFFFFF;
uint32_t uPopupStyleBg = 0xFF303030;
uint32_t uPopupHeaderStyleFg = 0xFFFFFFFF;
uint32_t uPopupHeaderStyleBg = 0x00000000; // default to invisible
uint32_t uPopupTitleStyleFg = 0xFFFFFFFF;
uint32_t uPopupTitleStyleBg = 0x00000000; // default to invisible
uint32_t uTooltipStyleFg = 0xFFFFFFFF;
uint32_t uTooltipStyleBg = 0xC0303030;
uint32_t uCollapsibleHeaderStyleFg = 0xFFFFFFFF;
@@ -148,8 +148,8 @@ static void LoadThemeInfo(const std::vector<Path> &directories) {
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("PopupHeaderStyleFg", &info.uPopupTitleStyleFg, info.uItemStyleFg); // Backwards compat
section.Get("PopupHeaderStyleBg", &info.uPopupTitleStyleBg, info.uPopupTitleStyleBg);
section.Get("CollapsibleHeaderStyleFg", &info.uCollapsibleHeaderStyleFg, info.uItemStyleFg); // Backwards compat
section.Get("CollapsibleHeaderStyleBg", &info.uCollapsibleHeaderStyleBg, info.uItemStyleBg);
section.Get("BackgroundColor", &info.uBackgroundColor, info.uBackgroundColor);
@@ -256,7 +256,7 @@ void UpdateTheme(UIContext *ctx) {
ui_theme.infoStyle = MakeStyle(themeInfo.uInfoStyleFg, themeInfo.uInfoStyleBg);
ui_theme.popupStyle = MakeStyle(themeInfo.uPopupStyleFg, themeInfo.uPopupStyleBg);
ui_theme.popupHeaderStyle = MakeStyle(themeInfo.uPopupHeaderStyleFg, themeInfo.uPopupHeaderStyleBg);
ui_theme.popupTitleStyle = MakeStyle(themeInfo.uPopupTitleStyleFg, themeInfo.uPopupTitleStyleBg);
ui_theme.tooltipStyle = MakeStyle(themeInfo.uTooltipStyleFg, themeInfo.uTooltipStyleBg);
+2 -2
View File
@@ -26,8 +26,8 @@ InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupStyleFg = "#000000FF"
PopupStyleBg = "#FFFFAAFF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#000080FF"
PopupTitleStyleFg = "#FFFFFFFF"
PopupTitleStyleBg = "#000080FF"
CollapsibleHeaderStyleFg = "#000000FF"
CollapsibleHeaderStyleBg = "#C0C0C0FF"
TooltipStyleFg = "#FFFFFFFF"
+4 -4
View File
@@ -14,8 +14,8 @@ InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupStyleFg = "#FFFFFFFF"
PopupStyleBg = "#1f4d5eFF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
PopupTitleStyleFg = "#FFFFFFFF"
PopupTitleStyleBg = "#00000000"
CollapsibleHeaderStyleFg = "#FFFFFFFF"
CollapsibleHeaderStyleBg = "#00000055"
TooltipStyleFg = "#FFFFFFFF"
@@ -44,8 +44,8 @@ InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupStyleFg = "#FFFFFFFF"
PopupStyleBg = "#0c1d24FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
PopupTitleStyleFg = "#FFFFFFFF"
PopupTitleStyleBg = "#00000000"
CollapsibleHeaderStyleFg = "#FFFFFFFF"
CollapsibleHeaderStyleBg = "#00000055"
TooltipStyleFg = "#FFFFFFFF"
+2 -2
View File
@@ -24,8 +24,8 @@ InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupStyleFg = "#FFFFFFFF"
PopupStyleBg = "#9498A1FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
PopupTitleStyleFg = "#FFFFFFFF"
PopupTitleStyleBg = "#00000000"
CollapsibleHeaderStyleFg = "#FFFFFFFF"
CollapsibleHeaderStyleBg = "#2D4459B0"
TooltipStyleFg = "#FFFFFFFF"
+2 -2
View File
@@ -25,8 +25,8 @@ InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupStyleFg = "#C3D7A4FF"
PopupStyleBg = "#94B185FF"
PopupHeaderStyleFg = "#FFFFFFFF"
PopupHeaderStyleBg = "#00000000"
PopupTitleStyleFg = "#FFFFFFFF"
PopupTitleStyleBg = "#00000000"
CollapsibleHeaderStyleFg = "#C3D7A4FF"
CollapsibleHeaderStyleBg = "#000000C0"
TooltipStyleFg = "#FFFFFFFF"