mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 23:15:38 +00:00
Add help component theme options textStyle
.
This commit is contained in:
parent
cc38f06141
commit
5ed0d7b7eb
|
@ -20,6 +20,7 @@ HelpStyle::HelpStyle()
|
||||||
textColor = 0x777777FF;
|
textColor = 0x777777FF;
|
||||||
entrySpacing = 16.0f;
|
entrySpacing = 16.0f;
|
||||||
iconTextSpacing = 8.0f;
|
iconTextSpacing = 8.0f;
|
||||||
|
textStyle = "uppercase";
|
||||||
|
|
||||||
if (FONT_SIZE_SMALL != 0)
|
if (FONT_SIZE_SMALL != 0)
|
||||||
font = Font::get(FONT_SIZE_SMALL);
|
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"))
|
if (elem->has("iconTextSpacing"))
|
||||||
iconTextSpacing = elem->get<float>("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;
|
std::shared_ptr<Font> font;
|
||||||
float entrySpacing;
|
float entrySpacing;
|
||||||
float iconTextSpacing;
|
float iconTextSpacing;
|
||||||
|
std::string textStyle;
|
||||||
|
|
||||||
HelpStyle(); // Default values.
|
HelpStyle(); // Default values.
|
||||||
void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view);
|
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},
|
{"fontPath", PATH},
|
||||||
{"fontSize", FLOAT},
|
{"fontSize", FLOAT},
|
||||||
{"entrySpacing", FLOAT},
|
{"entrySpacing", FLOAT},
|
||||||
{"iconTextSpacing", FLOAT}}},
|
{"iconTextSpacing", FLOAT},
|
||||||
|
{"textStyle", STRING}}},
|
||||||
{"navigationsounds",
|
{"navigationsounds",
|
||||||
{{"systembrowseSound", PATH},
|
{{"systembrowseSound", PATH},
|
||||||
{"quicksysselectSound", PATH},
|
{"quicksysselectSound", PATH},
|
||||||
|
|
|
@ -128,8 +128,19 @@ void HelpComponent::updateGrid()
|
||||||
icon->setResize(0, height);
|
icon->setResize(0, height);
|
||||||
icons.push_back(icon);
|
icons.push_back(icon);
|
||||||
|
|
||||||
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(it->second),
|
// Format label according to theme style.
|
||||||
font, mStyle.textColor);
|
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);
|
labels.push_back(lbl);
|
||||||
|
|
||||||
width +=
|
width +=
|
||||||
|
|
|
@ -541,6 +541,29 @@ namespace Utils
|
||||||
return stringUpper;
|
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)
|
std::string trim(const std::string& stringArg)
|
||||||
{
|
{
|
||||||
const size_t strBegin = stringArg.find_first_not_of(" \t");
|
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);
|
size_t moveCursor(const std::string& stringArg, const size_t cursor, const int amount);
|
||||||
std::string toLower(const std::string& stringArg);
|
std::string toLower(const std::string& stringArg);
|
||||||
std::string toUpper(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 trim(const std::string& stringArg);
|
||||||
std::string replace(const std::string& stringArg,
|
std::string replace(const std::string& stringArg,
|
||||||
const std::string& replace,
|
const std::string& replace,
|
||||||
|
|
Loading…
Reference in a new issue