diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 46ad6c436..28f4bc671 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -249,6 +249,7 @@ std::map> {{"pos", NORMALIZED_PAIR}, {"size", NORMALIZED_PAIR}, {"origin", NORMALIZED_PAIR}, + {"selectorWidth", FLOAT}, {"selectorHeight", FLOAT}, {"selectorHorizontalOffset", FLOAT}, {"selectorVerticalOffset", FLOAT}, diff --git a/es-core/src/components/primary/TextListComponent.h b/es-core/src/components/primary/TextListComponent.h index bf2eadd4d..069b5663d 100644 --- a/es-core/src/components/primary/TextListComponent.h +++ b/es-core/src/components/primary/TextListComponent.h @@ -123,6 +123,7 @@ private: bool mGamelistView; std::shared_ptr mFont; + float mSelectorWidth; float mSelectorHeight; float mSelectorHorizontalOffset; float mSelectorVerticalOffset; @@ -162,6 +163,7 @@ TextListComponent::TextListComponent() , mPreviousScrollVelocity {0} , mGamelistView {std::is_same_v ? true : false} , mFont {Font::get(FONT_SIZE_MEDIUM_FIXED)} + , mSelectorWidth {mSize.x} , mSelectorHeight {mFont->getSize() * 1.5f} , mSelectorHorizontalOffset {0.0f} , mSelectorVerticalOffset {0.0f} @@ -330,7 +332,7 @@ template void TextListComponent::render(const glm::mat4& parentT mRenderer->setMatrix(trans); mRenderer->drawRect(mSelectorHorizontalOffset, (mCursor - startEntry) * entrySize + mSelectorVerticalOffset, - mSize.x, mSelectorHeight, mSelectorColor, mSelectorColorEnd, + mSelectorWidth, mSelectorHeight, mSelectorColor, mSelectorColorEnd, mSelectorColorGradientHorizontal); } } @@ -670,12 +672,23 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, } } + mSize.x = glm::clamp(mSize.x, mRenderer->getScreenWidth() * 0.05f, + mRenderer->getScreenWidth() * 1.0f); + mSize.y = glm::clamp(mSize.y, mRenderer->getScreenHeight() * 0.05f, + mRenderer->getScreenHeight() * 1.0f); + + if (elem->has("selectorWidth")) + mSelectorWidth = + glm::clamp(elem->get("selectorWidth"), 0.0f, 1.0f) * Renderer::getScreenWidth(); + else + mSelectorWidth = mSize.x; + if (elem->has("selectorImagePath")) { const std::string& path {elem->get("selectorImagePath")}; bool tile {elem->has("selectorImageTile") && elem->get("selectorImageTile")}; mSelectorImage.setImage(path, tile); - mSelectorImage.setSize(mSize.x, mSelectorHeight); - mSelectorImage.setResize(mSize.x, mSelectorHeight); + mSelectorImage.setSize(mSelectorWidth, mSelectorHeight); + mSelectorImage.setResize(mSelectorWidth, mSelectorHeight); mSelectorImage.setColorShift(mSelectorColor); mSelectorImage.setColorShiftEnd(mSelectorColorEnd); } @@ -685,11 +698,6 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("fadeAbovePrimary")) mFadeAbovePrimary = elem->get("fadeAbovePrimary"); - - mSize.x = glm::clamp(mSize.x, mRenderer->getScreenWidth() * 0.05f, - mRenderer->getScreenWidth() * 1.0f); - mSize.y = glm::clamp(mSize.y, mRenderer->getScreenHeight() * 0.05f, - mRenderer->getScreenHeight() * 1.0f); } template void TextListComponent::onCursorChanged(const CursorState& state)