mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
Add help component theme options textStyle
.
This commit is contained in:
parent
6672fd1ec8
commit
dfffd1057d
|
@ -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<ThemeData>& theme, const std::s
|
|||
|
||||
if (elem->has("iconTextSpacing"))
|
||||
iconTextSpacing = elem->get<float>("iconTextSpacing");
|
||||
|
||||
if (elem->has("textStyle"))
|
||||
textStyle = elem->get<std::string>("textStyle");
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ struct HelpStyle {
|
|||
std::shared_ptr<Font> font;
|
||||
float entrySpacing;
|
||||
float iconTextSpacing;
|
||||
std::string textStyle;
|
||||
|
||||
HelpStyle(); // Default values.
|
||||
void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view);
|
||||
|
|
|
@ -155,7 +155,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{"fontPath", PATH},
|
||||
{"fontSize", FLOAT},
|
||||
{"entrySpacing", FLOAT},
|
||||
{"iconTextSpacing", FLOAT}}},
|
||||
{"iconTextSpacing", FLOAT},
|
||||
{"textStyle", STRING}}},
|
||||
{"navigationsounds",
|
||||
{{"systembrowseSound", PATH},
|
||||
{"quicksysselectSound", PATH},
|
||||
|
|
|
@ -128,8 +128,19 @@ void HelpComponent::updateGrid()
|
|||
icon->setResize(0, height);
|
||||
icons.push_back(icon);
|
||||
|
||||
auto lbl = std::make_shared<TextComponent>(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<TextComponent>(mWindow, lblInput, font, mStyle.textColor);
|
||||
labels.push_back(lbl);
|
||||
|
||||
width +=
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue