summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorAlexander Pech <alexpech12@gmail.com>2021-01-02 21:46:44 +1100
committerAlexander Pech <alexpech12@gmail.com>2021-01-14 21:32:41 +1100
commit463e2002abc0ecd7439fbf00966cef83842babce (patch)
tree95569d030046e09ed54f61372678388b0f700097 /scene
parent7a16efc88596caa5e794d1eb52c599d706b2457c (diff)
Keep RichTextLabel visible character properties in sync
The RichTextLabel class is inconsistent in how it updates the visible_characters and percent_visible properties when either is changed. To keep both properties consistent, update percent_visible when setting the visible_characters property. For both properties, when setting one, notify change for the other. Docs updated for member set_visible_characters on RichTextLabel class.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/rich_text_label.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 4f4d5ece4a..8891c6ab49 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3716,6 +3716,7 @@ void RichTextLabel::set_percent_visible(float p_percent) {
}
main->first_invalid_line = 0; //invalidate ALL
_validate_line_caches(main);
+ _change_notify("visible_characters");
update();
}
}
@@ -3929,6 +3930,15 @@ void RichTextLabel::_bind_methods() {
void RichTextLabel::set_visible_characters(int p_visible) {
visible_characters = p_visible;
+ if (p_visible == -1) {
+ percent_visible = 1;
+ } else {
+ int total_char_count = get_total_character_count();
+ if (total_char_count > 0) {
+ percent_visible = (float)p_visible / (float)total_char_count;
+ }
+ }
+ _change_notify("percent_visible");
update();
}