mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed an issues where textlist entries would sometimes scroll horizontally even though they fit inside the element width.
This commit is contained in:
parent
309e635be4
commit
deaa4e13b3
|
@ -282,17 +282,17 @@ template <typename T> void TextListComponent<T>::update(int deltaTime)
|
||||||
mLoopOffset2 = 0;
|
mLoopOffset2 = 0;
|
||||||
|
|
||||||
// If we're not scrolling and this object's text exceeds our size, then loop it.
|
// If we're not scrolling and this object's text exceeds our size, then loop it.
|
||||||
const float textLength {mFont
|
|
||||||
->sizeText(Utils::String::toUpper(
|
|
||||||
mEntries.at(static_cast<unsigned int>(mCursor)).name))
|
|
||||||
.x};
|
|
||||||
const float limit {mSize.x - mHorizontalMargin * 2.0f};
|
const float limit {mSize.x - mHorizontalMargin * 2.0f};
|
||||||
|
float length {0.0f};
|
||||||
|
|
||||||
if (textLength > limit) {
|
if (mEntries.at(static_cast<unsigned int>(mCursor)).data.textCache != nullptr)
|
||||||
|
length = mEntries.at(static_cast<unsigned int>(mCursor)).data.textCache->getSize().x;
|
||||||
|
|
||||||
|
if (length != 0.0f && length > limit) {
|
||||||
// Loop the text.
|
// Loop the text.
|
||||||
const float speed {mFont->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f};
|
const float speed {mFont->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f};
|
||||||
const float delay {3000.0f};
|
const float delay {3000.0f};
|
||||||
const float scrollLength {textLength};
|
const float scrollLength {length};
|
||||||
const float returnLength {speed * 1.5f};
|
const float returnLength {speed * 1.5f};
|
||||||
const float scrollTime {(scrollLength * 1000.0f) / speed};
|
const float scrollTime {(scrollLength * 1000.0f) / speed};
|
||||||
const float returnTime {(returnLength * 1000.0f) / speed};
|
const float returnTime {(returnLength * 1000.0f) / speed};
|
||||||
|
|
|
@ -234,12 +234,17 @@ public:
|
||||||
struct CacheMetrics {
|
struct CacheMetrics {
|
||||||
glm::vec2 size;
|
glm::vec2 size;
|
||||||
int maxGlyphHeight;
|
int maxGlyphHeight;
|
||||||
|
|
||||||
|
CacheMetrics()
|
||||||
|
: size {0.0f, 0.0f}
|
||||||
|
, maxGlyphHeight {0} {};
|
||||||
} metrics;
|
} metrics;
|
||||||
|
|
||||||
void setColor(unsigned int color);
|
void setColor(unsigned int color);
|
||||||
void setOpacity(float opacity);
|
void setOpacity(float opacity);
|
||||||
void setSaturation(float saturation);
|
void setSaturation(float saturation);
|
||||||
void setDimming(float dimming);
|
void setDimming(float dimming);
|
||||||
|
const glm::vec2& getSize() { return metrics.size; }
|
||||||
|
|
||||||
friend Font;
|
friend Font;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue