From edb3d9994287df3f91a166d3a415c113dd84a3b5 Mon Sep 17 00:00:00 2001 From: Micky Date: Thu, 4 Jul 2024 16:55:51 +0200 Subject: [PATCH] Add RichTextLabel `is_finished()`, deprecate `is_ready()` --- doc/classes/RichTextLabel.xml | 26 ++++++++++++++++---------- editor/editor_help.cpp | 6 +++--- editor/editor_log.cpp | 2 +- scene/gui/rich_text_label.cpp | 9 ++++++--- scene/gui/rich_text_label.h | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 24d2d26beb86..11820dabccee 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -70,7 +70,7 @@ Returns the line number of the character position provided. Line and character numbers are both zero-indexed. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. @@ -78,28 +78,28 @@ Returns the paragraph number of the character position provided. Paragraph and character numbers are both zero-indexed. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. Returns the height of the content. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. Returns the width of the content. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. Returns the total number of lines in the text. Wrapped text is counted as multiple lines. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. @@ -107,7 +107,7 @@ Returns the vertical offset of the line found at the provided index. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. @@ -167,7 +167,7 @@ Returns the vertical offset of the paragraph found at the provided index. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. @@ -211,14 +211,14 @@ Returns the number of visible lines. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. Returns the number of visible paragraphs. A paragraph is considered visible if at least one of its lines is visible. - [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_ready] or [signal finished] to determine whether document is fully loaded. + [b]Note:[/b] If [member threaded] is enabled, this method returns a value for the loaded part of the document. Use [method is_finished] or [signal finished] to determine whether document is fully loaded. @@ -256,13 +256,19 @@ Invalidates [param paragraph] and all subsequent paragraphs cache. + + + + If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code]. + + Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided). - + If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code]. diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 00ac1c7c6f30..332f25dd2d5b 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -288,7 +288,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { // Case order is important here to correctly handle edge cases like Variant.Type in @GlobalScope. if (table->has(link)) { // Found in the current page. - if (class_desc->is_ready()) { + if (class_desc->is_finished()) { emit_signal(SNAME("request_save_history")); class_desc->scroll_to_paragraph((*table)[link]); } else { @@ -2338,7 +2338,7 @@ void EditorHelp::_help_callback(const String &p_topic) { } } - if (class_desc->is_ready()) { + if (class_desc->is_finished()) { // call_deferred() is not enough. if (class_desc->is_connected(SceneStringName(draw), callable_mp(class_desc, &RichTextLabel::scroll_to_paragraph))) { class_desc->disconnect(SceneStringName(draw), callable_mp(class_desc, &RichTextLabel::scroll_to_paragraph)); @@ -3039,7 +3039,7 @@ Vector> EditorHelp::get_sections() { void EditorHelp::scroll_to_section(int p_section_index) { _wait_for_thread(); int line = section_line[p_section_index].second; - if (class_desc->is_ready()) { + if (class_desc->is_finished()) { class_desc->scroll_to_paragraph(line); } else { scroll_to = line; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 6a016c217a86..7f386a8a4cd2 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -398,7 +398,7 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { if (p_replace_previous) { // Force sync last line update (skip if number of unprocessed log messages is too large to avoid editor lag). if (log->get_pending_paragraphs() < 100) { - while (!log->is_ready()) { + while (!log->is_finished()) { ::OS::get_singleton()->delay_usec(1); } } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8ffa0f8c6316..b6082f2953d2 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1897,7 +1897,7 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_INTERNAL_PROCESS: { if (is_visible_in_tree()) { - if (!is_ready()) { + if (!is_finished()) { return; } double dt = get_process_delta_time(); @@ -2788,7 +2788,7 @@ int RichTextLabel::get_pending_paragraphs() const { return lines - to_line; } -bool RichTextLabel::is_ready() const { +bool RichTextLabel::is_finished() const { const_cast(this)->_validate_line_caches(); if (updating.load()) { @@ -5994,7 +5994,10 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text); - ClassDB::bind_method(D_METHOD("is_ready"), &RichTextLabel::is_ready); +#ifndef DISABLE_DEPRECATED + ClassDB::bind_method(D_METHOD("is_ready"), &RichTextLabel::is_finished); +#endif // DISABLE_DEPRECATED + ClassDB::bind_method(D_METHOD("is_finished"), &RichTextLabel::is_finished); ClassDB::bind_method(D_METHOD("set_threaded", "threaded"), &RichTextLabel::set_threaded); ClassDB::bind_method(D_METHOD("is_threaded"), &RichTextLabel::is_threaded); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 83285bd7cde5..9f81674454ac 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -785,7 +785,7 @@ class RichTextLabel : public Control { void deselect(); int get_pending_paragraphs() const; - bool is_ready() const; + bool is_finished() const; bool is_updating() const; void set_threaded(bool p_threaded);