Removed the RetroPie ES bug replication from TextListComponent for non-legacy theme sets.

This commit is contained in:
Leon Styhre 2022-06-05 12:17:15 +02:00
parent eb3fb3d953
commit c216f3804a

View file

@ -165,6 +165,7 @@ private:
std::shared_ptr<Font> mFont; std::shared_ptr<Font> mFont;
std::string mIndicators; std::string mIndicators;
std::string mCollectionIndicators; std::string mCollectionIndicators;
bool mLegacyMode;
bool mUppercase; bool mUppercase;
bool mLowercase; bool mLowercase;
bool mCapitalize; bool mCapitalize;
@ -196,6 +197,7 @@ TextListComponent<T>::TextListComponent()
, mFont {Font::get(FONT_SIZE_MEDIUM)} , mFont {Font::get(FONT_SIZE_MEDIUM)}
, mIndicators {"symbols"} , mIndicators {"symbols"}
, mCollectionIndicators {"symbols"} , mCollectionIndicators {"symbols"}
, mLegacyMode {false}
, mUppercase {false} , mUppercase {false}
, mLowercase {false} , mLowercase {false}
, mCapitalize {false} , mCapitalize {false}
@ -330,6 +332,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
std::shared_ptr<Font>& font {mFont}; std::shared_ptr<Font>& font {mFont};
int startEntry {0}; int startEntry {0};
int screenCount {0};
float y {0.0f}; float y {0.0f};
const float entrySize { const float entrySize {
@ -337,15 +340,19 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
mLineSpacing}; mLineSpacing};
const float lineSpacingHeight {floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))}; const float lineSpacingHeight {floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))};
// This extra vertical margin is technically incorrect, but it adds a little extra leeway if (mLegacyMode) {
// to avoid removing the last row on some older theme sets. There was a sizing bug in the // This extra vertical margin is technically incorrect, but it adds a little extra leeway
// RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly // to avoid removing the last row on some older theme sets. There was a sizing bug in the
// too small for the last row to show up when the sizing calculation is done correctly. // RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly
const float extraMargin {(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)}; // too small for the last row to show up when the sizing calculation is done correctly.
const float extraMargin {(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)};
// Number of entries that can fit on the screen simultaneously. // Number of entries that can fit on the screen simultaneously.
int screenCount { screenCount = static_cast<int>(
static_cast<int>(floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize))}; floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize));
}
else {
screenCount = static_cast<int>(floorf((mSize.y + lineSpacingHeight / 2.0f) / entrySize));
}
if (size() >= screenCount) { if (size() >= screenCount) {
startEntry = mCursor - screenCount / 2; startEntry = mCursor - screenCount / 2;
@ -495,6 +502,8 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (!elem) if (!elem)
return; return;
mLegacyMode = theme->isLegacyTheme();
using namespace ThemeFlags; using namespace ThemeFlags;
if (properties & COLOR) { if (properties & COLOR) {
if (elem->has("selectorColor")) { if (elem->has("selectorColor")) {