mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Added an 'entryRelativeScale' property to the helpsystem element
This commit is contained in:
parent
da11140626
commit
fa503fef7a
|
|
@ -566,6 +566,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"scope", STRING},
|
||||
{"entries", STRING},
|
||||
{"entryLayout", STRING},
|
||||
{"entryRelativeScale", FLOAT},
|
||||
{"entrySpacing", FLOAT},
|
||||
{"entrySpacingDimmed", FLOAT},
|
||||
{"iconTextSpacing", FLOAT},
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ HelpComponent::HelpComponent(std::shared_ptr<Font> font)
|
|||
, mStyleBackgroundCornerRadius {0.0f}
|
||||
, mStyleColorGradientHorizontal {true}
|
||||
, mStyleEntryLayout {EntryLayout::ICON_FIRST}
|
||||
, mEntryRelativeScale {1.0f}
|
||||
, mLetterHeight {mStyleFont->getLetterHeight() * 1.25f}
|
||||
, mLetterHeightDimmed {mLetterHeight}
|
||||
, mStyleRotation {0.0f}
|
||||
, mStyleEntrySpacing {0.00833f}
|
||||
, mStyleEntrySpacingDimmed {mStyleEntrySpacing}
|
||||
|
|
@ -166,14 +169,38 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
mRenderer->getScreenWidth();
|
||||
}
|
||||
|
||||
if (elem->has("entryRelativeScale"))
|
||||
mEntryRelativeScale = glm::clamp(elem->get<float>("entryRelativeScale"), 0.2f, 3.0f);
|
||||
|
||||
if (elem->has("fontPath") || elem->has("fontSize")) {
|
||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont);
|
||||
if (!elem->has("fontSizeDimmed"))
|
||||
mStyleFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont);
|
||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f, 1.0f, false, true);
|
||||
mLetterHeight = mStyleFont->getLetterHeight() * 1.25f;
|
||||
if (!elem->has("fontSizeDimmed")) {
|
||||
mStyleFontDimmed = Font::getFromTheme(
|
||||
elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
||||
(mEntryRelativeScale < 1.0f ? mEntryRelativeScale : 1.0f), true, true);
|
||||
mLetterHeightDimmed = mLetterHeight;
|
||||
}
|
||||
if (mEntryRelativeScale < 1.0f)
|
||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
||||
mEntryRelativeScale, false, true);
|
||||
}
|
||||
else if (mEntryRelativeScale < 1.0f) {
|
||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
||||
mEntryRelativeScale, false, true);
|
||||
}
|
||||
|
||||
if (elem->has("fontSizeDimmed"))
|
||||
mStyleFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f, 1.0f, true);
|
||||
if (elem->has("fontSizeDimmed")) {
|
||||
mStyleFontDimmed =
|
||||
Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f, 1.0f, true, true);
|
||||
mLetterHeightDimmed = mStyleFontDimmed->getLetterHeight() * 1.25f;
|
||||
if (mEntryRelativeScale < 1.0f)
|
||||
mStyleFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
||||
mEntryRelativeScale, true, true);
|
||||
}
|
||||
else if (mEntryRelativeScale < 1.0f && !elem->has("fontPath") && !elem->has("fontSize")) {
|
||||
mStyleFontDimmed = mStyleFont;
|
||||
}
|
||||
|
||||
if (elem->has("scope")) {
|
||||
const std::string& scope {elem->get<std::string>("scope")};
|
||||
|
|
@ -604,7 +631,7 @@ void HelpComponent::updateGrid()
|
|||
std::vector<std::shared_ptr<TextComponent>> labels;
|
||||
|
||||
float width {0.0f};
|
||||
float height {font->getLetterHeight() * 1.25f};
|
||||
const float height {isDimmed ? mLetterHeightDimmed : mLetterHeight};
|
||||
|
||||
for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); ++it) {
|
||||
if (!mEntries.empty() &&
|
||||
|
|
@ -624,7 +651,12 @@ void HelpComponent::updateGrid()
|
|||
}
|
||||
|
||||
icon->setColorShift(isDimmed ? mStyleIconColorDimmed : mStyleIconColor);
|
||||
icon->setResize(0, height);
|
||||
|
||||
if (mEntryRelativeScale < 1.0f)
|
||||
icon->setResize(0, height);
|
||||
else
|
||||
icon->setResize(0, height / mEntryRelativeScale);
|
||||
|
||||
icon->setOpacity(isDimmed ? mStyleOpacityDimmed : mStyleOpacity);
|
||||
icons.push_back(icon);
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ private:
|
|||
float mStyleBackgroundCornerRadius;
|
||||
bool mStyleColorGradientHorizontal;
|
||||
EntryLayout mStyleEntryLayout;
|
||||
float mEntryRelativeScale;
|
||||
float mLetterHeight;
|
||||
float mLetterHeightDimmed;
|
||||
float mStyleRotation;
|
||||
float mStyleEntrySpacing;
|
||||
float mStyleEntrySpacingDimmed;
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
|||
const std::shared_ptr<Font>& orig,
|
||||
const float maxHeight,
|
||||
const float sizeMultiplier,
|
||||
const bool fontSizeDimmed)
|
||||
const bool fontSizeDimmed,
|
||||
const bool helpComponent)
|
||||
{
|
||||
using namespace ThemeFlags;
|
||||
if (!(properties & FONT_PATH) && !(properties & FONT_SIZE))
|
||||
|
|
@ -220,11 +221,21 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
|||
if (fontSizeDimmed && properties & FONT_SIZE && elem->has("fontSizeDimmed")) {
|
||||
size = glm::clamp(screenSize * elem->get<float>("fontSizeDimmed"), screenSize * 0.001f,
|
||||
screenSize * 1.5f);
|
||||
// This is used by HelpComponent to set the relative size of the font compared to the icons.
|
||||
size *= sizeMultiplier;
|
||||
}
|
||||
else if (properties & FONT_SIZE && elem->has("fontSize")) {
|
||||
size = glm::clamp(screenSize * elem->get<float>("fontSize"), screenSize * 0.001f,
|
||||
screenSize * 1.5f);
|
||||
// This is used by the carousel where the itemScale property also scales the font size.
|
||||
// This is used by the carousel where the itemScale property also scales the font size, as
|
||||
// well as by HelpComponent to set the relative size of the font compared to the icons.
|
||||
size *= sizeMultiplier;
|
||||
}
|
||||
else if (helpComponent && sizeMultiplier != 1.0f && fontSizeDimmed &&
|
||||
!elem->has("fontSizeDimmed")) {
|
||||
size *= sizeMultiplier;
|
||||
}
|
||||
else if (helpComponent && sizeMultiplier != 1.0f && !fontSizeDimmed && !elem->has("fontSize")) {
|
||||
size *= sizeMultiplier;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ public:
|
|||
const std::shared_ptr<Font>& orig,
|
||||
const float maxHeight = 0.0f,
|
||||
const float sizeMultiplier = 1.0f,
|
||||
const bool fontSizeDimmed = false);
|
||||
const bool fontSizeDimmed = false,
|
||||
const bool helpComponent = false);
|
||||
|
||||
// Returns an approximation of VRAM used by the glyph atlas textures for this font object.
|
||||
size_t getMemUsage() const;
|
||||
|
|
|
|||
Loading…
Reference in a new issue