Utility/SimpleTextDrawer: Add line spacing factor
This commit is contained in:
parent
548ede4613
commit
6b825a084c
|
|
@ -39,6 +39,7 @@ namespace Nz
|
||||||
const Line& GetLine(std::size_t index) const override;
|
const Line& GetLine(std::size_t index) const override;
|
||||||
std::size_t GetLineCount() const override;
|
std::size_t GetLineCount() const override;
|
||||||
inline float GetLineHeight() const;
|
inline float GetLineHeight() const;
|
||||||
|
inline float GetLineSpacingFactor() const;
|
||||||
float GetMaxLineWidth() const override;
|
float GetMaxLineWidth() const override;
|
||||||
inline const Color& GetOutlineColor() const;
|
inline const Color& GetOutlineColor() const;
|
||||||
inline float GetOutlineThickness() const;
|
inline float GetOutlineThickness() const;
|
||||||
|
|
@ -69,8 +70,8 @@ namespace Nz
|
||||||
|
|
||||||
void ClearGlyphs() const;
|
void ClearGlyphs() const;
|
||||||
|
|
||||||
void ConnectFontSlots();
|
inline void ConnectFontSlots();
|
||||||
void DisconnectFontSlots();
|
inline void DisconnectFontSlots();
|
||||||
|
|
||||||
bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, Nz::Color color, int renderOrder, int* advance) const;
|
bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, Nz::Color color, int renderOrder, int* advance) const;
|
||||||
void GenerateGlyphs(const String& text) const;
|
void GenerateGlyphs(const String& text) const;
|
||||||
|
|
@ -110,6 +111,7 @@ namespace Nz
|
||||||
mutable bool m_colorUpdated;
|
mutable bool m_colorUpdated;
|
||||||
mutable bool m_glyphUpdated;
|
mutable bool m_glyphUpdated;
|
||||||
mutable float m_lastSeparatorPosition;
|
mutable float m_lastSeparatorPosition;
|
||||||
|
float m_lineSpacingFactor;
|
||||||
float m_maxLineWidth;
|
float m_maxLineWidth;
|
||||||
float m_outlineThickness;
|
float m_outlineThickness;
|
||||||
unsigned int m_characterSize;
|
unsigned int m_characterSize;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ namespace Nz
|
||||||
m_style(TextStyle_Regular),
|
m_style(TextStyle_Regular),
|
||||||
m_colorUpdated(true),
|
m_colorUpdated(true),
|
||||||
m_glyphUpdated(true),
|
m_glyphUpdated(true),
|
||||||
|
m_lineSpacingFactor(1.f),
|
||||||
m_maxLineWidth(std::numeric_limits<float>::infinity()),
|
m_maxLineWidth(std::numeric_limits<float>::infinity()),
|
||||||
m_outlineThickness(0.f),
|
m_outlineThickness(0.f),
|
||||||
m_characterSize(24)
|
m_characterSize(24)
|
||||||
|
|
@ -27,6 +28,7 @@ namespace Nz
|
||||||
m_colorUpdated(false),
|
m_colorUpdated(false),
|
||||||
m_glyphUpdated(false),
|
m_glyphUpdated(false),
|
||||||
m_outlineColor(drawer.m_outlineColor),
|
m_outlineColor(drawer.m_outlineColor),
|
||||||
|
m_lineSpacingFactor(drawer.m_lineSpacingFactor),
|
||||||
m_maxLineWidth(drawer.m_maxLineWidth),
|
m_maxLineWidth(drawer.m_maxLineWidth),
|
||||||
m_outlineThickness(drawer.m_outlineThickness),
|
m_outlineThickness(drawer.m_outlineThickness),
|
||||||
m_characterSize(drawer.m_characterSize)
|
m_characterSize(drawer.m_characterSize)
|
||||||
|
|
@ -67,6 +69,11 @@ namespace Nz
|
||||||
return GetLineHeight(m_font->GetSizeInfo(m_characterSize));
|
return GetLineHeight(m_font->GetSizeInfo(m_characterSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float SimpleTextDrawer::GetLineSpacingFactor() const
|
||||||
|
{
|
||||||
|
return m_lineSpacingFactor;
|
||||||
|
}
|
||||||
|
|
||||||
inline const Color& SimpleTextDrawer::GetOutlineColor() const
|
inline const Color& SimpleTextDrawer::GetOutlineColor() const
|
||||||
{
|
{
|
||||||
return m_outlineColor;
|
return m_outlineColor;
|
||||||
|
|
@ -122,6 +129,16 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void SimpleTextDrawer::SetLineSpacingFactor(float factor)
|
||||||
|
{
|
||||||
|
if (m_lineSpacingFactor != factor)
|
||||||
|
{
|
||||||
|
m_lineSpacingFactor = factor;
|
||||||
|
|
||||||
|
InvalidateGlyphs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void SimpleTextDrawer::SetMaxLineWidth(float lineWidth)
|
inline void SimpleTextDrawer::SetMaxLineWidth(float lineWidth)
|
||||||
{
|
{
|
||||||
if (m_maxLineWidth != lineWidth)
|
if (m_maxLineWidth != lineWidth)
|
||||||
|
|
@ -180,6 +197,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
m_characterSize = drawer.m_characterSize;
|
m_characterSize = drawer.m_characterSize;
|
||||||
m_color = drawer.m_color;
|
m_color = drawer.m_color;
|
||||||
|
m_lineSpacingFactor = drawer.m_lineSpacingFactor;
|
||||||
m_maxLineWidth = drawer.m_maxLineWidth;
|
m_maxLineWidth = drawer.m_maxLineWidth;
|
||||||
m_outlineColor = drawer.m_outlineColor;
|
m_outlineColor = drawer.m_outlineColor;
|
||||||
m_outlineThickness = drawer.m_outlineThickness;
|
m_outlineThickness = drawer.m_outlineThickness;
|
||||||
|
|
@ -203,6 +221,7 @@ namespace Nz
|
||||||
m_glyphs = std::move(drawer.m_glyphs);
|
m_glyphs = std::move(drawer.m_glyphs);
|
||||||
m_glyphUpdated = std::move(drawer.m_glyphUpdated);
|
m_glyphUpdated = std::move(drawer.m_glyphUpdated);
|
||||||
m_font = std::move(drawer.m_font);
|
m_font = std::move(drawer.m_font);
|
||||||
|
m_lineSpacingFactor = drawer.m_lineSpacingFactor;
|
||||||
m_maxLineWidth = drawer.m_maxLineWidth;
|
m_maxLineWidth = drawer.m_maxLineWidth;
|
||||||
m_outlineColor = std::move(drawer.m_outlineColor);
|
m_outlineColor = std::move(drawer.m_outlineColor);
|
||||||
m_outlineThickness = std::move(drawer.m_outlineThickness);
|
m_outlineThickness = std::move(drawer.m_outlineThickness);
|
||||||
|
|
@ -210,7 +229,6 @@ namespace Nz
|
||||||
m_text = std::move(drawer.m_text);
|
m_text = std::move(drawer.m_text);
|
||||||
|
|
||||||
// Update slot pointers (TODO: Improve the way of doing this)
|
// Update slot pointers (TODO: Improve the way of doing this)
|
||||||
ConnectFontSlots();
|
|
||||||
if (m_font)
|
if (m_font)
|
||||||
{
|
{
|
||||||
drawer.DisconnectFontSlots();
|
drawer.DisconnectFontSlots();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue