| #ifndef _RIVE_TEXT_STYLE_BACKGROUND_HPP_ |
| #define _RIVE_TEXT_STYLE_BACKGROUND_HPP_ |
| #include "rive/generated/text/text_style_background_base.hpp" |
| #include "rive/shapes/shape_paint_container.hpp" |
| #include "rive/text/text_selection_path.hpp" |
| #include <vector> |
| |
| namespace rive |
| { |
| class TextStylePaint; |
| |
| /// Paints a joined rounded rectangle behind the glyphs of every run using the |
| /// owning TextStylePaint. |
| class TextStyleBackground : public TextStyleBackgroundBase, |
| public ShapePaintContainer |
| { |
| public: |
| StatusCode onAddedDirty(CoreContext* context) override; |
| |
| void resetPath(); |
| void addRect(const AABB& rect); |
| void updatePath(); |
| void draw(Renderer* renderer, const Mat2D& worldTransform); |
| |
| // Implemented for ShapePaintContainer. |
| const Mat2D& shapeWorldTransform() const override; |
| Component* pathBuilder() override; |
| ShapePaintPath* localPath() override { return &m_path; } |
| ShapePaintPath* localClockwisePath() override { return &m_path; } |
| |
| protected: |
| void cornerRadiusChanged() override; |
| |
| private: |
| Artboard* getArtboard() override { return artboard(); } |
| TextStylePaint* style() const; |
| |
| std::vector<AABB> m_rects; |
| // Even-odd keeps rendering winding-agnostic so the Dart editor's |
| // un-normalized contours paint identically. |
| TextSelectionPath m_path{true, FillRule::evenOdd}; |
| }; |
| } // namespace rive |
| |
| #endif |