mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Added <lineSpacing> tag to textlist element.
This commit is contained in:
parent
fd2281afff
commit
91561480b3
|
@ -421,7 +421,7 @@ Can be created as an extra.
|
||||||
* `alignment` - type: STRING.
|
* `alignment` - type: STRING.
|
||||||
- Valid values are "left", "center", or "right". Controls alignment on the X axis. "center" will also align vertically.
|
- 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.
|
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
|
||||||
* `lineSpacing` - type: FLOAT. Controls the space between lines. Default is 1.5.
|
* `lineSpacing` - type: FLOAT. Controls the space between lines (as a multiple of font height). Default is 1.5.
|
||||||
|
|
||||||
#### textlist
|
#### textlist
|
||||||
|
|
||||||
|
@ -444,6 +444,7 @@ Can be created as an extra.
|
||||||
* `horizontalMargin` - type: FLOAT.
|
* `horizontalMargin` - type: FLOAT.
|
||||||
- Horizontal offset for text from the alignment point. If `alignment` is "left", offsets the text to the right. If `alignment` is "right", offsets text to the left. No effect if `alignment` is "center". Given as a percentage of the element's parent's width (same unit as `size`'s X value).
|
- Horizontal offset for text from the alignment point. If `alignment` is "left", offsets the text to the right. If `alignment` is "right", offsets text to the left. No effect if `alignment` is "center". Given as a percentage of the element's parent's width (same unit as `size`'s X value).
|
||||||
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
|
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
|
||||||
|
* `lineSpacing` - type: FLOAT. Controls the space between lines (as a multiple of font height). Default is 1.5.
|
||||||
|
|
||||||
#### ninepatch
|
#### ninepatch
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ std::map< std::string, ElementMapType > ThemeData::sElementMap = boost::assign::
|
||||||
("scrollSound", PATH)
|
("scrollSound", PATH)
|
||||||
("alignment", STRING)
|
("alignment", STRING)
|
||||||
("horizontalMargin", FLOAT)
|
("horizontalMargin", FLOAT)
|
||||||
("forceUppercase", BOOLEAN)))
|
("forceUppercase", BOOLEAN)
|
||||||
|
("lineSpacing", FLOAT)))
|
||||||
("container", makeMap(boost::assign::map_list_of
|
("container", makeMap(boost::assign::map_list_of
|
||||||
("pos", NORMALIZED_PAIR)
|
("pos", NORMALIZED_PAIR)
|
||||||
("size", NORMALIZED_PAIR)))
|
("size", NORMALIZED_PAIR)))
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
inline void setScrollSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
inline void setScrollSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
||||||
inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
||||||
inline void setSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
inline void setSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
||||||
|
inline void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
|
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
|
||||||
|
@ -97,6 +98,7 @@ private:
|
||||||
|
|
||||||
std::shared_ptr<Font> mFont;
|
std::shared_ptr<Font> mFont;
|
||||||
bool mUppercase;
|
bool mUppercase;
|
||||||
|
float mLineSpacing;
|
||||||
unsigned int mSelectorColor;
|
unsigned int mSelectorColor;
|
||||||
unsigned int mSelectedColor;
|
unsigned int mSelectedColor;
|
||||||
std::shared_ptr<Sound> mScrollSound;
|
std::shared_ptr<Sound> mScrollSound;
|
||||||
|
@ -116,6 +118,7 @@ TextListComponent<T>::TextListComponent(Window* window) :
|
||||||
|
|
||||||
mFont = Font::get(FONT_SIZE_MEDIUM);
|
mFont = Font::get(FONT_SIZE_MEDIUM);
|
||||||
mUppercase = false;
|
mUppercase = false;
|
||||||
|
mLineSpacing = 1.5f;
|
||||||
mSelectorColor = 0x000000FF;
|
mSelectorColor = 0x000000FF;
|
||||||
mSelectedColor = 0;
|
mSelectedColor = 0;
|
||||||
mColors[0] = 0x0000FFFF;
|
mColors[0] = 0x0000FFFF;
|
||||||
|
@ -132,7 +135,7 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
if(size() == 0)
|
if(size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float entrySize = font->getHeight() + 5;
|
const float entrySize = font->getHeight(mLineSpacing);
|
||||||
|
|
||||||
int startEntry = 0;
|
int startEntry = 0;
|
||||||
|
|
||||||
|
@ -199,7 +202,6 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
offset[0] -= mHorizontalMargin;
|
offset[0] -= mHorizontalMargin;
|
||||||
if(offset[0] < 0)
|
if(offset[0] < 0)
|
||||||
offset[0] = 0;
|
offset[0] = 0;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,5 +363,8 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
|
||||||
}
|
}
|
||||||
|
|
||||||
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
||||||
setUppercase(elem->get<bool>("forceUppercase"));
|
setUppercase(elem->get<bool>("forceUppercase"));
|
||||||
|
|
||||||
|
if(properties & LINE_SPACING && elem->has("lineSpacing"))
|
||||||
|
setLineSpacing(elem->get<float>("lineSpacing"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue