diff --git a/THEMES.md b/THEMES.md index cbcf06bfb..323c232a8 100644 --- a/THEMES.md +++ b/THEMES.md @@ -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 diff --git a/src/ThemeData.cpp b/src/ThemeData.cpp index bf16d6765..775bb6a6d 100644 --- a/src/ThemeData.cpp +++ b/src/ThemeData.cpp @@ -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))) diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index b896c1aff..34e2c8f2d 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -77,6 +77,7 @@ public: inline void setScrollSound(const std::shared_ptr& sound) { mScrollSound = sound; } inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; } inline void setSound(const std::shared_ptr& 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 mFont; bool mUppercase; + float mLineSpacing; unsigned int mSelectorColor; unsigned int mSelectedColor; std::shared_ptr mScrollSound; @@ -116,6 +118,7 @@ TextListComponent::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::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::render(const Eigen::Affine3f& parentTrans) offset[0] -= mHorizontalMargin; if(offset[0] < 0) offset[0] = 0; - break; } @@ -361,5 +363,8 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, c } if(properties & FORCE_UPPERCASE && elem->has("forceUppercase")) - setUppercase(elem->get("forceUppercase")); + setUppercase(elem->get("forceUppercase")); + + if(properties & LINE_SPACING && elem->has("lineSpacing")) + setLineSpacing(elem->get("lineSpacing")); }