Utility/SimpleTextDrawer: Replace line spacing factor by line spacing offset

This commit is contained in:
Lynix 2020-01-26 16:19:06 +01:00
parent 11d51872fa
commit 977044f59e
3 changed files with 14 additions and 13 deletions

View File

@ -219,6 +219,7 @@ Nazara Engine:
- On Windows, Thread::Set(Current)Name now uses `SetThreadDescription` Win32 function if possible instead of triggering a debugger exception. MinGW builds will use this if available too. - On Windows, Thread::Set(Current)Name now uses `SetThreadDescription` Win32 function if possible instead of triggering a debugger exception. MinGW builds will use this if available too.
- ⚠ Removed Texture(const Image\*) constructor, use Texture::LoadFromImage instead - ⚠ Removed Texture(const Image\*) constructor, use Texture::LoadFromImage instead
- ⚠ TextDrawers now use floating-point internally and to exposes their Bounds (AbstractTextDrawer::GetBounds() now returns a Rectf) - ⚠ TextDrawers now use floating-point internally and to exposes their Bounds (AbstractTextDrawer::GetBounds() now returns a Rectf)
- Added SimpleTextDrawer character and line spacing offset properties
Nazara Development Kit: Nazara Development Kit:
- Added ImageWidget (#139) - Added ImageWidget (#139)

View File

@ -40,7 +40,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; inline float GetLineSpacingOffset() 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;
@ -51,7 +51,7 @@ namespace Nz
inline void SetCharacterSize(unsigned int characterSize); inline void SetCharacterSize(unsigned int characterSize);
inline void SetColor(const Color& color); inline void SetColor(const Color& color);
inline void SetFont(Font* font); inline void SetFont(Font* font);
inline void SetLineSpacingFactor(float factor); inline void SetLineSpacingOffset(float offset);
inline void SetMaxLineWidth(float lineWidth) override; inline void SetMaxLineWidth(float lineWidth) override;
inline void SetOutlineColor(const Color& color); inline void SetOutlineColor(const Color& color);
inline void SetOutlineThickness(float thickness); inline void SetOutlineThickness(float thickness);
@ -113,8 +113,8 @@ 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_characterSpacingOffset; float m_characterSpacingOffset;
float m_lineSpacingOffset;
float m_maxLineWidth; float m_maxLineWidth;
float m_outlineThickness; float m_outlineThickness;
unsigned int m_characterSize; unsigned int m_characterSize;

View File

@ -13,8 +13,8 @@ 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_characterSpacingOffset(0.f), m_characterSpacingOffset(0.f),
m_lineSpacingOffset(0.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)
@ -29,8 +29,8 @@ 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_characterSpacingOffset(drawer.m_characterSpacingOffset), m_characterSpacingOffset(drawer.m_characterSpacingOffset),
m_lineSpacingOffset(drawer.m_lineSpacingOffset),
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)
@ -76,9 +76,9 @@ namespace Nz
return GetLineHeight(m_font->GetSizeInfo(m_characterSize)); return GetLineHeight(m_font->GetSizeInfo(m_characterSize));
} }
inline float SimpleTextDrawer::GetLineSpacingFactor() const inline float SimpleTextDrawer::GetLineSpacingOffset() const
{ {
return m_lineSpacingFactor; return m_lineSpacingOffset;
} }
inline const Color& SimpleTextDrawer::GetOutlineColor() const inline const Color& SimpleTextDrawer::GetOutlineColor() const
@ -146,11 +146,11 @@ namespace Nz
} }
} }
inline void SimpleTextDrawer::SetLineSpacingFactor(float factor) inline void SimpleTextDrawer::SetLineSpacingOffset(float offset)
{ {
if (m_lineSpacingFactor != factor) if (m_lineSpacingOffset != offset)
{ {
m_lineSpacingFactor = factor; m_lineSpacingOffset = offset;
InvalidateGlyphs(); InvalidateGlyphs();
} }
@ -215,7 +215,7 @@ namespace Nz
m_characterSize = drawer.m_characterSize; m_characterSize = drawer.m_characterSize;
m_characterSpacingOffset = drawer.m_characterSpacingOffset; m_characterSpacingOffset = drawer.m_characterSpacingOffset;
m_color = drawer.m_color; m_color = drawer.m_color;
m_lineSpacingFactor = drawer.m_lineSpacingFactor; m_lineSpacingOffset = drawer.m_lineSpacingOffset;
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;
@ -240,7 +240,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_lineSpacingOffset = drawer.m_lineSpacingOffset;
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);
@ -330,7 +330,7 @@ namespace Nz
inline float SimpleTextDrawer::GetLineHeight(const Font::SizeInfo& sizeInfo) const inline float SimpleTextDrawer::GetLineHeight(const Font::SizeInfo& sizeInfo) const
{ {
return float(sizeInfo.lineHeight) * m_lineSpacingFactor; return float(sizeInfo.lineHeight) + m_lineSpacingOffset;
} }
inline void SimpleTextDrawer::InvalidateColor() inline void SimpleTextDrawer::InvalidateColor()