diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index ca31cfa94..7dd7d6010 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -566,6 +566,7 @@ std::map> {"scope", STRING}, {"entries", STRING}, {"entryLayout", STRING}, + {"entryRelativeScale", FLOAT}, {"entrySpacing", FLOAT}, {"entrySpacingDimmed", FLOAT}, {"iconTextSpacing", FLOAT}, diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 914cbcd8c..a16f2dd29 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -37,6 +37,9 @@ HelpComponent::HelpComponent(std::shared_ptr 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& theme, mRenderer->getScreenWidth(); } + if (elem->has("entryRelativeScale")) + mEntryRelativeScale = glm::clamp(elem->get("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("scope")}; @@ -604,7 +631,7 @@ void HelpComponent::updateGrid() std::vector> 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); diff --git a/es-core/src/components/HelpComponent.h b/es-core/src/components/HelpComponent.h index 0e5f5e128..624f24c65 100644 --- a/es-core/src/components/HelpComponent.h +++ b/es-core/src/components/HelpComponent.h @@ -91,6 +91,9 @@ private: float mStyleBackgroundCornerRadius; bool mStyleColorGradientHorizontal; EntryLayout mStyleEntryLayout; + float mEntryRelativeScale; + float mLetterHeight; + float mLetterHeightDimmed; float mStyleRotation; float mStyleEntrySpacing; float mStyleEntrySpacingDimmed; diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index 624452a02..fb2200f04 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -204,7 +204,8 @@ std::shared_ptr Font::getFromTheme(const ThemeData::ThemeElement* elem, const std::shared_ptr& 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::getFromTheme(const ThemeData::ThemeElement* elem, if (fontSizeDimmed && properties & FONT_SIZE && elem->has("fontSizeDimmed")) { size = glm::clamp(screenSize * elem->get("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("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; } diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index 31be1b2e4..09360aff6 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -122,7 +122,8 @@ public: const std::shared_ptr& 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;