From 4822680d62a0b42fe62a2c68b449ce5893576e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Feb 2025 11:45:40 -0600 Subject: [PATCH] Remove some SetTextColor hacks in popups --- Common/UI/PopupScreens.cpp | 5 ++--- Common/UI/Tween.cpp | 8 +------- Common/UI/Tween.h | 8 -------- Common/UI/View.cpp | 6 ++++-- UI/MainScreen.cpp | 6 +++--- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 1384e4bf43..d72d21ce54 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -20,7 +20,7 @@ void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) { std::vector 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); diff --git a/Common/UI/Tween.cpp b/Common/UI/Tween.cpp index bf7e29026e..f71aaac856 100644 --- a/Common/UI/Tween.cpp +++ b/Common/UI/Tween.cpp @@ -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)); diff --git a/Common/UI/Tween.h b/Common/UI/Tween.h index f290c0e497..d5973e36bd 100644 --- a/Common/UI/Tween.h +++ b/Common/UI/Tween.h @@ -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; diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index cec3e26e84..0d6b7cb7cf 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -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; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 81bbab19da..3c9fffbdf2 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -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); }