mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Added <lineSpacing> tag to text elements.
Accessable with TextComponent::setLineSpacing(float spacing) in C++.
This commit is contained in:
parent
7e5f161271
commit
fe7f7f983b
|
@ -421,6 +421,7 @@ Can be created as an extra.
|
|||
* `alignment` - type: STRING.
|
||||
- Valid values are "left", "center", or "right". Controls alignment on the X axis. "center" will also align vertically.
|
||||
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
|
||||
* `lineSpacing` - type: FLOAT. Controls the space between lines. Default is 1.5.
|
||||
|
||||
#### textlist
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ std::map< std::string, ElementMapType > ThemeData::sElementMap = boost::assign::
|
|||
("fontPath", PATH)
|
||||
("fontSize", FLOAT)
|
||||
("alignment", STRING)
|
||||
("forceUppercase", BOOLEAN)))
|
||||
("forceUppercase", BOOLEAN)
|
||||
("lineSpacing", FLOAT)))
|
||||
("textlist", makeMap(boost::assign::map_list_of
|
||||
("pos", NORMALIZED_PAIR)
|
||||
("size", NORMALIZED_PAIR)
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace ThemeFlags
|
|||
ALIGNMENT = 256,
|
||||
TEXT = 512,
|
||||
FORCE_UPPERCASE = 1024,
|
||||
LINE_SPACING = 2048,
|
||||
|
||||
ALL = 0xFFFFFFFF
|
||||
};
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include "../Settings.h"
|
||||
|
||||
TextComponent::TextComponent(Window* window) : GuiComponent(window),
|
||||
mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(ALIGN_LEFT)
|
||||
mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(ALIGN_LEFT), mLineSpacing(1.5f)
|
||||
{
|
||||
}
|
||||
|
||||
TextComponent::TextComponent(Window* window, const std::string& text, const std::shared_ptr<Font>& font, unsigned int color, Alignment align,
|
||||
Eigen::Vector3f pos, Eigen::Vector2f size) : GuiComponent(window),
|
||||
mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(align)
|
||||
mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(align), mLineSpacing(1.5f)
|
||||
{
|
||||
setFont(font);
|
||||
setColor(color);
|
||||
|
@ -154,9 +154,9 @@ void TextComponent::onTextChanged()
|
|||
|
||||
text.append(abbrev);
|
||||
|
||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(text, Eigen::Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(), mAlignment));
|
||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(text, Eigen::Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(), mAlignment, mLineSpacing));
|
||||
}else{
|
||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(f->wrapText(text, mSize.x()), Eigen::Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(), mAlignment));
|
||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(f->wrapText(text, mSize.x()), Eigen::Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(), mAlignment, mLineSpacing));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,18 @@ void TextComponent::onColorChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void TextComponent::setAlignment(Alignment align)
|
||||
{
|
||||
mAlignment = align;
|
||||
onTextChanged();
|
||||
}
|
||||
|
||||
void TextComponent::setLineSpacing(float spacing)
|
||||
{
|
||||
mLineSpacing = spacing;
|
||||
onTextChanged();
|
||||
}
|
||||
|
||||
void TextComponent::setValue(const std::string& value)
|
||||
{
|
||||
setText(value);
|
||||
|
@ -210,5 +222,8 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const st
|
|||
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
||||
setUppercase(elem->get<bool>("forceUppercase"));
|
||||
|
||||
if(properties & LINE_SPACING && elem->has("lineSpacing"))
|
||||
setLineSpacing(elem->get<float>("lineSpacing"));
|
||||
|
||||
setFont(Font::getFromTheme(elem, properties, mFont));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ public:
|
|||
void onSizeChanged() override;
|
||||
void setText(const std::string& text);
|
||||
void setColor(unsigned int color);
|
||||
inline void setAlignment(Alignment align) { mAlignment = align; }
|
||||
void setAlignment(Alignment align);
|
||||
void setLineSpacing(float spacing);
|
||||
|
||||
void render(const Eigen::Affine3f& parentTrans) override;
|
||||
|
||||
|
@ -50,6 +51,7 @@ private:
|
|||
std::string mText;
|
||||
std::shared_ptr<TextCache> mTextCache;
|
||||
Alignment mAlignment;
|
||||
float mLineSpacing;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@ void GuiScraperStart::pressedStart()
|
|||
if((*it)->getPlatformId() == PlatformIds::PLATFORM_UNKNOWN)
|
||||
{
|
||||
mWindow->pushGui(new GuiMsgBox(mWindow,
|
||||
"Warning: some of your selected systems do not have a platform ID set. Results may be even more inaccurate than usual!\nContinue anyway?",
|
||||
strToUpper("Warning: some of your selected systems do not have a platform ID set. Results may be even more inaccurate than usual!\nContinue anyway?"),
|
||||
"YES", std::bind(&GuiScraperStart::start, this),
|
||||
"NO", nullptr));
|
||||
return;
|
||||
|
|
|
@ -107,7 +107,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
|||
|
||||
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE);
|
||||
mDescription.setSize(mDescContainer.getSize().x(), 0);
|
||||
mDescription.applyTheme(theme, getName(), "md_description", FONT_PATH | FONT_SIZE | COLOR | FORCE_UPPERCASE | ALIGNMENT);
|
||||
mDescription.applyTheme(theme, getName(), "md_description", ALL ^ (POSITION | ThemeFlags::SIZE | TEXT));
|
||||
}
|
||||
|
||||
void DetailedGameListView::initMDLabels()
|
||||
|
|
Loading…
Reference in a new issue