5#ifndef MALENA_RICHTEXTRENDERER_H
6#define MALENA_RICHTEXTRENDERER_H
90 unsigned int defaultSize,
129 std::size_t selStart,
135 std::size_t charIndex,
137 float width = 2.f)
const;
150 [[nodiscard]]
const std::vector<RenderedLine>&
getLines()
const;
155 unsigned int _defaultSize;
159 float _maxWidth = 0.f;
160 std::vector<RenderedLine> _lines;
162 void buildSegments();
163 void computeListMarkers();
168 [[nodiscard]]
unsigned int emptyLineSize(std::size_t charStart)
const;
Pure data layer for rich text editing.
float getTotalHeight() const
sf::Vector2f charIndexToPosition(std::size_t index) const
void drawCursor(sf::RenderTarget &target, const sf::RenderStates &states, std::size_t charIndex, const sf::Color &color, float width=2.f) const
std::size_t charIndexAbove(std::size_t cursorIndex) const
std::size_t charIndexBelow(std::size_t cursorIndex) const
void draw(sf::RenderTarget &target, const sf::RenderStates &states) const
sf::Color getDefaultColor() const
The default (unstyled) text color.
const std::vector< RenderedLine > & getLines() const
void setMaxWidth(float width)
Set max line width for wrapping. 0 = no wrap.
std::size_t lineIndexForChar(std::size_t charIndex) const
void reflow()
Reposition existing sf::Text objects to the current origin.
std::size_t positionToCharIndex(const sf::Vector2f &pos) const
void rebuild()
Rebuild sf::Text objects from the current buffer content.
void setOrigin(const sf::Vector2f &origin)
Set the top-left origin and reposition segments.
RichTextRenderer(const RichTextBuffer &buffer, const sf::Font &defaultFont, unsigned int defaultSize, sf::Color defaultColor)
void drawSelection(sf::RenderTarget &target, const sf::RenderStates &states, std::size_t selStart, std::size_t selEnd, const sf::Color &color) const
Vector2< float > Vector2f
One visual line of text made up of RenderedSegment objects.
std::string marker
"•" or "N." (empty = none)
float height
Total height including word-wrap rows.
std::vector< RenderedSegment > segments
sf::Vector2f markerPos
where to draw the marker
int listType
0 none, 1 bullet, 2 numbered
float rowHeight
Single visual row height (for cursor/selection).
float indent
left hanging indent for list text
sf::Text sfText
SFML text object, positioned and styled.
sf::Vector2f position
Top-left position.
std::size_t bufEnd
Last char index in the buffer (exclusive).
std::size_t bufStart
First char index in the buffer (inclusive).
RenderedSegment(sf::Text &&text, std::size_t start, std::size_t end, sf::Vector2f pos)
A styled attribute range applied to a span of characters.