Merge pull request #76605 from Rindbee/fix_get_visible_line_count
Fix calculation bug with `TextEdit::get_line_height()`
This commit is contained in:
commit
d61827af05
@ -347,7 +347,8 @@
|
|||||||
<method name="get_line_height" qualifiers="const">
|
<method name="get_line_height" qualifiers="const">
|
||||||
<return type="int" />
|
<return type="int" />
|
||||||
<description>
|
<description>
|
||||||
Returns the height of a largest line.
|
Returns the maximum value of the line height among all lines.
|
||||||
|
[b]Note:[/b] The return value is influenced by [theme_item line_spacing] and [theme_item font_size]. And it will not be less than [code]1[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_line_width" qualifiers="const">
|
<method name="get_line_width" qualifiers="const">
|
||||||
|
@ -3010,6 +3010,9 @@ void TextEdit::_update_theme_item_cache() {
|
|||||||
theme_cache.outline_color = get_theme_color(SNAME("font_outline_color"));
|
theme_cache.outline_color = get_theme_color(SNAME("font_outline_color"));
|
||||||
|
|
||||||
theme_cache.line_spacing = get_theme_constant(SNAME("line_spacing"));
|
theme_cache.line_spacing = get_theme_constant(SNAME("line_spacing"));
|
||||||
|
if (text.get_line_height() + theme_cache.line_spacing < 1) {
|
||||||
|
WARN_PRINT("Line height is too small, please increase font_size and/or line_spacing");
|
||||||
|
}
|
||||||
|
|
||||||
theme_cache.background_color = get_theme_color(SNAME("background_color"));
|
theme_cache.background_color = get_theme_color(SNAME("background_color"));
|
||||||
theme_cache.current_line_color = get_theme_color(SNAME("current_line_color"));
|
theme_cache.current_line_color = get_theme_color(SNAME("current_line_color"));
|
||||||
@ -3481,7 +3484,7 @@ int TextEdit::get_line_width(int p_line, int p_wrap_index) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TextEdit::get_line_height() const {
|
int TextEdit::get_line_height() const {
|
||||||
return text.get_line_height() + theme_cache.line_spacing;
|
return MAX(text.get_line_height() + theme_cache.line_spacing, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextEdit::get_indent_level(int p_line) const {
|
int TextEdit::get_indent_level(int p_line) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user