diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index 0aeecb239..3c903d34c 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) Nz::SimpleTextDrawer textDrawer; textDrawer.SetText("Hello world !"); textDrawer.SetCharacterSize(72); - textDrawer.SetOutlineThickness(4.f); + textDrawer.SetTextOutlineThickness(4.f); std::shared_ptr textSprite = std::make_shared(); textSprite->Update(textDrawer); diff --git a/examples/Tut02/main.cpp b/examples/Tut02/main.cpp index 83a5ec2a6..87b22f8bb 100644 --- a/examples/Tut02/main.cpp +++ b/examples/Tut02/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) Nz::SimpleTextDrawer textDrawer; textDrawer.SetCharacterSize(72); - textDrawer.SetOutlineThickness(4.f); + textDrawer.SetTextOutlineThickness(4.f); textDrawer.SetText("Press a key"); std::shared_ptr textSprite = std::make_shared(); diff --git a/include/Nazara/Utility/RichTextDrawer.hpp b/include/Nazara/Utility/RichTextDrawer.hpp index 8d8f59f3d..f771a680e 100644 --- a/include/Nazara/Utility/RichTextDrawer.hpp +++ b/include/Nazara/Utility/RichTextDrawer.hpp @@ -23,10 +23,10 @@ namespace Nz RichTextDrawer(); RichTextDrawer(const RichTextDrawer& drawer); - RichTextDrawer(RichTextDrawer&& drawer); + RichTextDrawer(RichTextDrawer&& drawer) noexcept; ~RichTextDrawer(); - BlockRef AppendText(const std::string& str, bool forceNewBlock = false); + BlockRef AppendText(std::string_view str, bool forceNewBlock = false); void Clear() override; @@ -38,7 +38,6 @@ namespace Nz inline std::size_t GetBlockCount() const; inline std::size_t GetBlockFirstGlyphIndex(std::size_t index) const; inline const std::shared_ptr& GetBlockFont(std::size_t index) const; - inline float GetBlockLineHeight(std::size_t index) const; inline float GetBlockLineSpacingOffset(std::size_t index) const; inline const Color& GetBlockOutlineColor(std::size_t index) const; inline float GetBlockOutlineThickness(std::size_t index) const; @@ -47,14 +46,9 @@ namespace Nz inline BlockRef GetBlock(std::size_t index); const Rectf& GetBounds() const override; - inline unsigned int GetDefaultCharacterSize() const; - inline float GetDefaultCharacterSpacingOffset() const; - inline const Color& GetDefaultColor() const; - inline const std::shared_ptr& GetDefaultFont() const; - inline float GetDefaultLineSpacingOffset() const; - inline const Color& GetDefaultOutlineColor() const; - inline float GetDefaultOutlineThickness() const; - inline TextStyleFlags GetDefaultStyle() const; + inline unsigned int GetCharacterSize() const; + inline float GetCharacterSpacingOffset() const; + inline float GetLineSpacingOffset() const; const std::shared_ptr& GetFont(std::size_t index) const override; std::size_t GetFontCount() const override; const Glyph& GetGlyph(std::size_t index) const override; @@ -63,6 +57,12 @@ namespace Nz std::size_t GetLineCount() const override; float GetMaxLineWidth() const override; + inline const Color& GetTextColor() const; + inline const std::shared_ptr& GetTextFont() const; + inline const Color& GetTextOutlineColor() const; + inline float GetTextOutlineThickness() const; + inline TextStyleFlags GetTextStyle() const; + inline bool HasBlocks() const; void MergeBlocks(); @@ -79,22 +79,22 @@ namespace Nz inline void SetBlockStyle(std::size_t index, TextStyleFlags style); inline void SetBlockText(std::size_t index, std::string str); - inline void SetDefaultCharacterSize(unsigned int characterSize); - inline void SetDefaultCharacterSpacingOffset(float offset); - inline void SetDefaultColor(const Color& color); - inline void SetDefaultFont(const std::shared_ptr& font); - inline void SetDefaultLineSpacingOffset(float offset); - inline void SetDefaultOutlineColor(const Color& color); - inline void SetDefaultOutlineThickness(float thickness); - inline void SetDefaultStyle(TextStyleFlags style); + inline void SetCharacterSize(unsigned int characterSize); + inline void SetCharacterSpacingOffset(float offset); + inline void SetLineSpacingOffset(float offset); + inline void SetTextColor(const Color& color); + inline void SetTextFont(const std::shared_ptr& font); + inline void SetTextOutlineColor(const Color& color); + inline void SetTextOutlineThickness(float thickness); + inline void SetTextStyle(TextStyleFlags style); void SetMaxLineWidth(float lineWidth) override; RichTextDrawer& operator=(const RichTextDrawer& drawer); - RichTextDrawer& operator=(RichTextDrawer&& drawer); + RichTextDrawer& operator=(RichTextDrawer&& drawer) noexcept; static constexpr std::size_t InvalidBlockIndex = std::numeric_limits::max(); - + private: struct Block; @@ -145,10 +145,10 @@ namespace Nz NazaraSlot(Font, OnFontRelease, fontReleaseSlot); }; - Color m_defaultColor; - Color m_defaultOutlineColor; - TextStyleFlags m_defaultStyle; - std::shared_ptr m_defaultFont; + Color m_currentColor; + Color m_currentOutlineColor; + TextStyleFlags m_currentStyle; + std::shared_ptr m_currentFont; mutable std::size_t m_lastSeparatorGlyph; std::unordered_map, std::size_t> m_fontIndexes; std::vector m_blocks; @@ -158,11 +158,11 @@ namespace Nz mutable Rectf m_bounds; mutable Vector2f m_drawPos; mutable bool m_glyphUpdated; - float m_defaultCharacterSpacingOffset; - float m_defaultLineSpacingOffset; - float m_defaultOutlineThickness; + float m_currentCharacterSpacingOffset; + float m_currentLineSpacingOffset; + float m_currentOutlineThickness; float m_maxLineWidth; - unsigned int m_defaultCharacterSize; + unsigned int m_currentCharacterSize; mutable float m_lastSeparatorPosition; }; diff --git a/include/Nazara/Utility/RichTextDrawer.inl b/include/Nazara/Utility/RichTextDrawer.inl index 3b57d593c..ac9b1e7a3 100644 --- a/include/Nazara/Utility/RichTextDrawer.inl +++ b/include/Nazara/Utility/RichTextDrawer.inl @@ -87,12 +87,6 @@ namespace Nz return m_fonts[fontIndex].font; } - inline float RichTextDrawer::GetBlockLineHeight(std::size_t index) const - { - NazaraAssert(index < m_blocks.size(), "Invalid block index"); - return m_blocks[index].lineSpacingOffset; - } - inline float RichTextDrawer::GetBlockLineSpacingOffset(std::size_t index) const { NazaraAssert(index < m_blocks.size(), "Invalid block index"); @@ -123,44 +117,19 @@ namespace Nz return m_blocks[index].text; } - inline unsigned int RichTextDrawer::GetDefaultCharacterSize() const + inline unsigned int RichTextDrawer::GetCharacterSize() const { - return m_defaultCharacterSize; + return m_currentCharacterSize; } - inline float RichTextDrawer::GetDefaultCharacterSpacingOffset() const + inline float RichTextDrawer::GetCharacterSpacingOffset() const { - return m_defaultCharacterSpacingOffset; + return m_currentCharacterSpacingOffset; } - inline const Color& RichTextDrawer::GetDefaultColor() const + inline float RichTextDrawer::GetLineSpacingOffset() const { - return m_defaultColor; - } - - inline const std::shared_ptr& RichTextDrawer::GetDefaultFont() const - { - return m_defaultFont; - } - - inline float RichTextDrawer::GetDefaultLineSpacingOffset() const - { - return m_defaultLineSpacingOffset; - } - - 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; + return m_currentLineSpacingOffset; } inline void RichTextDrawer::AppendNewLine(const Font& font, unsigned int characterSize, float lineSpacingOffset) const @@ -261,6 +230,31 @@ namespace Nz return m_lines.back().bounds.GetMaximum().x + size > m_maxLineWidth; } + inline const Color& RichTextDrawer::GetTextColor() const + { + return m_currentColor; + } + + inline const std::shared_ptr& RichTextDrawer::GetTextFont() const + { + return m_currentFont; + } + + inline const Color& RichTextDrawer::GetTextOutlineColor() const + { + return m_currentOutlineColor; + } + + inline float RichTextDrawer::GetTextOutlineThickness() const + { + return m_currentOutlineThickness; + } + + inline TextStyleFlags RichTextDrawer::GetTextStyle() const + { + return m_currentStyle; + } + inline bool RichTextDrawer::HasBlocks() const { return !m_blocks.empty(); @@ -358,44 +352,44 @@ namespace Nz InvalidateGlyphs(); } - inline void RichTextDrawer::SetDefaultCharacterSize(unsigned int characterSize) + inline void RichTextDrawer::SetCharacterSize(unsigned int characterSize) { - m_defaultCharacterSize = characterSize; + m_currentCharacterSize = characterSize; } - inline void RichTextDrawer::SetDefaultCharacterSpacingOffset(float offset) + inline void RichTextDrawer::SetCharacterSpacingOffset(float offset) { - m_defaultCharacterSpacingOffset = offset; + m_currentCharacterSpacingOffset = offset; } - inline void RichTextDrawer::SetDefaultColor(const Color& color) + inline void RichTextDrawer::SetLineSpacingOffset(float offset) { - m_defaultColor = color; + m_currentLineSpacingOffset = offset; } - inline void RichTextDrawer::SetDefaultFont(const std::shared_ptr& font) + inline void RichTextDrawer::SetTextColor(const Color& color) { - m_defaultFont = font; + m_currentColor = color; } - inline void RichTextDrawer::SetDefaultLineSpacingOffset(float offset) + inline void RichTextDrawer::SetTextFont(const std::shared_ptr& font) { - m_defaultLineSpacingOffset = offset; + m_currentFont = font; } - inline void RichTextDrawer::SetDefaultOutlineColor(const Color& color) + inline void RichTextDrawer::SetTextOutlineColor(const Color& color) { - m_defaultOutlineColor = color; + m_currentOutlineColor = color; } - inline void RichTextDrawer::SetDefaultOutlineThickness(float thickness) + inline void RichTextDrawer::SetTextOutlineThickness(float thickness) { - m_defaultOutlineThickness = thickness; + m_currentOutlineThickness = thickness; } - inline void RichTextDrawer::SetDefaultStyle(TextStyleFlags style) + inline void RichTextDrawer::SetTextStyle(TextStyleFlags style) { - m_defaultStyle = style; + m_currentStyle = style; } inline void RichTextDrawer::InvalidateGlyphs() @@ -453,7 +447,7 @@ namespace Nz * Returns the font used for the characters of the referenced block * \return A reference on the referenced block font * - * \see GetCharacterSize, GetColor, GetStyle, GetText, SetFont + * \see GetCharacterSize, GetTextColor, GetStyle, GetText, SetFont */ inline const std::shared_ptr& RichTextDrawer::BlockRef::GetFont() const { @@ -464,7 +458,7 @@ namespace Nz * Returns the line spacing offset used for the characters of the referenced block * \return The referenced block character size * - * \see GetColor, GetFont, GetStyle, GetText, SetCharacterSize + * \see GetTextColor, GetTextFont, GetStyle, GetText, SetCharacterSize */ inline float RichTextDrawer::BlockRef::GetLineSpacingOffset() const { @@ -475,7 +469,7 @@ namespace Nz * Returns the outline color used for the characters of the referenced block * \return The referenced block outline color * - * \see GetCharacterSize, GetColor, GetStyle, GetText, SetFont + * \see GetCharacterSize, GetTextColor, GetStyle, GetText, SetFont */ inline Color RichTextDrawer::BlockRef::GetOutlineColor() const { @@ -486,7 +480,7 @@ namespace Nz * Returns the outline thickness used for the characters of the referenced block * \return The referenced block outline thickness * - * \see GetCharacterSize, GetColor, GetStyle, GetText, SetFont + * \see GetCharacterSize, GetTextColor, GetStyle, GetText, SetFont */ inline float RichTextDrawer::BlockRef::GetOutlineThickness() const { @@ -497,7 +491,7 @@ namespace Nz * Returns the style flags used for the characters of the referenced block * \return The referenced block style flags (see TextStyleFlags) * - * \see GetCharacterSize, GetColor, GetFont, GetText, SetStyle + * \see GetCharacterSize, GetTextColor, GetTextFont, GetText, SetStyle */ inline TextStyleFlags RichTextDrawer::BlockRef::GetStyle() const { @@ -519,7 +513,7 @@ namespace Nz * Returns the text of the referenced block * \return The referenced block text * - * \see GetCharacterSize, GetColor, GetFont, GetStyle, SetText + * \see GetCharacterSize, GetTextColor, GetTextFont, GetStyle, SetText */ inline const std::string& RichTextDrawer::BlockRef::GetText() const { @@ -552,7 +546,7 @@ namespace Nz * Changes the color of the referenced block characters * \remark This is the only property that can be changed without forcing a glyph regeneration * - * \see GetColor, SetCharacterSize, SetFont, SetStyle, SetText + * \see GetTextColor, SetCharacterSize, SetFont, SetStyle, SetText */ inline void RichTextDrawer::BlockRef::SetColor(Color color) { @@ -563,7 +557,7 @@ namespace Nz * Changes the font 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 + * \see GetCharacterSize, SetCharacterSize, SetTextColor, SetStyle, SetText */ inline void RichTextDrawer::BlockRef::SetFont(std::shared_ptr font) { @@ -574,7 +568,7 @@ namespace Nz * Changes the line spacing offset 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 GetLineSpacingOffset, SetColor, SetFont, SetStyle, SetText + * \see GetLineSpacingOffset, SetTextColor, SetTextFont, SetStyle, SetText */ inline void RichTextDrawer::BlockRef::SetLineSpacingOffset(float offset) { @@ -585,7 +579,7 @@ namespace Nz * 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 + * \see GetCharacterSize, SetCharacterSize, SetTextColor, SetStyle, SetText */ inline void RichTextDrawer::BlockRef::SetOutlineColor(Color color) { @@ -596,7 +590,7 @@ namespace Nz * 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 + * \see GetCharacterSize, SetCharacterSize, SetTextColor, SetStyle, SetText */ inline void RichTextDrawer::BlockRef::SetOutlineThickness(float thickness) { @@ -607,7 +601,7 @@ namespace Nz * 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. * - * \see GetStyle, SetCharacterSize, SetColor, SetFont, SetText + * \see GetStyle, SetCharacterSize, SetTextColor, SetTextFont, SetText */ inline void RichTextDrawer::BlockRef::SetStyle(TextStyleFlags style) { @@ -618,7 +612,7 @@ namespace Nz * Changes the text of the referenced block * \remark This invalidates the drawer and will force a (complete or partial, depending on the block index) glyph regeneration to occur. * - * \see GetText, SetCharacterSize, SetColor, SetFont, SetStyle + * \see GetText, SetCharacterSize, SetTextColor, SetTextFont, SetTextStyle */ inline void RichTextDrawer::BlockRef::SetText(std::string text) { @@ -627,3 +621,4 @@ namespace Nz } #include +#include "RichTextDrawer.hpp" diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 7501de127..65db57566 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -30,8 +30,6 @@ namespace Nz const Rectf& GetBounds() const override; inline float GetCharacterSpacingOffset() const; inline unsigned int GetCharacterSize() const; - inline const Color& GetColor() const; - inline const std::shared_ptr& GetFont() const; const std::shared_ptr& GetFont(std::size_t index) const override; std::size_t GetFontCount() const override; const Glyph& GetGlyph(std::size_t index) const override; @@ -41,29 +39,32 @@ namespace Nz inline float GetLineHeight() const; inline float GetLineSpacingOffset() const; float GetMaxLineWidth() const override; - inline const Color& GetOutlineColor() const; - inline float GetOutlineThickness() const; - inline TextStyleFlags GetStyle() const; + inline const std::string& GetText() const; + inline const Color& GetTextColor() const; + inline const std::shared_ptr& GetTextFont() const; + inline const Color& GetTextOutlineColor() const; + inline float GetTextOutlineThickness() const; + inline TextStyleFlags GetTextStyle() const; inline void SetCharacterSpacingOffset(float offset); inline void SetCharacterSize(unsigned int characterSize); - inline void SetColor(const Color& color); - inline void SetFont(std::shared_ptr font); inline void SetLineSpacingOffset(float offset); inline void SetMaxLineWidth(float lineWidth) override; - inline void SetOutlineColor(const Color& color); - inline void SetOutlineThickness(float thickness); - inline void SetStyle(TextStyleFlags style); inline void SetText(std::string str); + inline void SetTextColor(const Color& color); + inline void SetTextFont(std::shared_ptr font); + inline void SetTextOutlineColor(const Color& color); + inline void SetTextOutlineThickness(float thickness); + inline void SetTextStyle(TextStyleFlags style); inline SimpleTextDrawer& operator=(const SimpleTextDrawer& drawer); inline SimpleTextDrawer& operator=(SimpleTextDrawer&& drawer) noexcept; - static inline SimpleTextDrawer Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); - static inline SimpleTextDrawer Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); - static inline SimpleTextDrawer Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); - static inline SimpleTextDrawer Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); + static inline SimpleTextDrawer Draw(std::string str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); + static inline SimpleTextDrawer Draw(std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); + static inline SimpleTextDrawer Draw(const std::shared_ptr& font, std::string str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); + static inline SimpleTextDrawer Draw(const std::shared_ptr& font, std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); private: inline void AppendNewLine() const; diff --git a/include/Nazara/Utility/SimpleTextDrawer.inl b/include/Nazara/Utility/SimpleTextDrawer.inl index 79524c4c9..d8d2210c5 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.inl +++ b/include/Nazara/Utility/SimpleTextDrawer.inl @@ -18,7 +18,7 @@ namespace Nz m_outlineThickness(0.f), m_characterSize(24) { - SetFont(Font::GetDefault()); + SetTextFont(Font::GetDefault()); } inline SimpleTextDrawer::SimpleTextDrawer(const SimpleTextDrawer& drawer) : @@ -34,7 +34,7 @@ namespace Nz m_outlineThickness(drawer.m_outlineThickness), m_characterSize(drawer.m_characterSize) { - SetFont(drawer.m_font); + SetTextFont(drawer.m_font); } inline SimpleTextDrawer::SimpleTextDrawer(SimpleTextDrawer&& drawer) noexcept @@ -59,16 +59,6 @@ namespace Nz return m_characterSize; } - inline const Color& SimpleTextDrawer::GetColor() const - { - return m_color; - } - - inline const std::shared_ptr& SimpleTextDrawer::GetFont() const - { - return m_font; - } - inline float SimpleTextDrawer::GetLineHeight() const { NazaraAssert(m_font, "SimpleTextDrawer has no font"); @@ -80,26 +70,36 @@ namespace Nz return m_lineSpacingOffset; } - inline const Color& SimpleTextDrawer::GetOutlineColor() const + inline const std::string& SimpleTextDrawer::GetText() const + { + return m_text; + } + + inline const Color& SimpleTextDrawer::GetTextColor() const + { + return m_color; + } + + inline const std::shared_ptr& SimpleTextDrawer::GetTextFont() const + { + return m_font; + } + + inline const Color& SimpleTextDrawer::GetTextOutlineColor() const { return m_outlineColor; } - inline float SimpleTextDrawer::GetOutlineThickness() const + inline float SimpleTextDrawer::GetTextOutlineThickness() const { return m_outlineThickness; } - inline TextStyleFlags SimpleTextDrawer::GetStyle() const + inline TextStyleFlags SimpleTextDrawer::GetTextStyle() const { return m_style; } - inline const std::string& SimpleTextDrawer::GetText() const - { - return m_text; - } - inline void SimpleTextDrawer::SetCharacterSpacingOffset(float offset) { if (m_characterSpacingOffset != offset) @@ -120,31 +120,6 @@ namespace Nz } } - inline void SimpleTextDrawer::SetColor(const Color& color) - { - if (m_color != color) - { - m_color = color; - - InvalidateColor(); - } - } - - inline void SimpleTextDrawer::SetFont(std::shared_ptr font) - { - if (m_font != font) - { - m_font = std::move(font); - - if (m_font) - ConnectFontSlots(); - else - DisconnectFontSlots(); - - InvalidateGlyphs(); - } - } - inline void SimpleTextDrawer::SetLineSpacingOffset(float offset) { if (m_lineSpacingOffset != offset) @@ -167,7 +142,42 @@ namespace Nz } } - inline void SimpleTextDrawer::SetOutlineColor(const Color& color) + inline void SimpleTextDrawer::SetText(std::string str) + { + if (m_text != str) + { + m_text = std::move(str); + + InvalidateGlyphs(); + } + } + + inline void SimpleTextDrawer::SetTextColor(const Color& color) + { + if (m_color != color) + { + m_color = color; + + InvalidateColor(); + } + } + + inline void SimpleTextDrawer::SetTextFont(std::shared_ptr font) + { + if (m_font != font) + { + m_font = std::move(font); + + if (m_font) + ConnectFontSlots(); + else + DisconnectFontSlots(); + + InvalidateGlyphs(); + } + } + + inline void SimpleTextDrawer::SetTextOutlineColor(const Color& color) { if (m_outlineColor != color) { @@ -177,7 +187,7 @@ namespace Nz } } - inline void SimpleTextDrawer::SetOutlineThickness(float thickness) + inline void SimpleTextDrawer::SetTextOutlineThickness(float thickness) { if (m_outlineThickness != thickness) { @@ -189,7 +199,7 @@ namespace Nz } } - inline void SimpleTextDrawer::SetStyle(TextStyleFlags style) + inline void SimpleTextDrawer::SetTextStyle(TextStyleFlags style) { if (m_style != style) { @@ -199,16 +209,6 @@ namespace Nz } } - inline void SimpleTextDrawer::SetText(std::string str) - { - if (m_text != str) - { - m_text = std::move(str); - - InvalidateGlyphs(); - } - } - inline SimpleTextDrawer& SimpleTextDrawer::operator=(const SimpleTextDrawer& drawer) { m_characterSize = drawer.m_characterSize; @@ -221,7 +221,7 @@ namespace Nz m_style = drawer.m_style; m_text = drawer.m_text; - SetFont(drawer.m_font); + SetTextFont(drawer.m_font); InvalidateGlyphs(); return *this; @@ -256,52 +256,52 @@ namespace Nz return *this; } - inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color) + inline SimpleTextDrawer SimpleTextDrawer::Draw(std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color) { SimpleTextDrawer drawer; drawer.SetCharacterSize(characterSize); - drawer.SetColor(color); - drawer.SetStyle(style); - drawer.SetText(str); + drawer.SetTextColor(color); + drawer.SetTextStyle(style); + drawer.SetText(std::move(str)); return drawer; } - inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor) + inline SimpleTextDrawer SimpleTextDrawer::Draw(std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor) { SimpleTextDrawer drawer; drawer.SetCharacterSize(characterSize); - drawer.SetColor(color); - drawer.SetOutlineColor(outlineColor); - drawer.SetOutlineThickness(outlineThickness); - drawer.SetStyle(style); - drawer.SetText(str); + drawer.SetTextColor(color); + drawer.SetTextOutlineColor(outlineColor); + drawer.SetTextOutlineThickness(outlineThickness); + drawer.SetTextStyle(style); + drawer.SetText(std::move(str)); return drawer; } - inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color) + inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::shared_ptr& font, std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color) { SimpleTextDrawer drawer; drawer.SetCharacterSize(characterSize); - drawer.SetColor(color); - drawer.SetFont(font); - drawer.SetStyle(style); - drawer.SetText(str); + drawer.SetTextColor(color); + drawer.SetTextFont(font); + drawer.SetTextStyle(style); + drawer.SetText(std::move(str)); return drawer; } - inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor) + inline SimpleTextDrawer SimpleTextDrawer::Draw(const std::shared_ptr& font, std::string str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor) { SimpleTextDrawer drawer; drawer.SetCharacterSize(characterSize); - drawer.SetColor(color); - drawer.SetFont(font); - drawer.SetOutlineColor(outlineColor); - drawer.SetOutlineThickness(outlineThickness); - drawer.SetStyle(style); - drawer.SetText(str); + drawer.SetTextColor(color); + drawer.SetTextFont(font); + drawer.SetTextOutlineColor(outlineColor); + drawer.SetTextOutlineThickness(outlineThickness); + drawer.SetTextStyle(style); + drawer.SetText(std::move(str)); return drawer; } diff --git a/include/Nazara/Widgets/AbstractTextAreaWidget.hpp b/include/Nazara/Widgets/AbstractTextAreaWidget.hpp index 711126d6e..c0bea3693 100644 --- a/include/Nazara/Widgets/AbstractTextAreaWidget.hpp +++ b/include/Nazara/Widgets/AbstractTextAreaWidget.hpp @@ -64,9 +64,9 @@ namespace Nz inline void SetReadOnly(bool readOnly = true); inline void SetSelection(Vector2ui fromPosition, Vector2ui toPosition); - inline void Write(const std::string& text); - inline void Write(const std::string& text, const Vector2ui& glyphPosition); - virtual void Write(const std::string& text, std::size_t glyphPosition) = 0; + inline void Write(std::string_view text); + inline void Write(std::string_view text, const Vector2ui& glyphPosition); + virtual void Write(std::string_view text, std::size_t glyphPosition) = 0; AbstractTextAreaWidget& operator=(const AbstractTextAreaWidget&) = delete; AbstractTextAreaWidget& operator=(AbstractTextAreaWidget&&) = delete; diff --git a/include/Nazara/Widgets/AbstractTextAreaWidget.inl b/include/Nazara/Widgets/AbstractTextAreaWidget.inl index da7e83353..769a7e3b1 100644 --- a/include/Nazara/Widgets/AbstractTextAreaWidget.inl +++ b/include/Nazara/Widgets/AbstractTextAreaWidget.inl @@ -231,12 +231,12 @@ namespace Nz } } - inline void AbstractTextAreaWidget::Write(const std::string& text) + inline void AbstractTextAreaWidget::Write(std::string_view text) { Write(text, GetGlyphIndex(m_cursorPositionBegin)); } - inline void AbstractTextAreaWidget::Write(const std::string& text, const Vector2ui& glyphPosition) + inline void AbstractTextAreaWidget::Write(std::string_view text, const Vector2ui& glyphPosition) { Write(text, GetGlyphIndex(glyphPosition)); } diff --git a/include/Nazara/Widgets/RichTextAreaWidget.hpp b/include/Nazara/Widgets/RichTextAreaWidget.hpp index c3f763752..d42a40b61 100644 --- a/include/Nazara/Widgets/RichTextAreaWidget.hpp +++ b/include/Nazara/Widgets/RichTextAreaWidget.hpp @@ -20,7 +20,7 @@ namespace Nz RichTextAreaWidget(RichTextAreaWidget&&) = delete; ~RichTextAreaWidget() = default; - void AppendText(const std::string& text); + void AppendText(std::string_view text); void Clear() override; @@ -44,7 +44,7 @@ namespace Nz inline void SetTextOutlineThickness(float thickness); inline void SetTextStyle(TextStyleFlags style); - void Write(const std::string& text, std::size_t glyphPosition) override; + void Write(std::string_view text, std::size_t glyphPosition) override; RichTextAreaWidget& operator=(const RichTextAreaWidget&) = delete; RichTextAreaWidget& operator=(RichTextAreaWidget&&) = delete; diff --git a/include/Nazara/Widgets/RichTextAreaWidget.inl b/include/Nazara/Widgets/RichTextAreaWidget.inl index 899a9f7d5..3a82795a9 100644 --- a/include/Nazara/Widgets/RichTextAreaWidget.inl +++ b/include/Nazara/Widgets/RichTextAreaWidget.inl @@ -8,82 +8,82 @@ namespace Nz { inline unsigned int RichTextAreaWidget::GetCharacterSize() const { - return m_drawer.GetDefaultCharacterSize(); + return m_drawer.GetCharacterSize(); } inline float RichTextAreaWidget::GetCharacterSpacingOffset() const { - return m_drawer.GetDefaultCharacterSpacingOffset(); + return m_drawer.GetCharacterSpacingOffset(); } inline float RichTextAreaWidget::GetLineSpacingOffset() const { - return m_drawer.GetDefaultLineSpacingOffset(); + return m_drawer.GetLineSpacingOffset(); } inline const Color& RichTextAreaWidget::GetTextColor() const { - return m_drawer.GetDefaultColor(); + return m_drawer.GetTextColor(); } inline const std::shared_ptr& RichTextAreaWidget::GetTextFont() const { - return m_drawer.GetDefaultFont(); + return m_drawer.GetTextFont(); } inline const Color& RichTextAreaWidget::GetTextOutlineColor() const { - return m_drawer.GetDefaultOutlineColor(); + return m_drawer.GetTextOutlineColor(); } inline float RichTextAreaWidget::GetTextOutlineThickness() const { - return m_drawer.GetDefaultOutlineThickness(); + return m_drawer.GetTextOutlineThickness(); } inline TextStyleFlags RichTextAreaWidget::GetTextStyle() const { - return m_drawer.GetDefaultStyle(); + return m_drawer.GetTextStyle(); } inline void RichTextAreaWidget::SetCharacterSize(unsigned int characterSize) { - m_drawer.SetDefaultCharacterSize(characterSize); + m_drawer.SetCharacterSize(characterSize); } inline void RichTextAreaWidget::SetCharacterSpacingOffset(float offset) { - m_drawer.SetDefaultCharacterSpacingOffset(offset); + m_drawer.SetCharacterSpacingOffset(offset); } inline void RichTextAreaWidget::SetLineSpacingOffset(float offset) { - m_drawer.SetDefaultLineSpacingOffset(offset); + m_drawer.SetLineSpacingOffset(offset); } inline void RichTextAreaWidget::SetTextColor(const Color& color) { - m_drawer.SetDefaultColor(color); + m_drawer.SetTextColor(color); } inline void RichTextAreaWidget::SetTextFont(std::shared_ptr font) { - m_drawer.SetDefaultFont(std::move(font)); + m_drawer.SetTextFont(std::move(font)); } inline void RichTextAreaWidget::SetTextOutlineColor(const Color& color) { - m_drawer.SetDefaultOutlineColor(color); + m_drawer.SetTextOutlineColor(color); } inline void RichTextAreaWidget::SetTextOutlineThickness(float thickness) { - m_drawer.SetDefaultOutlineThickness(thickness); + m_drawer.SetTextOutlineThickness(thickness); } inline void RichTextAreaWidget::SetTextStyle(TextStyleFlags style) { - m_drawer.SetDefaultStyle(style); + m_drawer.SetTextStyle(style); } } diff --git a/include/Nazara/Widgets/TextAreaWidget.hpp b/include/Nazara/Widgets/TextAreaWidget.hpp index 902afbf2e..bd3cfb205 100644 --- a/include/Nazara/Widgets/TextAreaWidget.hpp +++ b/include/Nazara/Widgets/TextAreaWidget.hpp @@ -20,7 +20,7 @@ namespace Nz TextAreaWidget(TextAreaWidget&&) = delete; ~TextAreaWidget() = default; - void AppendText(const std::string& text); + void AppendText(std::string_view text); void Clear() override; @@ -49,7 +49,7 @@ namespace Nz inline void SetTextStyle(TextStyleFlags style); using AbstractTextAreaWidget::Write; - void Write(const std::string& text, std::size_t glyphPosition) override; + void Write(std::string_view text, std::size_t glyphPosition) override; TextAreaWidget& operator=(const TextAreaWidget&) = delete; TextAreaWidget& operator=(TextAreaWidget&&) = delete; diff --git a/include/Nazara/Widgets/TextAreaWidget.inl b/include/Nazara/Widgets/TextAreaWidget.inl index 250d4075e..92aa9ab30 100644 --- a/include/Nazara/Widgets/TextAreaWidget.inl +++ b/include/Nazara/Widgets/TextAreaWidget.inl @@ -33,27 +33,27 @@ namespace Nz inline const Color& TextAreaWidget::GetTextColor() const { - return m_drawer.GetColor(); + return m_drawer.GetTextColor(); } inline const std::shared_ptr& TextAreaWidget::GetTextFont() const { - return m_drawer.GetFont(); + return m_drawer.GetTextFont(); } inline const Color& TextAreaWidget::GetTextOulineColor() const { - return m_drawer.GetOutlineColor(); + return m_drawer.GetTextOutlineColor(); } inline float TextAreaWidget::GetTextOulineThickness() const { - return m_drawer.GetOutlineThickness(); + return m_drawer.GetTextOutlineThickness(); } inline TextStyleFlags TextAreaWidget::GetTextStyle() const { - return m_drawer.GetStyle(); + return m_drawer.GetTextStyle(); } inline void TextAreaWidget::SetCharacterSize(unsigned int characterSize) @@ -89,35 +89,35 @@ namespace Nz inline void TextAreaWidget::SetTextColor(const Color& text) { - m_drawer.SetColor(text); + m_drawer.SetTextColor(text); UpdateDisplayText(); } inline void TextAreaWidget::SetTextFont(std::shared_ptr font) { - m_drawer.SetFont(std::move(font)); + m_drawer.SetTextFont(std::move(font)); UpdateDisplayText(); } inline void TextAreaWidget::SetTextOutlineColor(const Color& color) { - m_drawer.SetOutlineColor(color); + m_drawer.SetTextOutlineColor(color); UpdateDisplayText(); } inline void TextAreaWidget::SetTextOutlineThickness(float thickness) { - m_drawer.SetOutlineThickness(thickness); + m_drawer.SetTextOutlineThickness(thickness); UpdateDisplayText(); } inline void TextAreaWidget::SetTextStyle(TextStyleFlags style) { - m_drawer.SetStyle(style); + m_drawer.SetTextStyle(style); UpdateDisplayText(); } diff --git a/src/Nazara/Utility/RichTextDrawer.cpp b/src/Nazara/Utility/RichTextDrawer.cpp index 87f6ef6df..3022abc5c 100644 --- a/src/Nazara/Utility/RichTextDrawer.cpp +++ b/src/Nazara/Utility/RichTextDrawer.cpp @@ -10,31 +10,31 @@ namespace Nz { RichTextDrawer::RichTextDrawer() : - m_defaultColor(Color::White()), - m_defaultOutlineColor(Color::Black()), - m_defaultStyle(TextStyle_Regular), + m_currentColor(Color::White()), + m_currentOutlineColor(Color::Black()), + m_currentStyle(TextStyle_Regular), m_glyphUpdated(false), - m_defaultCharacterSpacingOffset(0.f), - m_defaultLineSpacingOffset(0.f), - m_defaultOutlineThickness(0.f), + m_currentCharacterSpacingOffset(0.f), + m_currentLineSpacingOffset(0.f), + m_currentOutlineThickness(0.f), m_maxLineWidth(std::numeric_limits::infinity()), - m_defaultCharacterSize(24) + m_currentCharacterSize(24) { - SetDefaultFont(Font::GetDefault()); + SetTextFont(Font::GetDefault()); } RichTextDrawer::RichTextDrawer(const RichTextDrawer& drawer) : - m_defaultColor(drawer.m_defaultColor), - m_defaultOutlineColor(drawer.m_defaultOutlineColor), - m_defaultStyle(drawer.m_defaultStyle), + m_currentColor(drawer.m_currentColor), + m_currentOutlineColor(drawer.m_currentOutlineColor), + m_currentStyle(drawer.m_currentStyle), m_fontIndexes(drawer.m_fontIndexes), m_blocks(drawer.m_blocks), m_glyphUpdated(false), - m_defaultCharacterSpacingOffset(drawer.m_defaultCharacterSpacingOffset), - m_defaultLineSpacingOffset(drawer.m_defaultLineSpacingOffset), - m_defaultOutlineThickness(drawer.m_defaultOutlineThickness), + m_currentCharacterSpacingOffset(drawer.m_currentCharacterSpacingOffset), + m_currentLineSpacingOffset(drawer.m_currentLineSpacingOffset), + m_currentOutlineThickness(drawer.m_currentOutlineThickness), m_maxLineWidth(drawer.m_maxLineWidth), - m_defaultCharacterSize(drawer.m_defaultCharacterSize) + m_currentCharacterSize(drawer.m_currentCharacterSize) { m_fonts.resize(drawer.m_fonts.size()); for (std::size_t i = 0; i < m_fonts.size(); ++i) @@ -43,38 +43,38 @@ namespace Nz m_fonts[i].useCount = drawer.m_fonts[i].useCount; } - SetDefaultFont(drawer.m_defaultFont); + SetTextFont(drawer.m_currentFont); ConnectFontSlots(); } - RichTextDrawer::RichTextDrawer(RichTextDrawer&& drawer) + RichTextDrawer::RichTextDrawer(RichTextDrawer&& drawer) noexcept { operator=(std::move(drawer)); } RichTextDrawer::~RichTextDrawer() = default; - auto RichTextDrawer::AppendText(const std::string& str, bool forceNewBlock) -> BlockRef + auto RichTextDrawer::AppendText(std::string_view str, bool forceNewBlock) -> BlockRef { NazaraAssert(!str.empty(), "String cannot be empty"); - std::size_t defaultFontIndex = HandleFontAddition(m_defaultFont); + std::size_t currentFontIndex = HandleFontAddition(m_currentFont); - auto HasDefaultProperties = [&](const Block& block) + auto DoPropertiesMatch = [&](const Block& block) { - return block.characterSize == m_defaultCharacterSize && - block.color == m_defaultColor && - block.fontIndex == defaultFontIndex && - block.characterSpacingOffset == m_defaultCharacterSpacingOffset && - block.lineSpacingOffset == m_defaultLineSpacingOffset && - block.outlineColor == m_defaultOutlineColor && - block.outlineThickness == m_defaultOutlineThickness && - block.style == m_defaultStyle; + return block.characterSize == m_currentCharacterSize && + block.color == m_currentColor && + block.fontIndex == currentFontIndex && + block.characterSpacingOffset == m_currentCharacterSpacingOffset && + block.lineSpacingOffset == m_currentLineSpacingOffset && + block.outlineColor == m_currentOutlineColor && + block.outlineThickness == m_currentOutlineThickness && + block.style == m_currentStyle; }; - // Check if last block has the same property as default, else create a new block - if (forceNewBlock || m_blocks.empty() || !HasDefaultProperties(m_blocks.back())) + // Check if last block has the same properties as previous block, else create a new block + if (forceNewBlock || m_blocks.empty() || !DoPropertiesMatch(m_blocks.back())) { std::size_t glyphIndex; if (!m_blocks.empty()) @@ -87,15 +87,15 @@ namespace Nz m_blocks.emplace_back(); Block& newBlock = m_blocks.back(); - newBlock.characterSize = m_defaultCharacterSize; - newBlock.characterSpacingOffset = m_defaultCharacterSpacingOffset; - newBlock.color = m_defaultColor; - newBlock.fontIndex = defaultFontIndex; + newBlock.characterSize = m_currentCharacterSize; + newBlock.characterSpacingOffset = m_currentCharacterSpacingOffset; + newBlock.color = m_currentColor; + newBlock.fontIndex = currentFontIndex; newBlock.glyphIndex = glyphIndex; - newBlock.lineSpacingOffset = m_defaultLineSpacingOffset; - newBlock.outlineColor = m_defaultOutlineColor; - newBlock.outlineThickness = m_defaultOutlineThickness; - newBlock.style = m_defaultStyle; + newBlock.lineSpacingOffset = m_currentLineSpacingOffset; + newBlock.outlineColor = m_currentOutlineColor; + newBlock.outlineThickness = m_currentOutlineThickness; + newBlock.style = m_currentStyle; newBlock.text = str; assert(newBlock.fontIndex < m_fonts.size()); @@ -235,14 +235,14 @@ namespace Nz DisconnectFontSlots(); m_blocks = drawer.m_blocks; - m_defaultCharacterSize = drawer.m_defaultCharacterSize; - m_defaultCharacterSpacingOffset = drawer.m_defaultCharacterSpacingOffset; - m_defaultColor = drawer.m_defaultColor; - m_defaultFont = drawer.m_defaultFont; - m_defaultLineSpacingOffset = drawer.m_defaultLineSpacingOffset; - m_defaultOutlineColor = drawer.m_defaultOutlineColor; - m_defaultOutlineThickness = drawer.m_defaultOutlineThickness; - m_defaultStyle = drawer.m_defaultStyle; + m_currentCharacterSize = drawer.m_currentCharacterSize; + m_currentCharacterSpacingOffset = drawer.m_currentCharacterSpacingOffset; + m_currentColor = drawer.m_currentColor; + m_currentFont = drawer.m_currentFont; + m_currentLineSpacingOffset = drawer.m_currentLineSpacingOffset; + m_currentOutlineColor = drawer.m_currentOutlineColor; + m_currentOutlineThickness = drawer.m_currentOutlineThickness; + m_currentStyle = drawer.m_currentStyle; m_fontIndexes = drawer.m_fontIndexes; m_fonts.resize(drawer.m_fonts.size()); @@ -258,20 +258,20 @@ namespace Nz return *this; } - RichTextDrawer& RichTextDrawer::operator=(RichTextDrawer&& drawer) + RichTextDrawer& RichTextDrawer::operator=(RichTextDrawer&& drawer) noexcept { DisconnectFontSlots(); m_blocks = std::move(drawer.m_blocks); m_bounds = std::move(drawer.m_bounds); - m_defaultCharacterSize = std::move(drawer.m_defaultCharacterSize); - m_defaultCharacterSpacingOffset = std::move(drawer.m_defaultCharacterSpacingOffset); - m_defaultColor = std::move(drawer.m_defaultColor); - m_defaultFont = std::move(drawer.m_defaultFont); - m_defaultLineSpacingOffset = std::move(drawer.m_defaultLineSpacingOffset); - m_defaultOutlineColor = std::move(drawer.m_defaultOutlineColor); - m_defaultOutlineThickness = std::move(drawer.m_defaultOutlineThickness); - m_defaultStyle = std::move(drawer.m_defaultStyle); + m_currentCharacterSize = std::move(drawer.m_currentCharacterSize); + m_currentCharacterSpacingOffset = std::move(drawer.m_currentCharacterSpacingOffset); + m_currentColor = std::move(drawer.m_currentColor); + m_currentFont = std::move(drawer.m_currentFont); + m_currentLineSpacingOffset = std::move(drawer.m_currentLineSpacingOffset); + m_currentOutlineColor = std::move(drawer.m_currentOutlineColor); + m_currentOutlineThickness = std::move(drawer.m_currentOutlineThickness); + m_currentStyle = std::move(drawer.m_currentStyle); m_drawPos = std::move(drawer.m_drawPos); m_fontIndexes = std::move(drawer.m_fontIndexes); m_fonts = std::move(drawer.m_fonts); @@ -545,7 +545,7 @@ namespace Nz } #endif - //SetFont(nullptr); + //SetTextFont(nullptr); } void RichTextDrawer::UpdateGlyphs() const diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 0adeeea78..0b2d30297 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -23,12 +23,10 @@ namespace Nz return m_bounds; } - const std::shared_ptr& SimpleTextDrawer::GetFont(std::size_t index) const + const std::shared_ptr& SimpleTextDrawer::GetFont([[maybe_unused]] std::size_t index) const { - NazaraAssert(index == 0, "Font index out of range"); - NazaraUnused(index); - - return GetFont(); + NazaraAssert(index == 0, "font index out of range"); + return GetTextFont(); } std::size_t SimpleTextDrawer::GetFontCount() const @@ -333,6 +331,6 @@ namespace Nz } #endif - SetFont(nullptr); + SetTextFont(nullptr); } } diff --git a/src/Nazara/Widgets/RichTextAreaWidget.cpp b/src/Nazara/Widgets/RichTextAreaWidget.cpp index 3736b1521..4b7bbc594 100644 --- a/src/Nazara/Widgets/RichTextAreaWidget.cpp +++ b/src/Nazara/Widgets/RichTextAreaWidget.cpp @@ -13,7 +13,7 @@ namespace Nz Layout(); } - void RichTextAreaWidget::AppendText(const std::string& text) + void RichTextAreaWidget::AppendText(std::string_view text) { //m_text += text; switch (m_echoMode) @@ -132,7 +132,7 @@ namespace Nz UpdateDisplayText(); } - void RichTextAreaWidget::Write(const std::string& text, std::size_t glyphPosition) + void RichTextAreaWidget::Write(std::string_view text, std::size_t glyphPosition) { if (m_drawer.HasBlocks()) { diff --git a/src/Nazara/Widgets/TextAreaWidget.cpp b/src/Nazara/Widgets/TextAreaWidget.cpp index d3a2a3f30..94a49d5eb 100644 --- a/src/Nazara/Widgets/TextAreaWidget.cpp +++ b/src/Nazara/Widgets/TextAreaWidget.cpp @@ -39,7 +39,7 @@ namespace Nz Layout(); } - void TextAreaWidget::AppendText(const std::string& text) + void TextAreaWidget::AppendText(std::string_view text) { m_text += text; @@ -113,7 +113,7 @@ namespace Nz SetText(newText); } - void TextAreaWidget::Write(const std::string& text, std::size_t glyphPosition) + void TextAreaWidget::Write(std::string_view text, std::size_t glyphPosition) { if (glyphPosition >= m_drawer.GetGlyphCount()) { diff --git a/tests/PresentModeTest/main.cpp b/tests/PresentModeTest/main.cpp index 0a63994fc..da1061c23 100644 --- a/tests/PresentModeTest/main.cpp +++ b/tests/PresentModeTest/main.cpp @@ -53,9 +53,9 @@ int main() auto UpdatePresentModeText = [&] { Nz::RichTextDrawer textDrawer; - textDrawer.SetDefaultStyle(Nz::TextStyle::Bold); + textDrawer.SetTextStyle(Nz::TextStyle::Bold); textDrawer.AppendText("Supported present modes:\n"); - textDrawer.SetDefaultStyle(Nz::TextStyle_Regular); + textDrawer.SetTextStyle(Nz::TextStyle_Regular); textDrawer.AppendText("Use +/- to switch present mode (and * to limit FPS to 50)\n"); for (Nz::PresentMode presentMode : supportedPresentModes) @@ -63,9 +63,9 @@ int main() textDrawer.AppendText("- "); if (presentMode == swapchain.GetPresentMode()) - textDrawer.SetDefaultColor(Nz::Color::Yellow()); + textDrawer.SetTextColor(Nz::Color::Yellow()); else - textDrawer.SetDefaultColor(Nz::Color::White()); + textDrawer.SetTextColor(Nz::Color::White()); switch (presentMode) { @@ -76,11 +76,11 @@ int main() } } - textDrawer.SetDefaultColor(Nz::Color::White()); + textDrawer.SetTextColor(Nz::Color::White()); textDrawer.AppendText("Use * to limit FPS to 50\n"); if (limitFps) { - textDrawer.SetDefaultColor(Nz::Color::Red()); + textDrawer.SetTextColor(Nz::Color::Red()); textDrawer.AppendText("FPS limited to 50\n"); } else