diff options
m--------- | depends/mglpp | 0 | ||||
-rw-r--r-- | include/Text.hpp | 5 | ||||
-rw-r--r-- | src/Text.cpp | 39 |
3 files changed, 41 insertions, 3 deletions
diff --git a/depends/mglpp b/depends/mglpp -Subproject 870f3ac7f31fd4056f95ebec1844a22ef64c747 +Subproject 3f8099b9b5c64e912a2ca227a9e3b2ce774f5ff diff --git a/include/Text.hpp b/include/Text.hpp index dc3a0f7..a8a17be 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -55,6 +55,8 @@ namespace QuickMedia { public: Text(std::string str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls = false); + Text(const Text &other); + Text& operator=(const Text&); void setString(std::string str); const std::string& getString() const; @@ -112,6 +114,7 @@ namespace QuickMedia RIGHT_WORD }; + Text(); void updateCaret(); int getStartOfLine(int startIndex) const; int getEndOfLine(int startIndex) const; @@ -135,7 +138,7 @@ namespace QuickMedia size_t get_string_index_from_caret_index(size_t caret_index) const; private: std::string str; // TODO: Remove this for non-editable text??? also replace with std::string? then we get more efficient editing of text - const bool bold_font; + bool bold_font; unsigned int characterSize; std::array<std::vector<mgl::Vertex>, 4> vertices; std::array<mgl::VertexBuffer, 4> vertex_buffers; diff --git a/src/Text.cpp b/src/Text.cpp index 18a87f4..39e5bc4 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -21,6 +21,26 @@ namespace QuickMedia static const size_t FONT_INDEX_SYMBOLS = 2; static const size_t FONT_INDEX_EMOJI = 3; static const size_t FONT_ARRAY_SIZE = 4; + + Text::Text() : + bold_font(false), + characterSize(12), + maxWidth(0.0f), + color(get_theme().text_color), + dirty(true), + dirtyText(true), + dirtyCaret(true), + editable(false), + highlight_urls(false), + caretMoveDirection(CaretMoveDirection::NONE), + num_lines(1), + lineSpacing(0.0f), + characterSpacing(0.0f), + caretIndex(0), + caret_offset_x(0.0f) + { + + } Text::Text(std::string _str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls) : bold_font(bold_font), @@ -28,8 +48,8 @@ namespace QuickMedia maxWidth(maxWidth), color(get_theme().text_color), dirty(true), - dirtyText(false), - dirtyCaret(false), + dirtyText(true), + dirtyCaret(true), editable(false), highlight_urls(highlight_urls), caretMoveDirection(CaretMoveDirection::NONE), @@ -41,6 +61,21 @@ namespace QuickMedia { setString(std::move(_str)); } + + Text::Text(const Text &other) : Text(other.str, other.bold_font, other.characterSize, other.maxWidth, other.highlight_urls) { + + } + + Text& Text::operator=(const Text &other) { + str = other.str; + bold_font = other.bold_font; + characterSize = other.characterSize; + maxWidth = other.maxWidth; + highlight_urls = other.highlight_urls; + caretIndex = other.caretIndex; + position = other.position; + return *this; + } void Text::setString(std::string str) { |