From 5e1062678fdf9e5f87f0435f7088398739797f52 Mon Sep 17 00:00:00 2001 From: iota97 Date: Fri, 11 Feb 2022 12:32:23 +0100 Subject: [PATCH 1/8] Allow custom UI themes --- CMakeLists.txt | 2 + Core/Config.cpp | 29 +---- Core/Config.h | 30 +---- Core/System.cpp | 2 + Core/System.h | 1 + UI/GameSettingsScreen.cpp | 10 ++ UI/NativeApp.cpp | 50 +------- UI/Theme.cpp | 238 ++++++++++++++++++++++++++++++++++++++ UI/Theme.h | 25 ++++ UI/UI.vcxproj | 2 + UWP/UI_UWP/UI_UWP.vcxproj | 2 + android/jni/Android.mk | 1 + 12 files changed, 288 insertions(+), 104 deletions(-) create mode 100644 UI/Theme.cpp create mode 100644 UI/Theme.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6882811733..0a591daa71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1235,6 +1235,8 @@ list(APPEND NativeAppSource UI/TextureUtil.cpp UI/ComboKeyMappingScreen.h UI/ComboKeyMappingScreen.cpp + UI/Theme.h + UI/Theme.cpp ) if(ANDROID) diff --git a/Core/Config.cpp b/Core/Config.cpp index cae5f22b5d..aca17187b6 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1169,34 +1169,7 @@ static ConfigSetting upgradeSettings[] = { }; static ConfigSetting themeSettings[] = { - ConfigSetting("ItemStyleFg", &g_Config.uItemStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemStyleBg", &g_Config.uItemStyleBg, 0x55000000, true, false), - ConfigSetting("ItemFocusedStyleFg", &g_Config.uItemFocusedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemFocusedStyleBg", &g_Config.uItemFocusedStyleBg, 0xFFEDC24C, true, false), - ConfigSetting("ItemDownStyleFg", &g_Config.uItemDownStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemDownStyleBg", &g_Config.uItemDownStyleBg, 0xFFBD9939, true, false), - ConfigSetting("ItemDisabledStyleFg", &g_Config.uItemDisabledStyleFg, 0x80EEEEEE, true, false), - ConfigSetting("ItemDisabledStyleBg", &g_Config.uItemDisabledStyleBg, 0x55E0D4AF, true, false), - ConfigSetting("ItemHighlightedStyleFg", &g_Config.uItemHighlightedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemHighlightedStyleBg", &g_Config.uItemHighlightedStyleBg, 0x55BDBB39, true, false), - - ConfigSetting("ButtonStyleFg", &g_Config.uButtonStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonStyleBg", &g_Config.uButtonStyleBg, 0x55000000, true, false), - ConfigSetting("ButtonFocusedStyleFg", &g_Config.uButtonFocusedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonFocusedStyleBg", &g_Config.uButtonFocusedStyleBg, 0xFFEDC24C, true, false), - ConfigSetting("ButtonDownStyleFg", &g_Config.uButtonDownStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonDownStyleBg", &g_Config.uButtonDownStyleBg, 0xFFBD9939, true, false), - ConfigSetting("ButtonDisabledStyleFg", &g_Config.uButtonDisabledStyleFg, 0x80EEEEEE, true, false), - ConfigSetting("ButtonDisabledStyleBg", &g_Config.uButtonDisabledStyleBg, 0x55E0D4AF, true, false), - ConfigSetting("ButtonHighlightedStyleFg", &g_Config.uButtonHighlightedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonHighlightedStyleBg", &g_Config.uButtonHighlightedStyleBg, 0x55BDBB39, true, false), - - ConfigSetting("HeaderStyleFg", &g_Config.uHeaderStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("InfoStyleFg", &g_Config.uInfoStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("InfoStyleBg", &g_Config.uInfoStyleBg, 0x00000000U, true, false), - ConfigSetting("PopupTitleStyleFg", &g_Config.uPopupTitleStyleFg, 0xFFE3BE59, true, false), - ConfigSetting("PopupStyleFg", &g_Config.uPopupStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("PopupStyleBg", &g_Config.uPopupStyleBg, 0xFF303030, true, false), + ConfigSetting("ThemeName", &g_Config.sThemeName, "Default", true, false), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index bed269cd63..e2ff16ed99 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -255,35 +255,7 @@ public: bool bShowOnScreenMessages; int iBackgroundAnimation; // enum BackgroundAnimation - // TODO: Maybe move to a separate theme system. - uint32_t uItemStyleFg; - uint32_t uItemStyleBg; - uint32_t uItemFocusedStyleFg; - uint32_t uItemFocusedStyleBg; - uint32_t uItemDownStyleFg; - uint32_t uItemDownStyleBg; - uint32_t uItemDisabledStyleFg; - uint32_t uItemDisabledStyleBg; - uint32_t uItemHighlightedStyleFg; - uint32_t uItemHighlightedStyleBg; - - uint32_t uButtonStyleFg; - uint32_t uButtonStyleBg; - uint32_t uButtonFocusedStyleFg; - uint32_t uButtonFocusedStyleBg; - uint32_t uButtonDownStyleFg; - uint32_t uButtonDownStyleBg; - uint32_t uButtonDisabledStyleFg; - uint32_t uButtonDisabledStyleBg; - uint32_t uButtonHighlightedStyleFg; - uint32_t uButtonHighlightedStyleBg; - - uint32_t uHeaderStyleFg; - uint32_t uInfoStyleFg; - uint32_t uInfoStyleBg; - uint32_t uPopupTitleStyleFg; - uint32_t uPopupStyleFg; - uint32_t uPopupStyleBg; + std::string sThemeName; bool bLogFrameDrops; bool bShowDebugStats; diff --git a/Core/System.cpp b/Core/System.cpp index 31f720be2e..e3952524d6 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -645,6 +645,8 @@ Path GetSysDirectory(PSPDirectories directoryType) { return pspDirectory / "AUDIO"; case DIRECTORY_CUSTOM_SHADERS: return pspDirectory / "shaders"; + case DIRECTORY_CUSTOM_THEMES: + return pspDirectory / "themes"; case DIRECTORY_MEMSTICK_ROOT: return g_Config.memStickDirectory; diff --git a/Core/System.h b/Core/System.h index f28681e6d3..641e6444e8 100644 --- a/Core/System.h +++ b/Core/System.h @@ -56,6 +56,7 @@ enum PSPDirectories { DIRECTORY_MEMSTICK_ROOT, DIRECTORY_EXDATA, DIRECTORY_CUSTOM_SHADERS, + DIRECTORY_CUSTOM_THEMES, }; class GraphicsContext; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 180f79eaa1..37f4708867 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -51,6 +51,7 @@ #include "UI/TiltEventProcessor.h" #include "UI/GPUDriverTestScreen.h" #include "UI/MemStickScreen.h" +#include "UI/Theme.h" #include "Common/File/FileUtil.h" #include "Common/OSVersion.h" @@ -191,6 +192,7 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) { void GameSettingsScreen::CreateViews() { ReloadAllPostShaderInfo(screenManager()->getDrawContext()); + ReloadAllThemeInfo(); if (editThenRestore_) { std::shared_ptr info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0); @@ -881,6 +883,14 @@ void GameSettingsScreen::CreateViews() { if (backgroundChoice_ != nullptr) { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } + + PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, gr->T("Color Theme"), GetThemeInfoNames(), nullptr, screenManager())); + theme->OnChoice.Add([=](EventParams &e) { + UpdateTheme(); + + return UI::EVENT_CONTINUE; + }); + static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), sy->GetName(), screenManager())); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 2d94f47282..52a43b6f3c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -115,6 +115,7 @@ #include "UI/RemoteISOScreen.h" #include "UI/TiltEventProcessor.h" #include "UI/TextureUtil.h" +#include "UI/Theme.h" #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI) #include "Qt/QtHost.h" @@ -131,7 +132,6 @@ // The new UI framework, for initialization -static UI::Theme ui_theme; static Atlas g_ui_atlas; static Atlas g_font_atlas; @@ -873,49 +873,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch restarting = false; } -static UI::Style MakeStyle(uint32_t fg, uint32_t bg) { - UI::Style s; - s.background = UI::Drawable(bg); - s.fgColor = fg; - return s; -} - -static void UIThemeInit() { -#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI) - ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 22); - ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 15); - ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 12); -#else - ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), "", 20); - ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), "", 14); - ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), "", 11); -#endif - - ui_theme.checkOn = ImageID("I_CHECKEDBOX"); - ui_theme.checkOff = ImageID("I_SQUARE"); - ui_theme.whiteImage = ImageID("I_SOLIDWHITE"); - ui_theme.sliderKnob = ImageID("I_CIRCLE"); - ui_theme.dropShadow4Grid = ImageID("I_DROP_SHADOW"); - - ui_theme.itemStyle = MakeStyle(g_Config.uItemStyleFg, g_Config.uItemStyleBg); - ui_theme.itemFocusedStyle = MakeStyle(g_Config.uItemFocusedStyleFg, g_Config.uItemFocusedStyleBg); - ui_theme.itemDownStyle = MakeStyle(g_Config.uItemDownStyleFg, g_Config.uItemDownStyleBg); - ui_theme.itemDisabledStyle = MakeStyle(g_Config.uItemDisabledStyleFg, g_Config.uItemDisabledStyleBg); - ui_theme.itemHighlightedStyle = MakeStyle(g_Config.uItemHighlightedStyleFg, g_Config.uItemHighlightedStyleBg); - - ui_theme.buttonStyle = MakeStyle(g_Config.uButtonStyleFg, g_Config.uButtonStyleBg); - ui_theme.buttonFocusedStyle = MakeStyle(g_Config.uButtonFocusedStyleFg, g_Config.uButtonFocusedStyleBg); - ui_theme.buttonDownStyle = MakeStyle(g_Config.uButtonDownStyleFg, g_Config.uButtonDownStyleBg); - ui_theme.buttonDisabledStyle = MakeStyle(g_Config.uButtonDisabledStyleFg, g_Config.uButtonDisabledStyleBg); - ui_theme.buttonHighlightedStyle = MakeStyle(g_Config.uButtonHighlightedStyleFg, g_Config.uButtonHighlightedStyleBg); - - ui_theme.headerStyle.fgColor = g_Config.uHeaderStyleFg; - ui_theme.infoStyle = MakeStyle(g_Config.uInfoStyleFg, g_Config.uInfoStyleBg); - - ui_theme.popupTitle.fgColor = g_Config.uPopupTitleStyleFg; - ui_theme.popupStyle = MakeStyle(g_Config.uPopupStyleFg, g_Config.uPopupStyleBg); -} - void RenderOverlays(UIContext *dc, void *userdata); bool CreateGlobalPipelines(); @@ -962,10 +919,9 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { ui_draw2d_front.SetAtlas(&g_ui_atlas); ui_draw2d_front.SetFontAtlas(&g_font_atlas); - UIThemeInit(); - + UpdateTheme(); uiContext = new UIContext(); - uiContext->theme = &ui_theme; + uiContext->theme = GetTheme(); ui_draw2d.Init(g_draw, texColorPipeline); ui_draw2d_front.Init(g_draw, texColorPipeline); diff --git a/UI/Theme.cpp b/UI/Theme.cpp new file mode 100644 index 0000000000..51659270b6 --- /dev/null +++ b/UI/Theme.cpp @@ -0,0 +1,238 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "ppsspp_config.h" + +#include + +#include "UI/Theme.h" + +#include "Common/File/FileUtil.h" +#include "Common/File/VFS/VFS.h" +#include "Common/Data/Format/IniFile.h" + +#include "Core/Config.h" + +#include "Common/UI/View.h" +#include "Common/UI/Context.h" +#include "Core/System.h" + +struct themeInfo { + std::string name; + + uint32_t uItemStyleFg = 0xFFFFFFFF; + uint32_t uItemStyleBg = 0x55000000; + uint32_t uItemFocusedStyleFg = 0xFFFFFFFF; + uint32_t uItemFocusedStyleBg = 0xFFEDC24C; + uint32_t uItemDownStyleFg = 0xFFFFFFFF; + uint32_t uItemDownStyleBg = 0xFFBD9939; + uint32_t uItemDisabledStyleFg = 0x80EEEEEE; + uint32_t uItemDisabledStyleBg = 0x55E0D4AF; + uint32_t uItemHighlightedStyleFg = 0xFFFFFFFF; + uint32_t uItemHighlightedStyleBg = 0x55BDBB39; + + uint32_t uButtonStyleFg = 0xFFFFFFFF; + uint32_t uButtonStyleBg = 0x55000000; + uint32_t uButtonFocusedStyleFg = 0xFFFFFFFF; + uint32_t uButtonFocusedStyleBg = 0xFFBD9939; + uint32_t uButtonDownStyleFg = 0xFFFFFFFF; + uint32_t uButtonDownStyleBg = 0xFFBD9939; + uint32_t uButtonDisabledStyleFg = 0x80EEEEEE; + uint32_t uButtonDisabledStyleBg = 0x55E0D4AF; + uint32_t uButtonHighlightedStyleFg = 0xFFFFFFFF; + uint32_t uButtonHighlightedStyleBg = 0x55BDBB39; + + uint32_t uHeaderStyleFg = 0xFFFFFFFF; + uint32_t uInfoStyleFg = 0xFFFFFFFF; + uint32_t uInfoStyleBg = 0x00000000; + uint32_t uPopupTitleStyleFg = 0xFFE3BE59; + uint32_t uPopupStyleFg = 0xFFFFFFFF; + uint32_t uPopupStyleBg = 0xFF303030; + + bool operator == (const std::string &other) { + return name == other; + } + bool operator == (const themeInfo &other) { + return name == other.name; + } +}; + +static UI::Theme ui_theme; +static std::vector themeInfos; + +static void LoadThemeInfo(const std::vector &directories) { + themeInfos.clear(); + themeInfo def{}; + def.name = "Default"; + themeInfos.push_back(def); + + auto appendTheme = [&](const themeInfo &info) { + auto beginErase = std::remove(themeInfos.begin(), themeInfos.end(), info.name); + if (beginErase != themeInfos.end()) { + themeInfos.erase(beginErase, themeInfos.end()); + } + themeInfos.push_back(info); + }; + + for (size_t d = 0; d < directories.size(); d++) { + std::vector fileInfo; + VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:"); + + if (fileInfo.empty()) { + File::GetFilesInDir(directories[d], &fileInfo, "ini:"); + } + + for (size_t f = 0; f < fileInfo.size(); f++) { + IniFile ini; + bool success = false; + Path name = fileInfo[f].fullName; + Path path = directories[d]; + // Hack around Android VFS path bug. really need to redesign this. + if (name.ToString().substr(0, 7) == "assets/") + name = Path(name.ToString().substr(7)); + if (path.ToString().substr(0, 7) == "assets/") + path = Path(path.ToString().substr(7)); + + if (ini.LoadFromVFS(name.ToString()) || ini.Load(fileInfo[f].fullName)) { + success = true; + // vsh load. meh. + } + + if (!success) + continue; + + // Alright, let's loop through the sections and see if any is a themes. + for (size_t i = 0; i < ini.Sections().size(); i++) { + Section §ion = ini.Sections()[i]; + themeInfo info; + section.Get("Name", &info.name, section.name().c_str()); + + section.Get("ItemStyleFg", &info.uItemStyleFg, 0xFFFFFFFF); + section.Get("ItemStyleBg", &info.uItemStyleBg, 0x55000000); + section.Get("ItemFocusedStyleFg", &info.uItemFocusedStyleFg, 0xFFFFFFFF); + section.Get("ItemFocusedStyleBg", &info.uItemFocusedStyleBg, 0xFFEDC24C); + section.Get("ItemDownStyleFg", &info.uItemDownStyleFg, 0xFFFFFFFF); + section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, 0xFFBD9939); + section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, 0x80EEEEEE); + section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, 0x55E0D4AF); + section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, 0xFFFFFFFF); + section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, 0x55BDBB39); + + section.Get("ButtonStyleFg", &info.uButtonStyleFg, 0xFFFFFFFF); + section.Get("ButtonStyleBg", &info.uButtonStyleBg, 0x55000000); + section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, 0xFFFFFFFF); + section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, 0xFFBD9939); + section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, 0xFFFFFFFF); + section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, 0xFFBD9939); + section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, 0x80EEEEEE); + section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, 0x55E0D4AF); + section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, 0xFFFFFFFF); + section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, 0x55BDBB39); + + section.Get("HeaderStyleFg", &info.uHeaderStyleFg, 0xFFFFFFFF); + section.Get("InfoStyleFg", &info.uInfoStyleFg, 0xFFFFFFFF); + section.Get("InfoStyleBg", &info.uInfoStyleBg, 0x00000000); + section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, 0xFFE3BE59); + section.Get("PopupStyleFg", &info.uPopupStyleFg, 0xFFFFFFFF); + section.Get("PopupStyleBg", &info.uPopupStyleBg, 0xFF303030); + + appendTheme(info); + } + } + } +} + +static UI::Style MakeStyle (uint32_t fg, uint32_t bg) { + UI::Style s; + s.background = UI::Drawable(bg); + s.fgColor = fg; + return s; +} + +void UpdateTheme() { + // First run, get the default in at least + if (themeInfos.empty()) { + ReloadAllThemeInfo(); + } + + size_t i; + for (i = 0; i < themeInfos.size(); ++i) { + if (themeInfos[i].name == g_Config.sThemeName) { + break; + } + } + + // Reset to Default if not found + if (i >= themeInfos.size()) { + g_Config.sThemeName = "Default"; + i = 0; + } + +#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI) + ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 22); + ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 15); + ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 12); +#else + ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), "", 20); + ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), "", 14); + ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), "", 11); +#endif + + ui_theme.checkOn = ImageID("I_CHECKEDBOX"); + ui_theme.checkOff = ImageID("I_SQUARE"); + ui_theme.whiteImage = ImageID("I_SOLIDWHITE"); + ui_theme.sliderKnob = ImageID("I_CIRCLE"); + ui_theme.dropShadow4Grid = ImageID("I_DROP_SHADOW"); + + // Actual configurable themes setting start here + ui_theme.itemStyle = MakeStyle(themeInfos[i].uItemStyleFg, themeInfos[i].uItemStyleBg); + ui_theme.itemFocusedStyle = MakeStyle(themeInfos[i].uItemFocusedStyleFg, themeInfos[i].uItemFocusedStyleBg); + ui_theme.itemDownStyle = MakeStyle(themeInfos[i].uItemDownStyleFg, themeInfos[i].uItemDownStyleBg); + ui_theme.itemDisabledStyle = MakeStyle(themeInfos[i].uItemDisabledStyleFg, themeInfos[i].uItemDisabledStyleBg); + ui_theme.itemHighlightedStyle = MakeStyle(themeInfos[i].uItemHighlightedStyleFg, themeInfos[i].uItemHighlightedStyleBg); + + ui_theme.buttonStyle = MakeStyle(themeInfos[i].uButtonStyleFg, themeInfos[i].uButtonStyleBg); + ui_theme.buttonFocusedStyle = MakeStyle(themeInfos[i].uButtonFocusedStyleFg, themeInfos[i].uButtonFocusedStyleBg); + ui_theme.buttonDownStyle = MakeStyle(themeInfos[i].uButtonDownStyleFg, themeInfos[i].uButtonDownStyleBg); + ui_theme.buttonDisabledStyle = MakeStyle(themeInfos[i].uButtonDisabledStyleFg, themeInfos[i].uButtonDisabledStyleBg); + ui_theme.buttonHighlightedStyle = MakeStyle(themeInfos[i].uButtonHighlightedStyleFg, themeInfos[i].uButtonHighlightedStyleBg); + + ui_theme.headerStyle.fgColor = themeInfos[i].uHeaderStyleFg; + ui_theme.infoStyle = MakeStyle(themeInfos[i].uInfoStyleFg, themeInfos[i].uInfoStyleBg); + + ui_theme.popupTitle.fgColor = themeInfos[i].uPopupTitleStyleFg; + ui_theme.popupStyle = MakeStyle(themeInfos[i].uPopupStyleFg, themeInfos[i].uPopupStyleBg); +} + +UI::Theme *GetTheme() { + return &ui_theme; +} + +void ReloadAllThemeInfo() { + std::vector directories; + directories.push_back(Path("themes")); // For VFS + directories.push_back(GetSysDirectory(DIRECTORY_CUSTOM_THEMES)); + LoadThemeInfo(directories); +} + +std::vector GetThemeInfoNames() { + std::vector names; + for (auto& i : themeInfos) + names.push_back(i.name); + + return names; +} \ No newline at end of file diff --git a/UI/Theme.h b/UI/Theme.h new file mode 100644 index 0000000000..e4e944efeb --- /dev/null +++ b/UI/Theme.h @@ -0,0 +1,25 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "Common/File/DirListing.h" +#include "Common/UI/Context.h" + +void ReloadAllThemeInfo(); + +std::vector GetThemeInfoNames(); +void UpdateTheme(); +UI::Theme *GetTheme(); \ No newline at end of file diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index b56a983acd..3264c2878f 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -67,6 +67,7 @@ + @@ -101,6 +102,7 @@ + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index b85cfdce34..c6534b2cd9 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -396,6 +396,7 @@ + @@ -431,6 +432,7 @@ + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b83f0223d9..bff3e7f199 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -686,6 +686,7 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/ProfilerDraw.cpp \ $(SRC)/UI/NativeApp.cpp \ $(SRC)/UI/TextureUtil.cpp \ + $(SRC)/UI/Theme.cpp \ $(SRC)/UI/ComboKeyMappingScreen.cpp ifneq ($(SKIPAPP),1) From 9ac07a10f6eb027fc451f68f8a21a94fda17fb1b Mon Sep 17 00:00:00 2001 From: iota97 Date: Fri, 11 Feb 2022 13:16:37 +0100 Subject: [PATCH 2/8] Forgot pragma, silly me --- UI/Theme.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UI/Theme.h b/UI/Theme.h index e4e944efeb..71a697fd83 100644 --- a/UI/Theme.h +++ b/UI/Theme.h @@ -1,3 +1,5 @@ +#pragma once + // Copyright (c) 2013- PPSSPP Project. // This program is free software: you can redistribute it and/or modify From 65b7b65bcd139d83bd5084dcaff65a662e7d9c2c Mon Sep 17 00:00:00 2001 From: iota97 Date: Sat, 12 Feb 2022 18:30:55 +0100 Subject: [PATCH 3/8] Adress feedback --- UI/Theme.cpp | 15 ++++++++------- UI/Theme.h | 1 - UI/UI.vcxproj | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 51659270b6..2c600d0bb3 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -24,6 +24,7 @@ #include "Common/File/FileUtil.h" #include "Common/File/VFS/VFS.h" #include "Common/Data/Format/IniFile.h" +#include "Common/File/DirListing.h" #include "Core/Config.h" @@ -31,7 +32,7 @@ #include "Common/UI/Context.h" #include "Core/System.h" -struct themeInfo { +struct ThemeInfo { std::string name; uint32_t uItemStyleFg = 0xFFFFFFFF; @@ -66,21 +67,21 @@ struct themeInfo { bool operator == (const std::string &other) { return name == other; } - bool operator == (const themeInfo &other) { + bool operator == (const ThemeInfo &other) { return name == other.name; } }; static UI::Theme ui_theme; -static std::vector themeInfos; +static std::vector themeInfos; static void LoadThemeInfo(const std::vector &directories) { themeInfos.clear(); - themeInfo def{}; + ThemeInfo def{}; def.name = "Default"; themeInfos.push_back(def); - auto appendTheme = [&](const themeInfo &info) { + auto appendTheme = [&](const ThemeInfo &info) { auto beginErase = std::remove(themeInfos.begin(), themeInfos.end(), info.name); if (beginErase != themeInfos.end()) { themeInfos.erase(beginErase, themeInfos.end()); @@ -118,7 +119,7 @@ static void LoadThemeInfo(const std::vector &directories) { // Alright, let's loop through the sections and see if any is a themes. for (size_t i = 0; i < ini.Sections().size(); i++) { Section §ion = ini.Sections()[i]; - themeInfo info; + ThemeInfo info; section.Get("Name", &info.name, section.name().c_str()); section.Get("ItemStyleFg", &info.uItemStyleFg, 0xFFFFFFFF); @@ -156,7 +157,7 @@ static void LoadThemeInfo(const std::vector &directories) { } } -static UI::Style MakeStyle (uint32_t fg, uint32_t bg) { +static UI::Style MakeStyle(uint32_t fg, uint32_t bg) { UI::Style s; s.background = UI::Drawable(bg); s.fgColor = fg; diff --git a/UI/Theme.h b/UI/Theme.h index 71a697fd83..9259313606 100644 --- a/UI/Theme.h +++ b/UI/Theme.h @@ -17,7 +17,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "Common/File/DirListing.h" #include "Common/UI/Context.h" void ReloadAllThemeInfo(); diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 3264c2878f..666e35aa02 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -102,7 +102,7 @@ - + From e5843160fe622d26214ee13913155bd5862112ac Mon Sep 17 00:00:00 2001 From: iota97 Date: Mon, 14 Feb 2022 07:37:56 +0100 Subject: [PATCH 4/8] Add themes to assets --- CMakeLists.txt | 7 +++-- UI/Theme.cpp | 53 +++++++++++++++++---------------- UI/Theme.h | 3 ++ android/ab.cmd | 1 + android/ab.sh | 1 + assets/themes/defaultthemes.ini | 28 +++++++++++++++++ ppsspp.iss | 1 + 7 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 assets/themes/defaultthemes.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a591daa71..91ad738c34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2261,6 +2261,7 @@ set(NativeAssets assets/debugger assets/lang assets/shaders + assets/themes assets/Roboto-Condensed.ttf assets/7z.png assets/compat.ini @@ -2367,6 +2368,7 @@ if(TargetBin) file(GLOB_RECURSE FLASH0_FILES assets/flash0/*) file(GLOB_RECURSE LANG_FILES assets/lang/*) file(GLOB_RECURSE SHADER_FILES assets/shaders/*) + file(GLOB_RECURSE THEME_FILE assets/themes/*) file(GLOB_RECURSE DEBUGGER_FILES assets/debugger/*) if(NOT IOS) @@ -2375,14 +2377,15 @@ if(TargetBin) set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/flash0/font") set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/lang") set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/shaders") + set_source_files_properties(${THEME_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/themes") set_source_files_properties(${DEBUGGER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/debugger") endif() if(IOS) - add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard") + add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard") file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/iOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPP.app/Frameworks/") else() - add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) + add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/") if(TARGET SDL2::SDL2 AND NOT USING_QT_UI) add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app") diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 2c600d0bb3..62a6888e49 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -81,6 +81,7 @@ static void LoadThemeInfo(const std::vector &directories) { def.name = "Default"; themeInfos.push_back(def); + // This will update the theme if already present, as such default in assets/theme will get priority if exist auto appendTheme = [&](const ThemeInfo &info) { auto beginErase = std::remove(themeInfos.begin(), themeInfos.end(), info.name); if (beginErase != themeInfos.end()) { @@ -122,34 +123,34 @@ static void LoadThemeInfo(const std::vector &directories) { ThemeInfo info; section.Get("Name", &info.name, section.name().c_str()); - section.Get("ItemStyleFg", &info.uItemStyleFg, 0xFFFFFFFF); - section.Get("ItemStyleBg", &info.uItemStyleBg, 0x55000000); - section.Get("ItemFocusedStyleFg", &info.uItemFocusedStyleFg, 0xFFFFFFFF); - section.Get("ItemFocusedStyleBg", &info.uItemFocusedStyleBg, 0xFFEDC24C); - section.Get("ItemDownStyleFg", &info.uItemDownStyleFg, 0xFFFFFFFF); - section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, 0xFFBD9939); - section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, 0x80EEEEEE); - section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, 0x55E0D4AF); - section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, 0xFFFFFFFF); - section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, 0x55BDBB39); + section.Get("ItemStyleFg", &info.uItemStyleFg, info.uItemStyleFg); + section.Get("ItemStyleBg", &info.uItemStyleBg, info.uItemStyleBg); + section.Get("ItemFocusedStyleFg", &info.uItemFocusedStyleFg, info.uItemFocusedStyleFg); + section.Get("ItemFocusedStyleBg", &info.uItemFocusedStyleBg, info.uItemFocusedStyleBg); + section.Get("ItemDownStyleFg", &info.uItemDownStyleFg, info.uItemDownStyleFg); + section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, info.uItemDownStyleBg); + section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, info.uItemDisabledStyleFg); + section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, info.uItemDisabledStyleBg); + section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, info.uItemHighlightedStyleFg); + section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, info.uItemHighlightedStyleBg); - section.Get("ButtonStyleFg", &info.uButtonStyleFg, 0xFFFFFFFF); - section.Get("ButtonStyleBg", &info.uButtonStyleBg, 0x55000000); - section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, 0xFFFFFFFF); - section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, 0xFFBD9939); - section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, 0xFFFFFFFF); - section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, 0xFFBD9939); - section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, 0x80EEEEEE); - section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, 0x55E0D4AF); - section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, 0xFFFFFFFF); - section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, 0x55BDBB39); + section.Get("ButtonStyleFg", &info.uButtonStyleFg, info.uButtonStyleFg); + section.Get("ButtonStyleBg", &info.uButtonStyleBg, info.uButtonStyleBg); + section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, info.uButtonFocusedStyleFg); + section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, info.uButtonFocusedStyleBg); + section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, info.uButtonDownStyleFg); + section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, info.uButtonDownStyleBg); + section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, info.uButtonDisabledStyleFg); + section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, info.uButtonDisabledStyleBg); + section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, info.uButtonHighlightedStyleFg); + section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, info.uButtonHighlightedStyleBg); - section.Get("HeaderStyleFg", &info.uHeaderStyleFg, 0xFFFFFFFF); - section.Get("InfoStyleFg", &info.uInfoStyleFg, 0xFFFFFFFF); - section.Get("InfoStyleBg", &info.uInfoStyleBg, 0x00000000); - section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, 0xFFE3BE59); - section.Get("PopupStyleFg", &info.uPopupStyleFg, 0xFFFFFFFF); - section.Get("PopupStyleBg", &info.uPopupStyleBg, 0xFF303030); + section.Get("HeaderStyleFg", &info.uHeaderStyleFg, info.uHeaderStyleFg); + section.Get("InfoStyleFg", &info.uInfoStyleFg, info.uInfoStyleFg); + section.Get("InfoStyleBg", &info.uInfoStyleBg, info.uInfoStyleBg); + section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, info.uPopupTitleStyleFg); + section.Get("PopupStyleFg", &info.uPopupStyleFg, info.uPopupStyleFg); + section.Get("PopupStyleBg", &info.uPopupStyleBg, info.uPopupStyleBg); appendTheme(info); } diff --git a/UI/Theme.h b/UI/Theme.h index 9259313606..adff861c04 100644 --- a/UI/Theme.h +++ b/UI/Theme.h @@ -17,6 +17,9 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include + #include "Common/UI/Context.h" void ReloadAllThemeInfo(); diff --git a/android/ab.cmd b/android/ab.cmd index 18aecf6608..f205269c8b 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -2,6 +2,7 @@ mkdir assets > nul xcopy ..\assets\flash0 assets\flash0\ /s /y Date: Mon, 14 Feb 2022 07:59:18 +0100 Subject: [PATCH 5/8] Allow translation --- UI/GameSettingsScreen.cpp | 3 ++- assets/lang/en_US.ini | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 37f4708867..379cb26711 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -221,6 +221,7 @@ void GameSettingsScreen::CreateViews() { auto dev = GetI18NCategory("Developer"); auto ri = GetI18NCategory("RemoteISO"); auto ps = GetI18NCategory("PostShaders"); + auto th = GetI18NCategory("Themes"); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); @@ -884,7 +885,7 @@ void GameSettingsScreen::CreateViews() { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } - PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, gr->T("Color Theme"), GetThemeInfoNames(), nullptr, screenManager())); + PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Color Theme"), GetThemeInfoNames(), th->GetName(), screenManager())); theme->OnChoice.Add([=](EventParams &e) { UpdateTheme(); diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index c9dc15deef..2dcc1b85d1 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -1211,6 +1211,10 @@ WARNING: Android battery save mode is on = WARNING: Android battery save mode is WARNING: Battery save mode is on = WARNING: Battery save mode is on Waves = Waves YYYYMMDD = YYYYMMDD +Color Theme = Color Theme + +[Themes] +Default = Default [Upgrade] Details = Details From 7860aea62fe43456ba9df1a33945fdc19acc6c1c Mon Sep 17 00:00:00 2001 From: iota97 Date: Mon, 14 Feb 2022 11:30:37 +0100 Subject: [PATCH 6/8] Fix disabled bg --- Common/UI/View.cpp | 29 +++++++++-------------------- UI/Theme.cpp | 4 ++-- assets/themes/defaultthemes.ini | 4 ++-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 428eee7d65..1e285d243a 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -415,6 +415,9 @@ ClickableItem::ClickableItem(LayoutParams *layoutParams) : Clickable(layoutParam void ClickableItem::Draw(UIContext &dc) { Style style = dc.theme->itemStyle; + if (!IsEnabled()) { + style = dc.theme->itemDisabledStyle; + } if (HasFocus()) { style = dc.theme->itemFocusedStyle; } @@ -475,27 +478,13 @@ void Choice::HighlightChanged(bool highlighted){ } void Choice::Draw(UIContext &dc) { - if (!IsSticky()) { - ClickableItem::Draw(dc); - } else { - Style style = dc.theme->itemStyle; - if (highlighted_) { - style = dc.theme->itemHighlightedStyle; - } - if (down_) { - style = dc.theme->itemDownStyle; - } - if (HasFocus()) { - style = dc.theme->itemFocusedStyle; - } - - DrawBG(dc, style); - } - Style style = dc.theme->itemStyle; - if (!IsEnabled()) { - style = dc.theme->itemDisabledStyle; - } + if (HasFocus()) style = dc.theme->itemFocusedStyle; + if (down_) style = dc.theme->itemDownStyle; + if (!IsEnabled()) style = dc.theme->itemDisabledStyle; + if (highlighted_) style = dc.theme->itemHighlightedStyle; + + DrawBG(dc, style); if (image_.isValid() && text_.empty()) { dc.Draw()->DrawImageRotated(image_, bounds_.centerX(), bounds_.centerY(), imgScale_, imgRot_, style.fgColor, imgFlipH_); diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 62a6888e49..3166310292 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -42,7 +42,7 @@ struct ThemeInfo { uint32_t uItemDownStyleFg = 0xFFFFFFFF; uint32_t uItemDownStyleBg = 0xFFBD9939; uint32_t uItemDisabledStyleFg = 0x80EEEEEE; - uint32_t uItemDisabledStyleBg = 0x55E0D4AF; + uint32_t uItemDisabledStyleBg = 0x55000000; uint32_t uItemHighlightedStyleFg = 0xFFFFFFFF; uint32_t uItemHighlightedStyleBg = 0x55BDBB39; @@ -53,7 +53,7 @@ struct ThemeInfo { uint32_t uButtonDownStyleFg = 0xFFFFFFFF; uint32_t uButtonDownStyleBg = 0xFFBD9939; uint32_t uButtonDisabledStyleFg = 0x80EEEEEE; - uint32_t uButtonDisabledStyleBg = 0x55E0D4AF; + uint32_t uButtonDisabledStyleBg = 0x55000000; uint32_t uButtonHighlightedStyleFg = 0xFFFFFFFF; uint32_t uButtonHighlightedStyleBg = 0x55BDBB39; diff --git a/assets/themes/defaultthemes.ini b/assets/themes/defaultthemes.ini index f01e9de862..fdffbf4508 100644 --- a/assets/themes/defaultthemes.ini +++ b/assets/themes/defaultthemes.ini @@ -7,7 +7,7 @@ ItemFocusedStyleBg = 0xffedc24c ItemDownStyleFg = 0xffffffff ItemDownStyleBg = 0xffbd9939 ItemDisabledStyleFg = 0x80eeeeee -ItemDisabledStyleBg = 0x55e0d4af +ItemDisabledStyleBg = 0x55000000 ItemHighlightedStyleFg = 0xffffffff ItemHighlightedStyleBg = 0x55bdbb39 ButtonStyleFg = 0xffffffff @@ -17,7 +17,7 @@ ButtonFocusedStyleBg = 0xffedc24c ButtonDownStyleFg = 0xffffffff ButtonDownStyleBg = 0xffbd9939 ButtonDisabledStyleFg = 0x80eeeeee -ButtonDisabledStyleBg = 0x55e0d4af +ButtonDisabledStyleBg = 0x55000000 ButtonHighlightedStyleFg = 0xffffffff ButtonHighlightedStyleBg = 0x55bdbb39 HeaderStyleFg = 0xffffffff From 561870dc2551e70fdfff700ff3c8377e7bb62e51 Mon Sep 17 00:00:00 2001 From: iota97 Date: Mon, 14 Feb 2022 13:57:22 +0100 Subject: [PATCH 7/8] Merge item and button style, remove hightlighed and few other fixes --- Common/UI/View.cpp | 32 ++++++++++++++------------------ Common/UI/View.h | 13 +++---------- Common/UI/ViewGroup.cpp | 6 ------ Common/UI/ViewGroup.h | 1 - UI/ComboKeyMappingScreen.cpp | 4 ++-- UI/ControlMappingScreen.cpp | 2 +- UI/MainScreen.cpp | 14 +++++++------- UI/MiscScreens.cpp | 6 +++--- UI/Theme.cpp | 33 --------------------------------- assets/themes/defaultthemes.ini | 12 ------------ 10 files changed, 30 insertions(+), 93 deletions(-) diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 1e285d243a..03459a296c 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -473,16 +473,11 @@ float Choice::CalculateTextScale(const UIContext &dc, float availWidth) const { return 1.0f; } -void Choice::HighlightChanged(bool highlighted){ - highlighted_ = highlighted; -} - void Choice::Draw(UIContext &dc) { Style style = dc.theme->itemStyle; if (HasFocus()) style = dc.theme->itemFocusedStyle; if (down_) style = dc.theme->itemDownStyle; if (!IsEnabled()) style = dc.theme->itemDisabledStyle; - if (highlighted_) style = dc.theme->itemHighlightedStyle; DrawBG(dc, style); @@ -499,7 +494,7 @@ void Choice::Draw(UIContext &dc) { paddingX += image->w + 6; availWidth -= image->w + 6; // TODO: Use scale rotation and flip here as well (DrawImageRotated is always ALIGN_CENTER for now) - dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER); + dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_LEFT | ALIGN_VCENTER); } float scale = CalculateTextScale(dc, availWidth); @@ -509,7 +504,8 @@ void Choice::Draw(UIContext &dc) { dc.DrawTextRect(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT); } else { if (rightIconImage_.isValid()) { - dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, style.fgColor, rightIconFlipH_); + uint32_t col = rightIconKeepColor_ ? 0xffffffff : style.fgColor; // Don't apply theme to gold icon + dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, col, rightIconFlipH_); } Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h); dc.DrawTextRect(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT); @@ -542,7 +538,7 @@ void InfoItem::Draw(UIContext &dc) { UI::Style style = HasFocus() ? dc.theme->itemFocusedStyle : dc.theme->infoStyle; if (choiceStyle_) { - style = HasFocus() ? dc.theme->buttonFocusedStyle : dc.theme->buttonStyle; + style = HasFocus() ? dc.theme->itemFocusedStyle : dc.theme->itemStyle; } @@ -810,11 +806,11 @@ void Button::Click() { } void Button::Draw(UIContext &dc) { - Style style = dc.theme->buttonStyle; + Style style = dc.theme->itemStyle; - if (HasFocus()) style = dc.theme->buttonFocusedStyle; - if (down_) style = dc.theme->buttonDownStyle; - if (!IsEnabled()) style = dc.theme->buttonDisabledStyle; + if (HasFocus()) style = dc.theme->itemFocusedStyle; + if (down_) style = dc.theme->itemDownStyle; + if (!IsEnabled()) style = dc.theme->itemDisabledStyle; // dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor); DrawBG(dc, style); @@ -829,13 +825,13 @@ void Button::Draw(UIContext &dc) { dc.SetFontStyle(dc.theme->uiFont); dc.SetFontScale(scale_, scale_); if (imageID_.isValid() && (ignoreText_ || text_.empty())) { - dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), scale_, 0xFFFFFFFF, ALIGN_CENTER); + dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), scale_, style.fgColor, ALIGN_CENTER); } else if (!text_.empty()) { float textX = bounds_.centerX(); if (imageID_.isValid()) { const AtlasImage *img = dc.Draw()->GetAtlas()->getImage(imageID_); if (img) { - dc.Draw()->DrawImage(imageID_, bounds_.centerX() - tw / 2 - 5, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER); + dc.Draw()->DrawImage(imageID_, bounds_.centerX() - tw / 2 - 5, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); textX += img->w / 2.0f; } } @@ -873,13 +869,13 @@ void RadioButton::Click() { } void RadioButton::Draw(UIContext &dc) { - Style style = dc.theme->buttonStyle; + Style style = dc.theme->itemStyle; bool checked = *value_ == thisButtonValue_; - if (HasFocus()) style = dc.theme->buttonFocusedStyle; - if (down_) style = dc.theme->buttonDownStyle; - if (!IsEnabled()) style = dc.theme->buttonDisabledStyle; + if (HasFocus()) style = dc.theme->itemFocusedStyle; + if (down_) style = dc.theme->itemDownStyle; + if (!IsEnabled()) style = dc.theme->itemDisabledStyle; DrawBG(dc, style); diff --git a/Common/UI/View.h b/Common/UI/View.h index c591573d9a..a8ee09bdb1 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -100,17 +100,10 @@ struct Theme { ImageID whiteImage; ImageID dropShadow4Grid; - Style buttonStyle; - Style buttonFocusedStyle; - Style buttonDownStyle; - Style buttonDisabledStyle; - Style buttonHighlightedStyle; - Style itemStyle; Style itemDownStyle; Style itemFocusedStyle; Style itemDisabledStyle; - Style itemHighlightedStyle; Style headerStyle; Style infoStyle; @@ -716,14 +709,14 @@ public: : ClickableItem(layoutParams), image_(image), rightIconImage_(ImageID::invalid()), imgScale_(imgScale), imgRot_(imgRot), imgFlipH_(imgFlipH) {} void Click() override; - virtual void HighlightChanged(bool highlighted); void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override; void Draw(UIContext &dc) override; std::string DescribeText() const override; virtual void SetCentered(bool c) { centered_ = c; } - virtual void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false) { + virtual void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false, bool keepColor = true) { + rightIconKeepColor_ = keepColor; rightIconScale_ = scale; rightIconRot_ = rot; rightIconFlipH_ = flipH; @@ -742,9 +735,9 @@ protected: float rightIconScale_; float rightIconRot_; bool rightIconFlipH_; + bool rightIconKeepColor_; Padding textPadding_; bool centered_ = false; - bool highlighted_ = false; float imgScale_ = 1.0f; float imgRot_ = 0.0f; bool imgFlipH_ = false; diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 5974ed7d04..f4fb73ffa3 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -1505,12 +1505,6 @@ void ChoiceStrip::SetSelection(int sel, bool triggerClick) { } } -void ChoiceStrip::HighlightChoice(int choice) { - if (choice < (int)views_.size()) { - Choice(choice)->HighlightChanged(true); - } -} - void ChoiceStrip::EnableChoice(int choice, bool enabled) { if (choice < (int)views_.size()) { Choice(choice)->SetEnabled(enabled); diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index ebb305252b..5b552c5f0f 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -330,7 +330,6 @@ public: int GetSelection() const { return selected_; } void SetSelection(int sel, bool triggerClick); - void HighlightChoice(int choice); void EnableChoice(int choice, bool enabled); bool Key(const KeyInput &input) override; diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index 931c0b0d9b..11d3ad0aef 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -212,7 +212,7 @@ void ComboKeyScreen::CreateViews() { vertLayout->Add(new CheckBox(show, co->T("Visible"))); Choice *icon = vertLayout->Add(new Choice(co->T("Icon"))); - icon->SetIcon(ImageID(comboKeyImages[cfg->image].i), 1.0f, comboKeyImages[cfg->image].r*PI/180); // Set right icon on the choice + icon->SetIcon(ImageID(comboKeyImages[cfg->image].i), 1.0f, comboKeyImages[cfg->image].r*PI/180, false, false); // Set right icon on the choice icon->OnClick.Add([=](UI::EventParams &e) { auto iconScreen = new ButtonIconScreen(co->T("Icon"), &(cfg->image)); if (e.v) @@ -223,7 +223,7 @@ void ComboKeyScreen::CreateViews() { }); Choice *shape = vertLayout->Add(new Choice(co->T("Shape"))); - shape->SetIcon(ImageID(comboKeyShapes[cfg->shape].l), 0.6f, comboKeyShapes[cfg->shape].r*PI/180, comboKeyShapes[cfg->shape].f); // Set right icon on the choice + shape->SetIcon(ImageID(comboKeyShapes[cfg->shape].l), 0.6f, comboKeyShapes[cfg->shape].r*PI/180, comboKeyShapes[cfg->shape].f, false); // Set right icon on the choice shape->OnClick.Add([=](UI::EventParams &e) { auto shape = new ButtonShapeScreen(co->T("Shape"), &(cfg->shape)); if (e.v) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index a4f664237d..126f2629f3 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -953,7 +953,7 @@ public: void Draw(UIContext &dc) override { uint32_t c = 0xFFFFFFFF; if (HasFocus() || Selected()) - c = dc.theme->buttonFocusedStyle.background.color; + c = dc.theme->itemFocusedStyle.background.color; float scales[2]{}; if (bgImg_.isValid()) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 5198a2b23d..2fd76ad4fd 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -401,7 +401,7 @@ void GameButton::Draw(UIContext &dc) { if (gridStyle_ && g_Config.bShowIDOnGameIcon) { dc.SetFontScale(0.5f*g_Config.fGameGridScale, 0.5f*g_Config.fGameGridScale); dc.DrawText(ginfo->id_version.c_str(), x+5, y+1, 0xFF000000, ALIGN_TOPLEFT); - dc.DrawText(ginfo->id_version.c_str(), x+4, y, 0xFFffFFff, ALIGN_TOPLEFT); + dc.DrawText(ginfo->id_version.c_str(), x+4, y, dc.theme->infoStyle.fgColor, ALIGN_TOPLEFT); dc.SetFontScale(1.0f, 1.0f); } if (overlayColor) { @@ -441,11 +441,11 @@ private: void DirButton::Draw(UIContext &dc) { using namespace UI; - Style style = dc.theme->buttonStyle; + Style style = dc.theme->itemStyle; - if (HasFocus()) style = dc.theme->buttonFocusedStyle; - if (down_) style = dc.theme->buttonDownStyle; - if (!IsEnabled()) style = dc.theme->buttonDisabledStyle; + if (HasFocus()) style = dc.theme->itemFocusedStyle; + if (down_) style = dc.theme->itemDownStyle; + if (!IsEnabled()) style = dc.theme->itemDisabledStyle; dc.FillRect(style.background, bounds_); @@ -470,7 +470,7 @@ void DirButton::Draw(UIContext &dc) { if (image == ImageID("I_FOLDER")) { dc.DrawText(text.c_str(), bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); } else { - dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, 0xFFFFFFFF, ALIGN_CENTER); + dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, style.fgColor, ALIGN_CENTER); } dc.PopScissor(); } else { @@ -479,7 +479,7 @@ void DirButton::Draw(UIContext &dc) { dc.PushScissor(bounds_); scissor = true; } - dc.Draw()->DrawImage(image, bounds_.x + 72, bounds_.centerY(), 0.88f*(gridStyle_ ? g_Config.fGameGridScale : 1.0), 0xFFFFFFFF, ALIGN_CENTER); + dc.Draw()->DrawImage(image, bounds_.x + 72, bounds_.centerY(), 0.88f*(gridStyle_ ? g_Config.fGameGridScale : 1.0), style.fgColor, ALIGN_CENTER); dc.DrawText(text.c_str(), bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); if (scissor) { diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 182a187fbd..5914fdce19 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -767,11 +767,11 @@ void LogoScreen::render() { // Manually formatting UTF-8 is fun. \xXX doesn't work everywhere. snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5); if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { - dc.Draw()->DrawImage(ImageID("I_ICONGOLD"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); + dc.Draw()->DrawImage(ImageID("I_ICONGOLD"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, 0xFFFFFFFF, ALIGN_CENTER); } else { - dc.Draw()->DrawImage(ImageID("I_ICON"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); + dc.Draw()->DrawImage(ImageID("I_ICON"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, 0xFFFFFFFF, ALIGN_CENTER); } - dc.Draw()->DrawImage(ImageID("I_LOGO"), bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, textColor, ALIGN_CENTER); + dc.Draw()->DrawImage(ImageID("I_LOGO"), bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, 0xFFFFFFFF, ALIGN_CENTER); //dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", bounds.w / 2, bounds.h / 2 - 30, textColor, ALIGN_CENTER); dc.SetFontScale(1.0f, 1.0f); dc.SetFontStyle(dc.theme->uiFont); diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 3166310292..671dfc940f 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -43,19 +43,6 @@ struct ThemeInfo { uint32_t uItemDownStyleBg = 0xFFBD9939; uint32_t uItemDisabledStyleFg = 0x80EEEEEE; uint32_t uItemDisabledStyleBg = 0x55000000; - uint32_t uItemHighlightedStyleFg = 0xFFFFFFFF; - uint32_t uItemHighlightedStyleBg = 0x55BDBB39; - - uint32_t uButtonStyleFg = 0xFFFFFFFF; - uint32_t uButtonStyleBg = 0x55000000; - uint32_t uButtonFocusedStyleFg = 0xFFFFFFFF; - uint32_t uButtonFocusedStyleBg = 0xFFBD9939; - uint32_t uButtonDownStyleFg = 0xFFFFFFFF; - uint32_t uButtonDownStyleBg = 0xFFBD9939; - uint32_t uButtonDisabledStyleFg = 0x80EEEEEE; - uint32_t uButtonDisabledStyleBg = 0x55000000; - uint32_t uButtonHighlightedStyleFg = 0xFFFFFFFF; - uint32_t uButtonHighlightedStyleBg = 0x55BDBB39; uint32_t uHeaderStyleFg = 0xFFFFFFFF; uint32_t uInfoStyleFg = 0xFFFFFFFF; @@ -131,19 +118,6 @@ static void LoadThemeInfo(const std::vector &directories) { section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, info.uItemDownStyleBg); section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, info.uItemDisabledStyleFg); section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, info.uItemDisabledStyleBg); - section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, info.uItemHighlightedStyleFg); - section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, info.uItemHighlightedStyleBg); - - section.Get("ButtonStyleFg", &info.uButtonStyleFg, info.uButtonStyleFg); - section.Get("ButtonStyleBg", &info.uButtonStyleBg, info.uButtonStyleBg); - section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, info.uButtonFocusedStyleFg); - section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, info.uButtonFocusedStyleBg); - section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, info.uButtonDownStyleFg); - section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, info.uButtonDownStyleBg); - section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, info.uButtonDisabledStyleFg); - section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, info.uButtonDisabledStyleBg); - section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, info.uButtonHighlightedStyleFg); - section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, info.uButtonHighlightedStyleBg); section.Get("HeaderStyleFg", &info.uHeaderStyleFg, info.uHeaderStyleFg); section.Get("InfoStyleFg", &info.uInfoStyleFg, info.uInfoStyleFg); @@ -205,13 +179,6 @@ void UpdateTheme() { ui_theme.itemFocusedStyle = MakeStyle(themeInfos[i].uItemFocusedStyleFg, themeInfos[i].uItemFocusedStyleBg); ui_theme.itemDownStyle = MakeStyle(themeInfos[i].uItemDownStyleFg, themeInfos[i].uItemDownStyleBg); ui_theme.itemDisabledStyle = MakeStyle(themeInfos[i].uItemDisabledStyleFg, themeInfos[i].uItemDisabledStyleBg); - ui_theme.itemHighlightedStyle = MakeStyle(themeInfos[i].uItemHighlightedStyleFg, themeInfos[i].uItemHighlightedStyleBg); - - ui_theme.buttonStyle = MakeStyle(themeInfos[i].uButtonStyleFg, themeInfos[i].uButtonStyleBg); - ui_theme.buttonFocusedStyle = MakeStyle(themeInfos[i].uButtonFocusedStyleFg, themeInfos[i].uButtonFocusedStyleBg); - ui_theme.buttonDownStyle = MakeStyle(themeInfos[i].uButtonDownStyleFg, themeInfos[i].uButtonDownStyleBg); - ui_theme.buttonDisabledStyle = MakeStyle(themeInfos[i].uButtonDisabledStyleFg, themeInfos[i].uButtonDisabledStyleBg); - ui_theme.buttonHighlightedStyle = MakeStyle(themeInfos[i].uButtonHighlightedStyleFg, themeInfos[i].uButtonHighlightedStyleBg); ui_theme.headerStyle.fgColor = themeInfos[i].uHeaderStyleFg; ui_theme.infoStyle = MakeStyle(themeInfos[i].uInfoStyleFg, themeInfos[i].uInfoStyleBg); diff --git a/assets/themes/defaultthemes.ini b/assets/themes/defaultthemes.ini index fdffbf4508..bbe6a67022 100644 --- a/assets/themes/defaultthemes.ini +++ b/assets/themes/defaultthemes.ini @@ -8,18 +8,6 @@ ItemDownStyleFg = 0xffffffff ItemDownStyleBg = 0xffbd9939 ItemDisabledStyleFg = 0x80eeeeee ItemDisabledStyleBg = 0x55000000 -ItemHighlightedStyleFg = 0xffffffff -ItemHighlightedStyleBg = 0x55bdbb39 -ButtonStyleFg = 0xffffffff -ButtonStyleBg = 0x55000000 -ButtonFocusedStyleFg = 0xffffffff -ButtonFocusedStyleBg = 0xffedc24c -ButtonDownStyleFg = 0xffffffff -ButtonDownStyleBg = 0xffbd9939 -ButtonDisabledStyleFg = 0x80eeeeee -ButtonDisabledStyleBg = 0x55000000 -ButtonHighlightedStyleFg = 0xffffffff -ButtonHighlightedStyleBg = 0x55bdbb39 HeaderStyleFg = 0xffffffff InfoStyleFg = 0xffffffff InfoStyleBg = 0x00000000 From aa9d097d11b54a7cf34a802805a0688b510b5fc9 Mon Sep 17 00:00:00 2001 From: iota97 Date: Mon, 14 Feb 2022 15:07:33 +0100 Subject: [PATCH 8/8] More fixes for themes --- Common/UI/UIScreen.cpp | 6 ++++++ Common/UI/View.cpp | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 15215148af..2df6ea2bf5 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -822,6 +822,12 @@ void AbstractChoiceWithValueDisplay::Draw(UIContext &dc) { if (!IsEnabled()) { style = dc.theme->itemDisabledStyle; } + if (HasFocus()) { + style = dc.theme->itemFocusedStyle; + } + if (down_) { + style = dc.theme->itemDownStyle; + } int paddingX = 12; dc.SetFontStyle(dc.theme->uiFont); diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 03459a296c..9df5e38286 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -687,8 +687,15 @@ EventReturn CheckBox::OnClicked(EventParams &e) { void CheckBox::Draw(UIContext &dc) { Style style = dc.theme->itemStyle; - if (!IsEnabled()) + if (!IsEnabled()) { style = dc.theme->itemDisabledStyle; + } + if (HasFocus()) { + style = dc.theme->itemFocusedStyle; + } + if (down_) { + style = dc.theme->itemDownStyle; + } dc.SetFontStyle(dc.theme->uiFont); ClickableItem::Draw(dc);