mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 21:52:51 +00:00
Label: Added get_visible_line_count
method
This commit is contained in:
parent
6a5e11c075
commit
78819b6b54
@ -356,6 +356,21 @@ int Label::get_line_count() const {
|
||||
return line_count;
|
||||
}
|
||||
|
||||
int Label::get_visible_line_count() const {
|
||||
|
||||
int line_spacing = get_constant("line_spacing");
|
||||
int font_h = get_font("font")->get_height()+line_spacing;
|
||||
int lines_visible = (get_size().y+line_spacing)/font_h;
|
||||
|
||||
if (lines_visible > line_count)
|
||||
lines_visible = line_count;
|
||||
|
||||
if (max_lines_visible >= 0 && lines_visible > max_lines_visible)
|
||||
lines_visible = max_lines_visible;
|
||||
|
||||
return lines_visible;
|
||||
}
|
||||
|
||||
void Label::regenerate_word_cache() {
|
||||
|
||||
while (word_cache) {
|
||||
@ -640,6 +655,7 @@ void Label::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
|
||||
ObjectTypeDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
|
||||
ObjectTypeDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
|
||||
ObjectTypeDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
|
||||
ObjectTypeDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
|
||||
ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
|
||||
ObjectTypeDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
|
||||
int get_line_height() const;
|
||||
int get_line_count() const;
|
||||
int get_visible_line_count() const;
|
||||
|
||||
Label(const String& p_text=String());
|
||||
~Label();
|
||||
|
Loading…
Reference in New Issue
Block a user