summaryrefslogtreecommitdiff
path: root/scene/gui/label.cpp
diff options
context:
space:
mode:
authorYuri Sizov <11782833+YuriSizov@users.noreply.github.com>2022-08-22 15:41:31 +0300
committerGitHub <noreply@github.com>2022-08-22 15:41:31 +0300
commit69c9d1f8e6d88947437fee0adb529c61b3109c23 (patch)
tree12d499a6a5c73dbacd5e2c21304b6b179483417d /scene/gui/label.cpp
parentd5052d90843c1e15545b2f4c5d8e6091ada3e9f6 (diff)
parent9a63792a08dc6a0c850add836a066222ef6b3b62 (diff)
Merge pull request #64670 from Mickeon/fix-label-visibile-percent
Clamp Label's `percent_visible` properly between 0 and 1.0
Diffstat (limited to 'scene/gui/label.cpp')
-rw-r--r--scene/gui/label.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index e7f48beb00..4ef1e48a32 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -764,13 +764,17 @@ int Label::get_visible_characters() const {
void Label::set_percent_visible(float p_percent) {
if (percent_visible != p_percent) {
- if (p_percent < 0 || p_percent >= 1) {
+ if (percent_visible >= 1.0) {
visible_chars = -1;
- percent_visible = 1;
+ percent_visible = 1.0;
+ } else if (percent_visible < 0.0) {
+ visible_chars = 0;
+ percent_visible = 0.0;
} else {
visible_chars = get_total_character_count() * p_percent;
percent_visible = p_percent;
}
+
if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
dirty = true;
}