summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-02-10 18:24:13 +0100
committerGitHub <noreply@github.com>2022-02-10 18:24:13 +0100
commitd6abf8f1583e8a5dfcff655e0fa7cc3d3fc2069d (patch)
treef4a4d4ee361da2c7612917357dcc7faa0e74acd1 /scene
parente4e6813baf7090c701b8ea796b9d0f4f174c8d45 (diff)
parent29c21ac5904e212c5837dc39a70d6fa9da6f8bd1 (diff)
Merge pull request #57873 from markdibarry/add_get_content_width_RichTextLabel
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/rich_text_label.cpp9
-rw-r--r--scene/gui/rich_text_label.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 4865b9770e..86e5afcb7c 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -4157,6 +4157,14 @@ int RichTextLabel::get_content_height() const {
return total_height;
}
+int RichTextLabel::get_content_width() const {
+ int total_width = 0;
+ for (int i = 0; i < main->lines.size(); i++) {
+ total_width = MAX(total_width, main->lines[i].offset.x + main->lines[i].text_buf->get_size().x);
+ }
+ return total_width;
+}
+
#ifndef DISABLE_DEPRECATED
// People will be very angry, if their texts get erased, because of #39148. (3.x -> 4.0)
// Although some people may not used bbcode_text, so we only overwrite, if bbcode_text is not empty.
@@ -4279,6 +4287,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_visible_paragraph_count"), &RichTextLabel::get_visible_paragraph_count);
ClassDB::bind_method(D_METHOD("get_content_height"), &RichTextLabel::get_content_height);
+ ClassDB::bind_method(D_METHOD("get_content_width"), &RichTextLabel::get_content_width);
ClassDB::bind_method(D_METHOD("parse_expressions_for_values", "expressions"), &RichTextLabel::parse_expressions_for_values);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index e79244f2e4..ea3a08d7bd 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -554,6 +554,7 @@ public:
int get_visible_line_count() const;
int get_content_height() const;
+ int get_content_width() const;
VScrollBar *get_v_scroll_bar() { return vscroll; }