Merge pull request #57873 from markdibarry/add_get_content_width_RichTextLabel
This commit is contained in:
commit
d6abf8f158
3 changed files with 16 additions and 0 deletions
|
@ -55,6 +55,12 @@
|
||||||
Returns the height of the content.
|
Returns the height of the content.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_content_width" qualifiers="const">
|
||||||
|
<return type="int" />
|
||||||
|
<description>
|
||||||
|
Returns the width of the content.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_line_count" qualifiers="const">
|
<method name="get_line_count" qualifiers="const">
|
||||||
<return type="int" />
|
<return type="int" />
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -4157,6 +4157,14 @@ int RichTextLabel::get_content_height() const {
|
||||||
return total_height;
|
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
|
#ifndef DISABLE_DEPRECATED
|
||||||
// People will be very angry, if their texts get erased, because of #39148. (3.x -> 4.0)
|
// 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.
|
// 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_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_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);
|
ClassDB::bind_method(D_METHOD("parse_expressions_for_values", "expressions"), &RichTextLabel::parse_expressions_for_values);
|
||||||
|
|
||||||
|
|
|
@ -554,6 +554,7 @@ public:
|
||||||
int get_visible_line_count() const;
|
int get_visible_line_count() const;
|
||||||
|
|
||||||
int get_content_height() const;
|
int get_content_height() const;
|
||||||
|
int get_content_width() const;
|
||||||
|
|
||||||
VScrollBar *get_v_scroll_bar() { return vscroll; }
|
VScrollBar *get_v_scroll_bar() { return vscroll; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue