Added <lineSpacing> tag to textlist element.

This commit is contained in:
Aloshi 2014-05-14 18:27:22 -05:00
parent fd2281afff
commit 91561480b3
3 changed files with 12 additions and 5 deletions

View file

@ -421,7 +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.
* `lineSpacing` - type: FLOAT. Controls the space between lines (as a multiple of font height). Default is 1.5.
#### textlist
@ -444,6 +444,7 @@ Can be created as an extra.
* `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).
* `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

View file

@ -54,7 +54,8 @@ std::map< std::string, ElementMapType > ThemeData::sElementMap = boost::assign::
("scrollSound", PATH)
("alignment", STRING)
("horizontalMargin", FLOAT)
("forceUppercase", BOOLEAN)))
("forceUppercase", BOOLEAN)
("lineSpacing", FLOAT)))
("container", makeMap(boost::assign::map_list_of
("pos", NORMALIZED_PAIR)
("size", NORMALIZED_PAIR)))

View file

@ -77,6 +77,7 @@ public:
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 setSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
inline void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
protected:
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
@ -97,6 +98,7 @@ private:
std::shared_ptr<Font> mFont;
bool mUppercase;
float mLineSpacing;
unsigned int mSelectorColor;
unsigned int mSelectedColor;
std::shared_ptr<Sound> mScrollSound;
@ -116,6 +118,7 @@ TextListComponent<T>::TextListComponent(Window* window) :
mFont = Font::get(FONT_SIZE_MEDIUM);
mUppercase = false;
mLineSpacing = 1.5f;
mSelectorColor = 0x000000FF;
mSelectedColor = 0;
mColors[0] = 0x0000FFFF;
@ -132,7 +135,7 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
if(size() == 0)
return;
const float entrySize = font->getHeight() + 5;
const float entrySize = font->getHeight(mLineSpacing);
int startEntry = 0;
@ -199,7 +202,6 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
offset[0] -= mHorizontalMargin;
if(offset[0] < 0)
offset[0] = 0;
break;
}
@ -362,4 +364,7 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
setUppercase(elem->get<bool>("forceUppercase"));
if(properties & LINE_SPACING && elem->has("lineSpacing"))
setLineSpacing(elem->get<float>("lineSpacing"));
}