Skip to content

Commit

Permalink
Add RichTextLabel is_finished(), deprecate is_ready()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickeon committed Jul 4, 2024
1 parent e6448ca commit 6bbd53d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
26 changes: 16 additions & 10 deletions doc/classes/RichTextLabel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,44 +70,44 @@
<param index="0" name="character" type="int" />
<description>
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.
</description>
</method>
<method name="get_character_paragraph">
<return type="int" />
<param index="0" name="character" type="int" />
<description>
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.
</description>
</method>
<method name="get_content_height" qualifiers="const">
<return type="int" />
<description>
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.
</description>
</method>
<method name="get_content_width" qualifiers="const">
<return type="int" />
<description>
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.
</description>
</method>
<method name="get_line_count" qualifiers="const">
<return type="int" />
<description>
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.
</description>
</method>
<method name="get_line_offset">
<return type="float" />
<param index="0" name="line" type="int" />
<description>
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.
</description>
</method>
<method name="get_menu" qualifiers="const">
Expand Down Expand Up @@ -167,7 +167,7 @@
<param index="0" name="paragraph" type="int" />
<description>
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.
</description>
</method>
<method name="get_parsed_text" qualifiers="const">
Expand Down Expand Up @@ -211,14 +211,14 @@
<return type="int" />
<description>
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.
</description>
</method>
<method name="get_visible_paragraph_count" qualifiers="const">
<return type="int" />
<description>
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.
</description>
</method>
<method name="install_effect">
Expand Down Expand Up @@ -256,13 +256,19 @@
Invalidates [param paragraph] and all subsequent paragraphs cache.
</description>
</method>
<method name="is_finished" qualifiers="const">
<return type="bool" />
<description>
If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code].
</description>
</method>
<method name="is_menu_visible" qualifiers="const">
<return type="bool" />
<description>
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).
</description>
</method>
<method name="is_ready" qualifiers="const">
<method name="is_ready" qualifiers="const" deprecated="Use [method is_finished] instead.">
<return type="bool" />
<description>
If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code].
Expand Down
9 changes: 9 additions & 0 deletions scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,13 @@ int RichTextLabel::get_pending_paragraphs() const {
return lines - to_line;
}

#ifndef DISABLE_DEPRECATED
bool RichTextLabel::is_ready() const {
return is_finished();
}
#endif // DISABLE_DEPRECATED

bool RichTextLabel::is_finished() const {
const_cast<RichTextLabel *>(this)->_validate_line_caches();

if (updating.load()) {
Expand Down Expand Up @@ -5994,7 +6000,10 @@ void RichTextLabel::_bind_methods() {

ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);

#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("is_ready"), &RichTextLabel::is_ready);
#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);
Expand Down
3 changes: 3 additions & 0 deletions scene/gui/rich_text_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,10 @@ class RichTextLabel : public Control {
void deselect();

int get_pending_paragraphs() const;
#ifndef DISABLE_DEPRECATED
bool is_ready() const;
#endif // DISABLE_DEPRECATED
bool is_finished() const;
bool is_updating() const;

void set_threaded(bool p_threaded);
Expand Down

0 comments on commit 6bbd53d

Please sign in to comment.