diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Text.hpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/include/Text.hpp b/include/Text.hpp index d34fd47..0244ba1 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -46,6 +46,13 @@ namespace QuickMedia //bool ownLine; // Currently only used for emoji, to make emoji bigger when it's the only thing on a line bool is_japanese; }; + + struct VertexRef { + int vertices_index; // index to |vertices| VertexArray + int index; // index within vertices[vertices_index] + int line; + sf::Uint32 codepoint; + }; class Text { @@ -94,14 +101,9 @@ namespace QuickMedia UP, DOWN, HOME, - END - }; - - struct VertexRef { - int vertices_index; // index to |vertices| VertexArray - int index; // index within vertices[vertices_index] - int line; - sf::Uint32 codepoint; + END, + LEFT, + RIGHT }; void updateCaret(); @@ -115,6 +117,11 @@ namespace QuickMedia float get_text_quad_left_side(const VertexRef &vertex_ref) const; float get_text_quad_right_side(const VertexRef &vertex_ref) const; + // If the index is past the end, then the caret offset is the right side of the last character, rather than the left side + float get_caret_offset_by_caret_index(int index) const; + VertexRef& get_vertex_ref_clamp(int index); + // Takes into consideration if index is the last vertex and the last vertex is a newline, then it should be on its own line + int get_vertex_line(int index) const; private: sf::String str; // TODO: Remove this for non-editable text??? const sf::Font *font; @@ -138,6 +145,7 @@ namespace QuickMedia std::vector<TextElement> textElements; int caretIndex; + float caret_offset_x; sf::Vector2f caretPosition; sf::Clock lastSeenTimer; sf::Vector2u renderTargetSize; |