class EE::Graphics::RichText¶
Overview¶
A drawable class that renders rich text with multiple styles and spans. More…
#include <richtext.hpp> class RichText: public EE::Graphics::Drawable { public: // enums enum BlockType; // structs struct Block; struct RenderParagraph; struct RenderSpan; // construction ~RichText(); // methods static RichText* New(); void addSpan(const String& text, const FontStyleConfig& style); void addSpan(const String& text, Font* font = nullptr, Uint32 characterSize = 0, Color color = Color::White, Uint32 style = Text::Regular); void clear(); void setFontStyleConfig(const FontStyleConfig& styleConfig); FontStyleConfig& getFontStyleConfig(); void setAlign(Uint32 align); Uint32 getAlign() const; void setMaxWidth(Float width); Float getMaxWidth() const; void addDrawable(std::shared_ptr<Drawable> drawable); void addCustomSize(const Sizef& size); const std::vector<Block>& getBlocks(); virtual void draw( const Float& X, const Float& Y, const Vector2f& scale = Vector2f::One, const Float& rotation = 0, BlendMode effect = BlendMode::Alpha(), const OriginPoint& rotationCenter = OriginPoint::OriginCenter, const OriginPoint& scaleCenter = OriginPoint::OriginCenter ); virtual void draw(); virtual void draw(const Vector2f& position); virtual void draw(const Vector2f& position, const Sizef& size); virtual bool isStateful(); virtual Sizef getSize(); virtual Sizef getPixelsSize(); void invalidate(); const std::vector<RenderParagraph>& getLines() const; };
Inherited Members¶
public: // enums enum Type; // methods virtual Sizef getSize() = 0; virtual Sizef getPixelsSize() = 0; virtual void draw() = 0; virtual void draw(const Vector2f& position) = 0; virtual void draw(const Vector2f& position, const Sizef& size) = 0; virtual bool isStateful() = 0; void setAlpha(Uint8 alpha); const Uint8& getAlpha(); void setColor(const Color& color); const Color& getColor() const; void setColorFilter(const Color& color); RGB getColorFilter(); void clearColor(); void clearColorFilter(); void resetAlpha(); Type getDrawableType() const; const Vector2f& getPosition() const; void setPosition(const Vector2f& position); virtual bool isDrawableResource() const;
Detailed Documentation¶
A drawable class that renders rich text with multiple styles and spans.
RichText allows rendering text with different fonts, sizes, colors, and styles mixed together. It supports word wrapping and alignment.
Construction¶
~RichText()
Destructor.
Methods¶
static RichText* New()
Returns:
A new instance of RichText.
void addSpan(const String& text, const FontStyleConfig& style)
Adds a text span with a specific style configuration.
Parameters:
text |
The text content. |
style |
The font style configuration to apply. |
void addSpan(const String& text, Font* font = nullptr, Uint32 characterSize = 0, Color color = Color::White, Uint32 style = Text::Regular)
Adds a text span with individual style parameters.
Parameters:
text |
The text content. |
font |
The font to use (optional, uses default if null). |
characterSize |
The character size (optional, uses default if 0). |
color |
The text color (optional, uses default if White). |
style |
The text style (optional, uses default if Regular). |
void clear()
Clears all text spans.
void setFontStyleConfig(const FontStyleConfig& styleConfig)
Sets the default font style configuration used for new spans if not specified.
FontStyleConfig& getFontStyleConfig()
Returns:
The default font style configuration.
void setAlign(Uint32 align)
Sets the text alignment (Left, Center, Right).
Uint32 getAlign() const
Returns:
The text alignment.
void setMaxWidth(Float width)
Sets the maximum width for wrapping. If 0, wrapping is disabled.
Float getMaxWidth() const
Returns:
The maximum width for wrapping.
void addDrawable(std::shared_ptr<Drawable> drawable)
Adds a drawable (e.g., an image) into the text flow.
Parameters:
drawable |
The drawable to add. |
void addCustomSize(const Sizef& size)
Adds a custom size spacer into the text flow.
Parameters:
size |
The physical dimensions of the spacer. |
const std::vector<Block>& getBlocks()
Returns:
The list of blocks.
void invalidate()
Invalidates the layout, forcing a recalculation on the next update.
const std::vector<RenderParagraph>& getLines() const
Returns:
The list of rendered lines.