diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-06-15 11:01:45 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-06-16 16:49:37 +0300 |
commit | b5c96df2771113cd9c5cb24b07b199a08a8ad917 (patch) | |
tree | 7dc5b5f47f3cefde77306c48619919060f576ea8 /scene/resources | |
parent | ef6511fbb4b280ca81f18f89d89be7a7b6c706ec (diff) |
Move duplicate AutoWrap, Overrun and VisibleChar behavior enums to the TextServer.
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/text_line.cpp | 26 | ||||
-rw-r--r-- | scene/resources/text_line.h | 17 | ||||
-rw-r--r-- | scene/resources/text_paragraph.cpp | 24 | ||||
-rw-r--r-- | scene/resources/text_paragraph.h | 17 |
4 files changed, 25 insertions, 59 deletions
diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp index f9390ca528..d6e7ca3478 100644 --- a/scene/resources/text_line.cpp +++ b/scene/resources/text_line.cpp @@ -98,12 +98,6 @@ void TextLine::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_outline", "canvas", "pos", "outline_size", "color"), &TextLine::draw_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("hit_test", "coords"), &TextLine::hit_test); - - BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_CHAR); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_ELLIPSIS); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS); } void TextLine::_shape() { @@ -112,26 +106,26 @@ void TextLine::_shape() { TS->shaped_text_tab_align(rid, tab_stops); } - uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIMMING; - if (overrun_behavior != OVERRUN_NO_TRIMMING) { + uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM; + if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { switch (overrun_behavior) { - case OVERRUN_TRIM_WORD_ELLIPSIS: + case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_ELLIPSIS: + case TextServer::OVERRUN_TRIM_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_WORD: + case TextServer::OVERRUN_TRIM_WORD: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; break; - case OVERRUN_TRIM_CHAR: + case TextServer::OVERRUN_TRIM_CHAR: overrun_flags |= TextServer::OVERRUN_TRIM; break; - case OVERRUN_NO_TRIMMING: + case TextServer::OVERRUN_NO_TRIMMING: break; } @@ -259,20 +253,20 @@ uint16_t TextLine::get_flags() const { return flags; } -void TextLine::set_text_overrun_behavior(TextLine::OverrunBehavior p_behavior) { +void TextLine::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { if (overrun_behavior != p_behavior) { overrun_behavior = p_behavior; dirty = true; } } -TextLine::OverrunBehavior TextLine::get_text_overrun_behavior() const { +TextServer::OverrunBehavior TextLine::get_text_overrun_behavior() const { return overrun_behavior; } void TextLine::set_width(float p_width) { width = p_width; - if (alignment == HORIZONTAL_ALIGNMENT_FILL || overrun_behavior != OVERRUN_NO_TRIMMING) { + if (alignment == HORIZONTAL_ALIGNMENT_FILL || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { dirty = true; } } diff --git a/scene/resources/text_line.h b/scene/resources/text_line.h index c5762db0f2..784ee8ef26 100644 --- a/scene/resources/text_line.h +++ b/scene/resources/text_line.h @@ -39,15 +39,6 @@ class TextLine : public RefCounted { GDCLASS(TextLine, RefCounted); -public: - enum OverrunBehavior { - OVERRUN_NO_TRIMMING, - OVERRUN_TRIM_CHAR, - OVERRUN_TRIM_WORD, - OVERRUN_TRIM_ELLIPSIS, - OVERRUN_TRIM_WORD_ELLIPSIS, - }; - private: RID rid; int spacing_top = 0; @@ -58,7 +49,7 @@ private: float width = -1.0; uint16_t flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA; HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; - OverrunBehavior overrun_behavior = OVERRUN_TRIM_ELLIPSIS; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_TRIM_ELLIPSIS; Vector<float> tab_stops; @@ -98,8 +89,8 @@ public: void set_flags(uint16_t p_flags); uint16_t get_flags() const; - void set_text_overrun_behavior(OverrunBehavior p_behavior); - OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_width(float p_width); float get_width() const; @@ -125,6 +116,4 @@ public: ~TextLine(); }; -VARIANT_ENUM_CAST(TextLine::OverrunBehavior); - #endif // TEXT_LINE_H diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index 477b41efaa..874992ea3d 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -129,12 +129,6 @@ void TextParagraph::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_dropcap_outline", "canvas", "pos", "outline_size", "color"), &TextParagraph::draw_dropcap_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("hit_test", "coords"), &TextParagraph::hit_test); - - BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_CHAR); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_ELLIPSIS); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS); } void TextParagraph::_shape_lines() { @@ -190,26 +184,26 @@ void TextParagraph::_shape_lines() { lines_rid.push_back(line); } - uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIMMING; - if (overrun_behavior != OVERRUN_NO_TRIMMING) { + uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM; + if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { switch (overrun_behavior) { - case OVERRUN_TRIM_WORD_ELLIPSIS: + case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_ELLIPSIS: + case TextServer::OVERRUN_TRIM_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_WORD: + case TextServer::OVERRUN_TRIM_WORD: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; break; - case OVERRUN_TRIM_CHAR: + case TextServer::OVERRUN_TRIM_CHAR: overrun_flags |= TextServer::OVERRUN_TRIM; break; - case OVERRUN_NO_TRIMMING: + case TextServer::OVERRUN_NO_TRIMMING: break; } } @@ -451,7 +445,7 @@ uint16_t TextParagraph::get_flags() const { return flags; } -void TextParagraph::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior) { +void TextParagraph::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { _THREAD_SAFE_METHOD_ if (overrun_behavior != p_behavior) { @@ -460,7 +454,7 @@ void TextParagraph::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_b } } -TextParagraph::OverrunBehavior TextParagraph::get_text_overrun_behavior() const { +TextServer::OverrunBehavior TextParagraph::get_text_overrun_behavior() const { return overrun_behavior; } diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h index 4f1aad16b5..bdcc2b5701 100644 --- a/scene/resources/text_paragraph.h +++ b/scene/resources/text_paragraph.h @@ -41,15 +41,6 @@ class TextParagraph : public RefCounted { GDCLASS(TextParagraph, RefCounted); _THREAD_SAFE_CLASS_ -public: - enum OverrunBehavior { - OVERRUN_NO_TRIMMING, - OVERRUN_TRIM_CHAR, - OVERRUN_TRIM_WORD, - OVERRUN_TRIM_ELLIPSIS, - OVERRUN_TRIM_WORD_ELLIPSIS, - }; - private: RID dropcap_rid; int dropcap_lines = 0; @@ -66,7 +57,7 @@ private: int max_lines_visible = -1; uint16_t flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA; - OverrunBehavior overrun_behavior = OVERRUN_NO_TRIMMING; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; @@ -116,8 +107,8 @@ public: void set_flags(uint16_t p_flags); uint16_t get_flags() const; - void set_text_overrun_behavior(OverrunBehavior p_behavior); - OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_width(float p_width); float get_width() const; @@ -165,6 +156,4 @@ public: ~TextParagraph(); }; -VARIANT_ENUM_CAST(TextParagraph::OverrunBehavior); - #endif // TEXT_PARAGRAPH_H |