RichText: Add support for outline color/thickness

This commit is contained in:
Lynix
2019-12-28 11:43:48 +01:00
parent 988641b34b
commit 97418bfe04
5 changed files with 155 additions and 11 deletions

View File

@@ -82,6 +82,18 @@ namespace Nz
return m_fonts[fontIndex].font;
}
inline const Color& RichTextDrawer::GetBlockOutlineColor(std::size_t index) const
{
NazaraAssert(index < m_blocks.size(), "Invalid block index");
return m_blocks[index].outlineColor;
}
inline float RichTextDrawer::GetBlockOutlineThickness(std::size_t index) const
{
NazaraAssert(index < m_blocks.size(), "Invalid block index");
return m_blocks[index].outlineThickness;
}
inline TextStyleFlags RichTextDrawer::GetBlockStyle(std::size_t index) const
{
NazaraAssert(index < m_blocks.size(), "Invalid block index");
@@ -109,6 +121,16 @@ namespace Nz
return m_defaultFont;
}
inline const Color& RichTextDrawer::GetDefaultOutlineColor() const
{
return m_defaultOutlineColor;
}
inline float RichTextDrawer::GetDefaultOutlineThickness() const
{
return m_defaultOutlineThickness;
}
inline TextStyleFlags RichTextDrawer::GetDefaultStyle() const
{
return m_defaultStyle;
@@ -235,6 +257,24 @@ namespace Nz
m_fonts[fontIndex].useCount++;
m_blocks[index].fontIndex = fontIndex;
}
InvalidateGlyphs();
}
inline void RichTextDrawer::SetBlockOutlineColor(std::size_t index, const Color& color)
{
NazaraAssert(index < m_blocks.size(), "Invalid block index");
m_blocks[index].outlineColor = color;
InvalidateGlyphs();
}
inline void RichTextDrawer::SetBlockOutlineThickness(std::size_t index, float thickness)
{
NazaraAssert(index < m_blocks.size(), "Invalid block index");
m_blocks[index].outlineThickness = thickness;
InvalidateGlyphs();
}
inline void RichTextDrawer::SetBlockStyle(std::size_t index, TextStyleFlags style)
@@ -279,6 +319,16 @@ namespace Nz
m_defaultFont = font;
}
inline void RichTextDrawer::SetDefaultOutlineColor(const Color& color)
{
m_defaultOutlineColor = color;
}
inline void RichTextDrawer::SetDefaultOutlineThickness(float thickness)
{
m_defaultOutlineThickness = thickness;
}
inline void RichTextDrawer::SetDefaultStyle(TextStyleFlags style)
{
m_defaultStyle = style;
@@ -335,6 +385,28 @@ namespace Nz
return m_drawer.GetBlockFont(m_blockIndex);
}
/*!
* Returns the outline color used for the characters of the referenced block
* \return The referenced block outline color
*
* \see GetCharacterSize, GetColor, GetStyle, GetText, SetFont
*/
inline Color RichTextDrawer::BlockRef::GetOutlineColor() const
{
return m_drawer.GetBlockOutlineColor(m_blockIndex);
}
/*!
* Returns the outline thickness used for the characters of the referenced block
* \return The referenced block outline thickness
*
* \see GetCharacterSize, GetColor, GetStyle, GetText, SetFont
*/
inline float RichTextDrawer::BlockRef::GetOutlineThickness() const
{
return m_drawer.GetBlockOutlineThickness(m_blockIndex);
}
/*!
* Returns the style flags used for the characters of the referenced block
* \return The referenced block style flags (see TextStyleFlags)
@@ -401,6 +473,28 @@ namespace Nz
m_drawer.SetBlockFont(m_blockIndex, std::move(font));
}
/*!
* Changes the outline color of the referenced block characters
* \remark This invalidates the drawer and will force a (complete or partial, depending on the block index) glyph regeneration to occur.
*
* \see GetCharacterSize, SetCharacterSize, SetColor, SetStyle, SetText
*/
inline void RichTextDrawer::BlockRef::SetOutlineColor(Color color)
{
m_drawer.SetBlockOutlineColor(m_blockIndex, std::move(color));
}
/*!
* Changes the outline thickness of the referenced block characters
* \remark This invalidates the drawer and will force a (complete or partial, depending on the block index) glyph regeneration to occur.
*
* \see GetCharacterSize, SetCharacterSize, SetColor, SetStyle, SetText
*/
inline void RichTextDrawer::BlockRef::SetOutlineThickness(float thickness)
{
m_drawer.SetBlockOutlineThickness(m_blockIndex, thickness);
}
/*!
* Changes the style flags of the referenced block characters
* \remark This invalidates the drawer and will force a (complete or partial, depending on the block index) glyph regeneration to occur.