Remove some SetTextColor hacks in popups

This commit is contained in:
Henrik Rydgård 2025-02-17 11:45:40 -06:00
parent 863bef5f64
commit 4822680d62
5 changed files with 10 additions and 23 deletions

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);

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));

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;

View file

@ -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;

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);
}