Merge pull request #18122 from olivergs/wip/rtl-content-height
RichTextLabel, doc: Added new method to get total content height
This commit is contained in:
commit
fb4e9526e8
3 changed files with 19 additions and 3 deletions
|
@ -75,6 +75,13 @@
|
||||||
Returns the number of visible lines.
|
Returns the number of visible lines.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_content_height">
|
||||||
|
<return type="int">
|
||||||
|
</return>
|
||||||
|
<description>
|
||||||
|
Returns the height of the content.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="newline">
|
<method name="newline">
|
||||||
<return type="void">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
|
|
|
@ -692,9 +692,7 @@ void RichTextLabel::_scroll_changed(double) {
|
||||||
|
|
||||||
void RichTextLabel::_update_scroll() {
|
void RichTextLabel::_update_scroll() {
|
||||||
|
|
||||||
int total_height = 0;
|
int total_height = get_content_height();
|
||||||
if (main->lines.size())
|
|
||||||
total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
|
|
||||||
|
|
||||||
bool exceeds = total_height > get_size().height && scroll_active;
|
bool exceeds = total_height > get_size().height && scroll_active;
|
||||||
|
|
||||||
|
@ -2058,6 +2056,13 @@ float RichTextLabel::get_percent_visible() const {
|
||||||
return percent_visible;
|
return percent_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RichTextLabel::get_content_height() {
|
||||||
|
int total_height = 0;
|
||||||
|
if (main->lines.size())
|
||||||
|
total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
|
||||||
|
return total_height;
|
||||||
|
}
|
||||||
|
|
||||||
void RichTextLabel::_bind_methods() {
|
void RichTextLabel::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input);
|
ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input);
|
||||||
|
@ -2124,6 +2129,8 @@ void RichTextLabel::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_line_count"), &RichTextLabel::get_line_count);
|
ClassDB::bind_method(D_METHOD("get_line_count"), &RichTextLabel::get_line_count);
|
||||||
ClassDB::bind_method(D_METHOD("get_visible_line_count"), &RichTextLabel::get_visible_line_count);
|
ClassDB::bind_method(D_METHOD("get_visible_line_count"), &RichTextLabel::get_visible_line_count);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_content_height"), &RichTextLabel::get_content_height);
|
||||||
|
|
||||||
ADD_GROUP("BBCode", "bbcode_");
|
ADD_GROUP("BBCode", "bbcode_");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode");
|
||||||
|
|
|
@ -340,6 +340,8 @@ public:
|
||||||
int get_line_count() const;
|
int get_line_count() const;
|
||||||
int get_visible_line_count() const;
|
int get_visible_line_count() const;
|
||||||
|
|
||||||
|
int get_content_height();
|
||||||
|
|
||||||
VScrollBar *get_v_scroll() { return vscroll; }
|
VScrollBar *get_v_scroll() { return vscroll; }
|
||||||
|
|
||||||
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
|
||||||
|
|
Loading…
Reference in a new issue