mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed an issue in CarouselComponent where setting itemScale to less than 1.0 did not work as expected.
Also fixed a problem where carousel text entries did not get multiplied by itemScale.
This commit is contained in:
parent
4513b20339
commit
a8d1c4a2e1
|
@ -227,7 +227,7 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
item->setLinearInterpolation(mLinearInterpolation);
|
item->setLinearInterpolation(mLinearInterpolation);
|
||||||
item->setMipmapping(true);
|
item->setMipmapping(true);
|
||||||
item->setMaxSize(glm::round(mItemSize * mItemScale));
|
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
item->applyTheme(theme, "system", "image_logo",
|
item->applyTheme(theme, "system", "image_logo",
|
||||||
ThemeFlags::PATH | ThemeFlags::COLOR);
|
ThemeFlags::PATH | ThemeFlags::COLOR);
|
||||||
item->setRotateByTargetSize(true);
|
item->setRotateByTargetSize(true);
|
||||||
|
@ -241,7 +241,7 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
item->setLinearInterpolation(mLinearInterpolation);
|
item->setLinearInterpolation(mLinearInterpolation);
|
||||||
item->setMipmapping(true);
|
item->setMipmapping(true);
|
||||||
item->setMaxSize(glm::round(mItemSize * mItemScale));
|
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
item->setImage(entry.data.itemPath);
|
item->setImage(entry.data.itemPath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
item->setRotateByTargetSize(true);
|
item->setRotateByTargetSize(true);
|
||||||
|
@ -252,7 +252,8 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
auto defaultItem = std::make_shared<ImageComponent>(false, dynamic);
|
auto defaultItem = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
defaultItem->setLinearInterpolation(mLinearInterpolation);
|
defaultItem->setLinearInterpolation(mLinearInterpolation);
|
||||||
defaultItem->setMipmapping(true);
|
defaultItem->setMipmapping(true);
|
||||||
defaultItem->setMaxSize(glm::round(mItemSize * mItemScale));
|
defaultItem->setMaxSize(
|
||||||
|
glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
defaultItem->setImage(entry.data.defaultItemPath);
|
defaultItem->setImage(entry.data.defaultItemPath);
|
||||||
defaultItem->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
defaultItem->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
defaultItem->setRotateByTargetSize(true);
|
defaultItem->setRotateByTargetSize(true);
|
||||||
|
@ -276,7 +277,8 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
|
|
||||||
auto text = std::make_shared<TextComponent>(
|
auto text = std::make_shared<TextComponent>(
|
||||||
nameEntry, mFont, 0x000000FF, mItemHorizontalAlignment, mItemVerticalAlignment,
|
nameEntry, mFont, 0x000000FF, mItemHorizontalAlignment, mItemVerticalAlignment,
|
||||||
glm::vec3 {0.0f, 0.0f, 0.0f}, glm::round(mItemSize * mItemScale), 0x00000000);
|
glm::vec3 {0.0f, 0.0f, 0.0f},
|
||||||
|
glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)), 0x00000000);
|
||||||
if (legacyMode) {
|
if (legacyMode) {
|
||||||
text->applyTheme(theme, "system", "text_logoText",
|
text->applyTheme(theme, "system", "text_logoText",
|
||||||
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
|
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
|
||||||
|
@ -324,7 +326,7 @@ void CarouselComponent<T>::updateEntry(Entry& entry, const std::shared_ptr<Theme
|
||||||
auto item = std::make_shared<ImageComponent>(false, true);
|
auto item = std::make_shared<ImageComponent>(false, true);
|
||||||
item->setLinearInterpolation(mLinearInterpolation);
|
item->setLinearInterpolation(mLinearInterpolation);
|
||||||
item->setMipmapping(true);
|
item->setMipmapping(true);
|
||||||
item->setMaxSize(glm::round(mItemSize * mItemScale));
|
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
item->setImage(entry.data.itemPath);
|
item->setImage(entry.data.itemPath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
item->setRotateByTargetSize(true);
|
item->setRotateByTargetSize(true);
|
||||||
|
@ -769,9 +771,17 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
||||||
if (singleEntry)
|
if (singleEntry)
|
||||||
distance = 0.0f;
|
distance = 0.0f;
|
||||||
|
|
||||||
float scale {1.0f + ((mItemScale - 1.0f) * (1.0f - fabsf(distance)))};
|
float scale {0.0f};
|
||||||
scale = std::min(mItemScale, std::max(1.0f, scale));
|
|
||||||
scale /= mItemScale;
|
if (mItemScale >= 1.0f) {
|
||||||
|
scale = 1.0f + ((mItemScale - 1.0f) * (1.0f - fabsf(distance)));
|
||||||
|
scale = std::min(mItemScale, std::max(1.0f, scale));
|
||||||
|
scale /= mItemScale;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scale = 1.0f + ((1.0f - mItemScale) * (fabsf(distance) - 1.0f));
|
||||||
|
scale = std::max(mItemScale, std::min(1.0f, scale));
|
||||||
|
}
|
||||||
|
|
||||||
glm::mat4 itemTrans {carouselTrans};
|
glm::mat4 itemTrans {carouselTrans};
|
||||||
if (singleEntry)
|
if (singleEntry)
|
||||||
|
@ -1012,7 +1022,7 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("itemScale"))
|
if (elem->has("itemScale"))
|
||||||
mItemScale = glm::clamp(elem->get<float>("itemScale"), 0.5f, 3.0f);
|
mItemScale = glm::clamp(elem->get<float>("itemScale"), 0.2f, 3.0f);
|
||||||
|
|
||||||
if (elem->has("itemTransitions")) {
|
if (elem->has("itemTransitions")) {
|
||||||
const std::string itemTransitions {elem->get<std::string>("itemTransitions")};
|
const std::string itemTransitions {elem->get<std::string>("itemTransitions")};
|
||||||
|
@ -1206,7 +1216,9 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mFont = Font::getFromTheme(elem, properties, mFont, 0.0f, mLegacyMode);
|
// For non-legacy themes, scale the font size with the itemScale property value.
|
||||||
|
mFont = Font::getFromTheme(elem, properties, mFont, 0.0f, mLegacyMode,
|
||||||
|
(mLegacyMode ? 1.0f : (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
|
|
||||||
if (elem->has("textColor"))
|
if (elem->has("textColor"))
|
||||||
mTextColor = elem->get<unsigned int>("textColor");
|
mTextColor = elem->get<unsigned int>("textColor");
|
||||||
|
|
|
@ -422,7 +422,8 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
||||||
unsigned int properties,
|
unsigned int properties,
|
||||||
const std::shared_ptr<Font>& orig,
|
const std::shared_ptr<Font>& orig,
|
||||||
const float maxHeight,
|
const float maxHeight,
|
||||||
const bool legacyTheme)
|
const bool legacyTheme,
|
||||||
|
const float sizeMultiplier)
|
||||||
{
|
{
|
||||||
mLegacyTheme = legacyTheme;
|
mLegacyTheme = legacyTheme;
|
||||||
|
|
||||||
|
@ -438,6 +439,8 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
||||||
if (properties & FONT_SIZE && elem->has("fontSize")) {
|
if (properties & FONT_SIZE && elem->has("fontSize")) {
|
||||||
size = glm::clamp(screenHeight * elem->get<float>("fontSize"), screenHeight * 0.001f,
|
size = glm::clamp(screenHeight * elem->get<float>("fontSize"), screenHeight * 0.001f,
|
||||||
screenHeight * 1.5f);
|
screenHeight * 1.5f);
|
||||||
|
// This is used by the carousel where the itemScale property also scales the font size.
|
||||||
|
size *= sizeMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxHeight != 0.0f && size > maxHeight)
|
if (maxHeight != 0.0f && size > maxHeight)
|
||||||
|
@ -741,10 +744,8 @@ Font::Glyph* Font::getGlyph(const unsigned int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the letter 'S' as a size reference.
|
// Use the letter 'S' as a size reference.
|
||||||
if (mLetterHeight == 0 && id == 'S') {
|
if (mLetterHeight == 0 && id == 'S')
|
||||||
const float ratio {static_cast<float>(glyphSize.y) / std::round(mFontSize)};
|
mLetterHeight = static_cast<float>(glyphSize.y);
|
||||||
mLetterHeight = mFontSize * ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create glyph.
|
// Create glyph.
|
||||||
Glyph& glyph {mGlyphMap[id]};
|
Glyph& glyph {mGlyphMap[id]};
|
||||||
|
|
|
@ -94,7 +94,8 @@ public:
|
||||||
unsigned int properties,
|
unsigned int properties,
|
||||||
const std::shared_ptr<Font>& orig,
|
const std::shared_ptr<Font>& orig,
|
||||||
const float maxHeight = 0.0f,
|
const float maxHeight = 0.0f,
|
||||||
const bool legacyTheme = false);
|
const bool legacyTheme = false,
|
||||||
|
const float sizeMultiplier = 1.0f);
|
||||||
|
|
||||||
// Returns an approximation of VRAM used by this font's texture (in bytes).
|
// Returns an approximation of VRAM used by this font's texture (in bytes).
|
||||||
size_t getMemUsage() const;
|
size_t getMemUsage() const;
|
||||||
|
|
Loading…
Reference in a new issue