|
@@ -1800,13 +1800,13 @@ void RichTextLabel::_notification(int p_what) {
|
|
|
|
|
|
case NOTIFICATION_RESIZED: {
|
|
case NOTIFICATION_RESIZED: {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
- main->first_resized_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_resized_line.store(0); // Invalidate all lines.
|
|
queue_redraw();
|
|
queue_redraw();
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
- main->first_invalid_font_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_font_line.store(0); // Invalidate all lines.
|
|
queue_redraw();
|
|
queue_redraw();
|
|
} break;
|
|
} break;
|
|
|
|
|
|
@@ -1816,7 +1816,7 @@ void RichTextLabel::_notification(int p_what) {
|
|
set_text(text);
|
|
set_text(text);
|
|
}
|
|
}
|
|
|
|
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
queue_redraw();
|
|
queue_redraw();
|
|
} break;
|
|
} break;
|
|
|
|
|
|
@@ -2528,7 +2528,7 @@ PackedFloat32Array RichTextLabel::_find_tab_stops(Item *p_item) {
|
|
item = item->parent;
|
|
item = item->parent;
|
|
}
|
|
}
|
|
|
|
|
|
- return PackedFloat32Array();
|
|
|
|
|
|
+ return default_tab_stops;
|
|
}
|
|
}
|
|
|
|
|
|
HorizontalAlignment RichTextLabel::_find_alignment(Item *p_item) {
|
|
HorizontalAlignment RichTextLabel::_find_alignment(Item *p_item) {
|
|
@@ -4444,19 +4444,19 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|
add_text(String::chr(0x00AD));
|
|
add_text(String::chr(0x00AD));
|
|
pos = brk_end + 1;
|
|
pos = brk_end + 1;
|
|
} else if (tag == "center") {
|
|
} else if (tag == "center") {
|
|
- push_paragraph(HORIZONTAL_ALIGNMENT_CENTER);
|
|
|
|
|
|
+ push_paragraph(HORIZONTAL_ALIGNMENT_CENTER, text_direction, language, st_parser, default_jst_flags, default_tab_stops);
|
|
pos = brk_end + 1;
|
|
pos = brk_end + 1;
|
|
tag_stack.push_front(tag);
|
|
tag_stack.push_front(tag);
|
|
} else if (tag == "fill") {
|
|
} else if (tag == "fill") {
|
|
- push_paragraph(HORIZONTAL_ALIGNMENT_FILL);
|
|
|
|
|
|
+ push_paragraph(HORIZONTAL_ALIGNMENT_FILL, text_direction, language, st_parser, default_jst_flags, default_tab_stops);
|
|
pos = brk_end + 1;
|
|
pos = brk_end + 1;
|
|
tag_stack.push_front(tag);
|
|
tag_stack.push_front(tag);
|
|
} else if (tag == "left") {
|
|
} else if (tag == "left") {
|
|
- push_paragraph(HORIZONTAL_ALIGNMENT_LEFT);
|
|
|
|
|
|
+ push_paragraph(HORIZONTAL_ALIGNMENT_LEFT, text_direction, language, st_parser, default_jst_flags, default_tab_stops);
|
|
pos = brk_end + 1;
|
|
pos = brk_end + 1;
|
|
tag_stack.push_front(tag);
|
|
tag_stack.push_front(tag);
|
|
} else if (tag == "right") {
|
|
} else if (tag == "right") {
|
|
- push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT);
|
|
|
|
|
|
+ push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT, text_direction, language, st_parser, default_jst_flags, default_tab_stops);
|
|
pos = brk_end + 1;
|
|
pos = brk_end + 1;
|
|
tag_stack.push_front(tag);
|
|
tag_stack.push_front(tag);
|
|
} else if (tag == "ul") {
|
|
} else if (tag == "ul") {
|
|
@@ -4515,8 +4515,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|
|
|
|
|
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
|
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
|
Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED;
|
|
Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED;
|
|
- String lang;
|
|
|
|
- PackedFloat32Array tab_stops;
|
|
|
|
|
|
+ String lang = language;
|
|
|
|
+ PackedFloat32Array tab_stops = default_tab_stops;
|
|
TextServer::StructuredTextParser st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT;
|
|
TextServer::StructuredTextParser st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT;
|
|
BitField<TextServer::JustificationFlag> jst_flags = default_jst_flags;
|
|
BitField<TextServer::JustificationFlag> jst_flags = default_jst_flags;
|
|
for (int i = 0; i < subtag.size(); i++) {
|
|
for (int i = 0; i < subtag.size(); i++) {
|
|
@@ -5734,19 +5734,89 @@ void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction)
|
|
|
|
|
|
if (text_direction != p_text_direction) {
|
|
if (text_direction != p_text_direction) {
|
|
text_direction = p_text_direction;
|
|
text_direction = p_text_direction;
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
- _validate_line_caches();
|
|
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
|
|
+ queue_redraw();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Control::TextDirection RichTextLabel::get_text_direction() const {
|
|
|
|
+ return text_direction;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void RichTextLabel::set_horizontal_alignment(HorizontalAlignment p_alignment) {
|
|
|
|
+ ERR_FAIL_INDEX((int)p_alignment, 4);
|
|
|
|
+ _stop_thread();
|
|
|
|
+
|
|
|
|
+ if (default_alignment != p_alignment) {
|
|
|
|
+ default_alignment = p_alignment;
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
|
|
+ queue_redraw();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+HorizontalAlignment RichTextLabel::get_horizontal_alignment() const {
|
|
|
|
+ return default_alignment;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void RichTextLabel::set_justification_flags(BitField<TextServer::JustificationFlag> p_flags) {
|
|
|
|
+ _stop_thread();
|
|
|
|
+
|
|
|
|
+ if (default_jst_flags != p_flags) {
|
|
|
|
+ default_jst_flags = p_flags;
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+BitField<TextServer::JustificationFlag> RichTextLabel::get_justification_flags() const {
|
|
|
|
+ return default_jst_flags;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void RichTextLabel::set_tab_stops(const PackedFloat32Array &p_tab_stops) {
|
|
|
|
+ _stop_thread();
|
|
|
|
+
|
|
|
|
+ if (default_tab_stops != p_tab_stops) {
|
|
|
|
+ default_tab_stops = p_tab_stops;
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
|
|
+ queue_redraw();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+PackedFloat32Array RichTextLabel::get_tab_stops() const {
|
|
|
|
+ return default_tab_stops;
|
|
|
|
+}
|
|
|
|
+
|
|
void RichTextLabel::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
|
void RichTextLabel::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
|
if (st_parser != p_parser) {
|
|
if (st_parser != p_parser) {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
|
|
|
|
st_parser = p_parser;
|
|
st_parser = p_parser;
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
- _validate_line_caches();
|
|
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5760,7 +5830,7 @@ void RichTextLabel::set_structured_text_bidi_override_options(Array p_args) {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
|
|
|
|
st_args = p_args;
|
|
st_args = p_args;
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
_validate_line_caches();
|
|
_validate_line_caches();
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
@@ -5770,17 +5840,17 @@ Array RichTextLabel::get_structured_text_bidi_override_options() const {
|
|
return st_args;
|
|
return st_args;
|
|
}
|
|
}
|
|
|
|
|
|
-Control::TextDirection RichTextLabel::get_text_direction() const {
|
|
|
|
- return text_direction;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void RichTextLabel::set_language(const String &p_language) {
|
|
void RichTextLabel::set_language(const String &p_language) {
|
|
if (language != p_language) {
|
|
if (language != p_language) {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
|
|
|
|
language = p_language;
|
|
language = p_language;
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
- _validate_line_caches();
|
|
|
|
|
|
+ if (!text.is_empty()) {
|
|
|
|
+ _apply_translation();
|
|
|
|
+ } else {
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
|
|
+ _validate_line_caches();
|
|
|
|
+ }
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5794,7 +5864,7 @@ void RichTextLabel::set_autowrap_mode(TextServer::AutowrapMode p_mode) {
|
|
_stop_thread();
|
|
_stop_thread();
|
|
|
|
|
|
autowrap_mode = p_mode;
|
|
autowrap_mode = p_mode;
|
|
- main->first_invalid_line = 0; //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_line = 0; // Invalidate all lines.
|
|
_validate_line_caches();
|
|
_validate_line_caches();
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
@@ -5820,7 +5890,7 @@ void RichTextLabel::set_visible_ratio(float p_ratio) {
|
|
}
|
|
}
|
|
|
|
|
|
if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
|
|
if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
|
|
- main->first_invalid_line.store(0); // Invalidate ALL.
|
|
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines..
|
|
_validate_line_caches();
|
|
_validate_line_caches();
|
|
}
|
|
}
|
|
queue_redraw();
|
|
queue_redraw();
|
|
@@ -5948,6 +6018,13 @@ void RichTextLabel::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("set_language", "language"), &RichTextLabel::set_language);
|
|
ClassDB::bind_method(D_METHOD("set_language", "language"), &RichTextLabel::set_language);
|
|
ClassDB::bind_method(D_METHOD("get_language"), &RichTextLabel::get_language);
|
|
ClassDB::bind_method(D_METHOD("get_language"), &RichTextLabel::get_language);
|
|
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_horizontal_alignment", "alignment"), &RichTextLabel::set_horizontal_alignment);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("get_horizontal_alignment"), &RichTextLabel::get_horizontal_alignment);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_justification_flags", "justification_flags"), &RichTextLabel::set_justification_flags);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("get_justification_flags"), &RichTextLabel::get_justification_flags);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_tab_stops", "tab_stops"), &RichTextLabel::set_tab_stops);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("get_tab_stops"), &RichTextLabel::get_tab_stops);
|
|
|
|
+
|
|
ClassDB::bind_method(D_METHOD("set_autowrap_mode", "autowrap_mode"), &RichTextLabel::set_autowrap_mode);
|
|
ClassDB::bind_method(D_METHOD("set_autowrap_mode", "autowrap_mode"), &RichTextLabel::set_autowrap_mode);
|
|
ClassDB::bind_method(D_METHOD("get_autowrap_mode"), &RichTextLabel::get_autowrap_mode);
|
|
ClassDB::bind_method(D_METHOD("get_autowrap_mode"), &RichTextLabel::get_autowrap_mode);
|
|
|
|
|
|
@@ -6068,6 +6145,10 @@ void RichTextLabel::_bind_methods() {
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled");
|
|
|
|
|
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_horizontal_alignment", "get_horizontal_alignment");
|
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "justification_flags", PROPERTY_HINT_FLAGS, "Kashida Justification:1,Word Justification:2,Justify Only After Last Tab:8,Skip Last Line:32,Skip Last Line With Visible Characters:64,Do Not Skip Single Line:128"), "set_justification_flags", "get_justification_flags");
|
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "tab_stops"), "set_tab_stops", "get_tab_stops");
|
|
|
|
+
|
|
ADD_GROUP("Markup", "");
|
|
ADD_GROUP("Markup", "");
|
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "custom_effects", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("RichTextEffect"), (PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE)), "set_effects", "get_effects");
|
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "custom_effects", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("RichTextEffect"), (PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE)), "set_effects", "get_effects");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta_underlined"), "set_meta_underline", "is_meta_underlined");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta_underlined"), "set_meta_underline", "is_meta_underlined");
|
|
@@ -6170,7 +6251,7 @@ void RichTextLabel::set_visible_characters_behavior(TextServer::VisibleCharacter
|
|
_stop_thread();
|
|
_stop_thread();
|
|
|
|
|
|
visible_chars_behavior = p_behavior;
|
|
visible_chars_behavior = p_behavior;
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
_validate_line_caches();
|
|
_validate_line_caches();
|
|
queue_redraw();
|
|
queue_redraw();
|
|
}
|
|
}
|
|
@@ -6190,7 +6271,7 @@ void RichTextLabel::set_visible_characters(int p_visible) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
|
|
if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
|
|
- main->first_invalid_line.store(0); //invalidate ALL
|
|
|
|
|
|
+ main->first_invalid_line.store(0); // Invalidate all lines.
|
|
_validate_line_caches();
|
|
_validate_line_caches();
|
|
}
|
|
}
|
|
queue_redraw();
|
|
queue_redraw();
|