RichText: Add support for outline color/thickness
This commit is contained in:
@@ -37,6 +37,8 @@ namespace Nz
|
||||
inline std::size_t GetBlockCount() const;
|
||||
inline std::size_t GetBlockFirstGlyphIndex(std::size_t index) const;
|
||||
inline const FontRef& GetBlockFont(std::size_t index) const;
|
||||
inline const Color& GetBlockOutlineColor(std::size_t index) const;
|
||||
inline float GetBlockOutlineThickness(std::size_t index) const;
|
||||
inline TextStyleFlags GetBlockStyle(std::size_t index) const;
|
||||
inline const String& GetBlockText(std::size_t index) const;
|
||||
|
||||
@@ -45,6 +47,8 @@ namespace Nz
|
||||
inline unsigned int GetDefaultCharacterSize() const;
|
||||
inline const Color& GetDefaultColor() const;
|
||||
inline const FontRef& GetDefaultFont() const;
|
||||
inline const Color& GetDefaultOutlineColor() const;
|
||||
inline float GetDefaultOutlineThickness() const;
|
||||
inline TextStyleFlags GetDefaultStyle() const;
|
||||
Font* GetFont(std::size_t index) const override;
|
||||
std::size_t GetFontCount() const override;
|
||||
@@ -63,12 +67,16 @@ namespace Nz
|
||||
inline void SetBlockCharacterSize(std::size_t index, unsigned int characterSize);
|
||||
inline void SetBlockColor(std::size_t index, const Color& color);
|
||||
inline void SetBlockFont(std::size_t index, FontRef font);
|
||||
inline void SetBlockOutlineColor(std::size_t index, const Color& color);
|
||||
inline void SetBlockOutlineThickness(std::size_t index, float thickness);
|
||||
inline void SetBlockStyle(std::size_t index, TextStyleFlags style);
|
||||
inline void SetBlockText(std::size_t index, String str);
|
||||
|
||||
inline void SetDefaultCharacterSize(unsigned int characterSize);
|
||||
inline void SetDefaultColor(const Color& color);
|
||||
inline void SetDefaultFont(const FontRef& font);
|
||||
inline void SetDefaultOutlineColor(const Color& color);
|
||||
inline void SetDefaultOutlineThickness(float thickness);
|
||||
inline void SetDefaultStyle(TextStyleFlags style);
|
||||
|
||||
void SetMaxLineWidth(float lineWidth) override;
|
||||
@@ -106,8 +114,10 @@ namespace Nz
|
||||
std::size_t fontIndex;
|
||||
std::size_t glyphIndex;
|
||||
Color color;
|
||||
Color outlineColor;
|
||||
String text;
|
||||
TextStyleFlags style;
|
||||
float outlineThickness;
|
||||
unsigned int characterSize;
|
||||
};
|
||||
|
||||
@@ -123,6 +133,7 @@ namespace Nz
|
||||
};
|
||||
|
||||
Color m_defaultColor;
|
||||
Color m_defaultOutlineColor;
|
||||
TextStyleFlags m_defaultStyle;
|
||||
FontRef m_defaultFont;
|
||||
std::unordered_map<FontRef, std::size_t> m_fontIndexes;
|
||||
@@ -134,6 +145,7 @@ namespace Nz
|
||||
mutable Recti m_bounds;
|
||||
mutable Vector2ui m_drawPos;
|
||||
mutable bool m_glyphUpdated;
|
||||
float m_defaultOutlineThickness;
|
||||
float m_maxLineWidth;
|
||||
unsigned int m_defaultCharacterSize;
|
||||
};
|
||||
@@ -151,12 +163,16 @@ namespace Nz
|
||||
inline Color GetColor() const;
|
||||
inline std::size_t GetFirstGlyphIndex() const;
|
||||
inline const FontRef& GetFont() const;
|
||||
inline Color GetOutlineColor() const;
|
||||
inline float GetOutlineThickness() const;
|
||||
inline TextStyleFlags GetStyle() const;
|
||||
inline const String& GetText() const;
|
||||
|
||||
inline void SetCharacterSize(unsigned int size);
|
||||
inline void SetColor(Color color);
|
||||
inline void SetFont(FontRef font);
|
||||
inline void SetOutlineColor(Color color);
|
||||
inline void SetOutlineThickness(float thickness);
|
||||
inline void SetStyle(TextStyleFlags style);
|
||||
inline void SetText(const String& text);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user