mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Add help component theme options entrySpacing
and iconTextSpacing
.
This commit is contained in:
parent
d25670361a
commit
6672fd1ec8
|
@ -18,6 +18,8 @@ HelpStyle::HelpStyle()
|
|||
origin = glm::vec2{};
|
||||
iconColor = 0x777777FF;
|
||||
textColor = 0x777777FF;
|
||||
entrySpacing = 16.0f;
|
||||
iconTextSpacing = 8.0f;
|
||||
|
||||
if (FONT_SIZE_SMALL != 0)
|
||||
font = Font::get(FONT_SIZE_SMALL);
|
||||
|
@ -47,4 +49,10 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
|
|||
|
||||
if (elem->has("fontPath") || elem->has("fontSize"))
|
||||
font = Font::getFromTheme(elem, ThemeFlags::ALL, font);
|
||||
|
||||
if (elem->has("entrySpacing"))
|
||||
entrySpacing = elem->get<float>("entrySpacing");
|
||||
|
||||
if (elem->has("iconTextSpacing"))
|
||||
iconTextSpacing = elem->get<float>("iconTextSpacing");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ struct HelpStyle {
|
|||
unsigned int iconColor;
|
||||
unsigned int textColor;
|
||||
std::shared_ptr<Font> font;
|
||||
float entrySpacing;
|
||||
float iconTextSpacing;
|
||||
|
||||
HelpStyle(); // Default values.
|
||||
void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view);
|
||||
|
|
|
@ -153,7 +153,9 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{"textColor", COLOR},
|
||||
{"iconColor", COLOR},
|
||||
{"fontPath", PATH},
|
||||
{"fontSize", FLOAT}}},
|
||||
{"fontSize", FLOAT},
|
||||
{"entrySpacing", FLOAT},
|
||||
{"iconTextSpacing", FLOAT}}},
|
||||
{"navigationsounds",
|
||||
{{"systembrowseSound", PATH},
|
||||
{"quicksysselectSound", PATH},
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
#include "resources/TextureResource.h"
|
||||
#include "utils/StringUtil.h"
|
||||
|
||||
#define ICON_TEXT_SPACING 8.0f // Space between [icon] and [text] (px).
|
||||
#define ENTRY_SPACING 16.0f // Space between [text] and next [icon] (px).
|
||||
|
||||
static std::map<std::string, std::string> sIconPathMap{};
|
||||
|
||||
HelpComponent::HelpComponent(Window* window)
|
||||
|
@ -135,8 +132,9 @@ void HelpComponent::updateGrid()
|
|||
font, mStyle.textColor);
|
||||
labels.push_back(lbl);
|
||||
|
||||
width += icon->getSize().x + lbl->getSize().x +
|
||||
((ICON_TEXT_SPACING + ENTRY_SPACING) * Renderer::getScreenWidthModifier());
|
||||
width +=
|
||||
icon->getSize().x + lbl->getSize().x +
|
||||
((mStyle.iconTextSpacing + mStyle.entrySpacing) * Renderer::getScreenWidthModifier());
|
||||
}
|
||||
|
||||
mGrid->setSize(width, height);
|
||||
|
@ -144,8 +142,8 @@ void HelpComponent::updateGrid()
|
|||
for (unsigned int i = 0; i < icons.size(); i++) {
|
||||
const int col = i * 4;
|
||||
mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width);
|
||||
mGrid->setColWidthPerc(col + 1,
|
||||
(ICON_TEXT_SPACING * Renderer::getScreenWidthModifier()) / width);
|
||||
mGrid->setColWidthPerc(
|
||||
col + 1, (mStyle.iconTextSpacing * Renderer::getScreenWidthModifier()) / width);
|
||||
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
||||
|
||||
mGrid->setEntry(icons.at(i), glm::ivec2{col, 0}, false, false);
|
||||
|
|
Loading…
Reference in a new issue