mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
The gamelist description text no longer scrolls above the starting position.
This commit is contained in:
parent
a7f431ae9f
commit
5099593d73
|
@ -122,6 +122,7 @@ DetailedGameListView::DetailedGameListView(
|
||||||
|
|
||||||
mDescription.setFont(Font::get(FONT_SIZE_SMALL));
|
mDescription.setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
mDescription.setSize(mDescContainer.getSize().x(), 0);
|
mDescription.setSize(mDescContainer.getSize().x(), 0);
|
||||||
|
mDescription.setNoTopMargin(true);
|
||||||
mDescContainer.addChild(&mDescription);
|
mDescContainer.addChild(&mDescription);
|
||||||
|
|
||||||
mGamelistInfo.setOrigin(0.5f, 0.5f);
|
mGamelistInfo.setOrigin(0.5f, 0.5f);
|
||||||
|
|
|
@ -140,6 +140,7 @@ VideoGameListView::VideoGameListView(
|
||||||
|
|
||||||
mDescription.setFont(Font::get(FONT_SIZE_SMALL));
|
mDescription.setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
mDescription.setSize(mDescContainer.getSize().x(), 0);
|
mDescription.setSize(mDescContainer.getSize().x(), 0);
|
||||||
|
mDescription.setNoTopMargin(true);
|
||||||
mDescContainer.addChild(&mDescription);
|
mDescContainer.addChild(&mDescription);
|
||||||
|
|
||||||
mGamelistInfo.setOrigin(0.5f, 0.5f);
|
mGamelistInfo.setOrigin(0.5f, 0.5f);
|
||||||
|
|
|
@ -22,6 +22,7 @@ TextComponent::TextComponent(
|
||||||
mHorizontalAlignment(ALIGN_LEFT),
|
mHorizontalAlignment(ALIGN_LEFT),
|
||||||
mVerticalAlignment(ALIGN_CENTER),
|
mVerticalAlignment(ALIGN_CENTER),
|
||||||
mLineSpacing(1.5f),
|
mLineSpacing(1.5f),
|
||||||
|
mNoTopMargin(false),
|
||||||
mBgColor(0),
|
mBgColor(0),
|
||||||
mMargin(0.0f),
|
mMargin(0.0f),
|
||||||
mRenderBackground(false)
|
mRenderBackground(false)
|
||||||
|
@ -46,6 +47,7 @@ TextComponent::TextComponent(
|
||||||
mHorizontalAlignment(align),
|
mHorizontalAlignment(align),
|
||||||
mVerticalAlignment(ALIGN_CENTER),
|
mVerticalAlignment(ALIGN_CENTER),
|
||||||
mLineSpacing(1.5f),
|
mLineSpacing(1.5f),
|
||||||
|
mNoTopMargin(false),
|
||||||
mBgColor(0),
|
mBgColor(0),
|
||||||
mMargin(margin),
|
mMargin(margin),
|
||||||
mRenderBackground(false)
|
mRenderBackground(false)
|
||||||
|
@ -245,12 +247,13 @@ void TextComponent::onTextChanged()
|
||||||
text.append(abbrev);
|
text.append(abbrev);
|
||||||
|
|
||||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(text, Vector2f(0, 0),
|
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(text, Vector2f(0, 0),
|
||||||
(mColor >> 8 << 8) | mOpacity, mSize.x(), mHorizontalAlignment, mLineSpacing));
|
(mColor >> 8 << 8) | mOpacity, mSize.x(), mHorizontalAlignment,
|
||||||
|
mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(f->wrapText(
|
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(f->wrapText(
|
||||||
text, mSize.x()), Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(),
|
text, mSize.x()), Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(),
|
||||||
mHorizontalAlignment, mLineSpacing));
|
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +280,12 @@ void TextComponent::setLineSpacing(float spacing)
|
||||||
onTextChanged();
|
onTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextComponent::setNoTopMargin(bool margin)
|
||||||
|
{
|
||||||
|
mNoTopMargin = margin;
|
||||||
|
onTextChanged();
|
||||||
|
}
|
||||||
|
|
||||||
std::string TextComponent::getValue() const
|
std::string TextComponent::getValue() const
|
||||||
{
|
{
|
||||||
return mText;
|
return mText;
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void setHorizontalAlignment(Alignment align);
|
void setHorizontalAlignment(Alignment align);
|
||||||
void setVerticalAlignment(Alignment align);
|
void setVerticalAlignment(Alignment align);
|
||||||
void setLineSpacing(float spacing);
|
void setLineSpacing(float spacing);
|
||||||
|
void setNoTopMargin(bool margin);
|
||||||
void setBackgroundColor(unsigned int color);
|
void setBackgroundColor(unsigned int color);
|
||||||
void setRenderBackground(bool render);
|
void setRenderBackground(bool render);
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ private:
|
||||||
Alignment mHorizontalAlignment;
|
Alignment mHorizontalAlignment;
|
||||||
Alignment mVerticalAlignment;
|
Alignment mVerticalAlignment;
|
||||||
float mLineSpacing;
|
float mLineSpacing;
|
||||||
|
bool mNoTopMargin;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H
|
||||||
|
|
|
@ -574,13 +574,23 @@ TextCache* Font::buildTextCache(
|
||||||
unsigned int color,
|
unsigned int color,
|
||||||
float xLen,
|
float xLen,
|
||||||
Alignment alignment,
|
Alignment alignment,
|
||||||
float lineSpacing)
|
float lineSpacing,
|
||||||
|
bool noTopMargin)
|
||||||
{
|
{
|
||||||
float x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text, 0, xLen, alignment) : 0);
|
float x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text, 0, xLen, alignment) : 0);
|
||||||
|
float yTop = 0;
|
||||||
|
float yBot = 0;
|
||||||
|
|
||||||
float yTop = getGlyph('S')->bearing.y();
|
if (noTopMargin) {
|
||||||
float yBot = getHeight(lineSpacing);
|
yTop = 0;
|
||||||
float y = offset[1] + (yBot + yTop)/2.0f;
|
yBot = getHeight(1.5);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yTop = getGlyph('S')->bearing.y();
|
||||||
|
yBot = getHeight(lineSpacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
float y = offset[1] + (yBot + yTop) / 2.0f;
|
||||||
|
|
||||||
// Vertices by texture.
|
// Vertices by texture.
|
||||||
std::map<FontTexture*, std::vector<Renderer::Vertex>> vertMap;
|
std::map<FontTexture*, std::vector<Renderer::Vertex>> vertMap;
|
||||||
|
@ -670,9 +680,11 @@ TextCache* Font::buildTextCache(
|
||||||
float offsetX,
|
float offsetX,
|
||||||
float offsetY,
|
float offsetY,
|
||||||
unsigned int color,
|
unsigned int color,
|
||||||
float lineSpacing)
|
float lineSpacing,
|
||||||
|
bool noTopMargin)
|
||||||
{
|
{
|
||||||
return buildTextCache(text, Vector2f(offsetX, offsetY), color, 0.0f, ALIGN_LEFT, lineSpacing);
|
return buildTextCache(text, Vector2f(offsetX, offsetY), color, 0.0f, ALIGN_LEFT,
|
||||||
|
lineSpacing, noTopMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextCache::setColor(unsigned int color)
|
void TextCache::setColor(unsigned int color)
|
||||||
|
|
|
@ -57,15 +57,21 @@ public:
|
||||||
Vector2f sizeText(std::string text, float lineSpacing = 1.5f);
|
Vector2f sizeText(std::string text, float lineSpacing = 1.5f);
|
||||||
// Returns the portion of a string that fits within the passed argument maxWidth.
|
// Returns the portion of a string that fits within the passed argument maxWidth.
|
||||||
std::string getTextMaxWidth(std::string text, float maxWidth);
|
std::string getTextMaxWidth(std::string text, float maxWidth);
|
||||||
TextCache* buildTextCache(const std::string& text, float offsetX,
|
TextCache* buildTextCache(
|
||||||
float offsetY, unsigned int color, float lineSpacing = 1.5f);
|
const std::string& text,
|
||||||
|
float offsetX,
|
||||||
|
float offsetY,
|
||||||
|
unsigned int color,
|
||||||
|
float lineSpacing = 1.5f,
|
||||||
|
bool noTopMargin = false);
|
||||||
TextCache* buildTextCache(
|
TextCache* buildTextCache(
|
||||||
const std::string& text,
|
const std::string& text,
|
||||||
Vector2f offset,
|
Vector2f offset,
|
||||||
unsigned int color,
|
unsigned int color,
|
||||||
float xLen,
|
float xLen,
|
||||||
Alignment alignment = ALIGN_LEFT,
|
Alignment alignment = ALIGN_LEFT,
|
||||||
float lineSpacing = 1.5f);
|
float lineSpacing = 1.5f,
|
||||||
|
bool noTopMargin = false);
|
||||||
void renderTextCache(TextCache* cache);
|
void renderTextCache(TextCache* cache);
|
||||||
|
|
||||||
// Inserts newlines into text to make it wrap properly.
|
// Inserts newlines into text to make it wrap properly.
|
||||||
|
|
|
@ -227,7 +227,7 @@ based on: 'recalbox-multi' by the Recalbox community
|
||||||
</rating>
|
</rating>
|
||||||
<text name="md_description">
|
<text name="md_description">
|
||||||
<lineSpacing>1.2</lineSpacing>
|
<lineSpacing>1.2</lineSpacing>
|
||||||
<pos>0.454 0.675</pos>
|
<pos>0.454 0.678</pos>
|
||||||
<size>0.346 0.235</size>
|
<size>0.346 0.235</size>
|
||||||
<fontSize>0.02</fontSize>
|
<fontSize>0.02</fontSize>
|
||||||
</text>
|
</text>
|
||||||
|
|
Loading…
Reference in a new issue