diff --git a/es-core/src/HelpStyle.cpp b/es-core/src/HelpStyle.cpp index bd59352c2..7294c2f21 100644 --- a/es-core/src/HelpStyle.cpp +++ b/es-core/src/HelpStyle.cpp @@ -20,6 +20,7 @@ HelpStyle::HelpStyle() textColor = 0x777777FF; entrySpacing = 16.0f; iconTextSpacing = 8.0f; + textStyle = "uppercase"; if (FONT_SIZE_SMALL != 0) font = Font::get(FONT_SIZE_SMALL); @@ -55,4 +56,7 @@ void HelpStyle::applyTheme(const std::shared_ptr& theme, const std::s if (elem->has("iconTextSpacing")) iconTextSpacing = elem->get("iconTextSpacing"); + + if (elem->has("textStyle")) + textStyle = elem->get("textStyle"); } diff --git a/es-core/src/HelpStyle.h b/es-core/src/HelpStyle.h index 118b15c46..5a7afe50e 100644 --- a/es-core/src/HelpStyle.h +++ b/es-core/src/HelpStyle.h @@ -26,6 +26,7 @@ struct HelpStyle { std::shared_ptr font; float entrySpacing; float iconTextSpacing; + std::string textStyle; HelpStyle(); // Default values. void applyTheme(const std::shared_ptr& theme, const std::string& view); diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 753033603..a208e14ff 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -155,7 +155,8 @@ std::map> The {"fontPath", PATH}, {"fontSize", FLOAT}, {"entrySpacing", FLOAT}, - {"iconTextSpacing", FLOAT}}}, + {"iconTextSpacing", FLOAT}, + {"textStyle", STRING}}}, {"navigationsounds", {{"systembrowseSound", PATH}, {"quicksysselectSound", PATH}, diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 8899b173f..647fa6b15 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -128,8 +128,19 @@ void HelpComponent::updateGrid() icon->setResize(0, height); icons.push_back(icon); - auto lbl = std::make_shared(mWindow, Utils::String::toUpper(it->second), - font, mStyle.textColor); + // Format label according to theme style. + std::string lblInput = it->second; + if (mStyle.textStyle == "lowercase") { + lblInput = Utils::String::toLower(lblInput); + } + else if (mStyle.textStyle == "camelcase") { + lblInput = Utils::String::toCamelCase(lblInput); + } + else { + lblInput = Utils::String::toUpper(lblInput); + } + + auto lbl = std::make_shared(mWindow, lblInput, font, mStyle.textColor); labels.push_back(lbl); width += diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index edb2f56d2..91141ce1f 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -541,6 +541,29 @@ namespace Utils return stringUpper; } + std::string toCamelCase(const std::string& stringArg) + { + std::string line = stringArg; + bool active = true; + + for (int i = 0; line[i] != '\0'; i++) { + if (std::isalpha(line[i])) { + if (active) { + line[i] = Utils::String::toUpper(std::string(1, line[i]))[0]; + active = false; + } + else { + line[i] = Utils::String::toLower(std::string(1, line[i]))[0]; + } + } + else if (line[i] == ' ') { + active = true; + } + } + + return line; + } + std::string trim(const std::string& stringArg) { const size_t strBegin = stringArg.find_first_not_of(" \t"); diff --git a/es-core/src/utils/StringUtil.h b/es-core/src/utils/StringUtil.h index 98b1ecb23..28e9c9060 100644 --- a/es-core/src/utils/StringUtil.h +++ b/es-core/src/utils/StringUtil.h @@ -26,6 +26,7 @@ namespace Utils size_t moveCursor(const std::string& stringArg, const size_t cursor, const int amount); std::string toLower(const std::string& stringArg); std::string toUpper(const std::string& stringArg); + std::string toCamelCase(const std::string& stringArg); std::string trim(const std::string& stringArg); std::string replace(const std::string& stringArg, const std::string& replace,