summaryrefslogtreecommitdiff
path: root/scene/gui/label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/label.cpp')
-rw-r--r--scene/gui/label.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 2d4438c48c..4c025e92df 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -144,7 +144,6 @@ void Label::_notification(int p_what) {
if (!wc)
return;
- int c = 0;
int line=0;
int line_to=lines_skipped + (lines_visible>0?lines_visible:1);
while(wc) {
@@ -357,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) {
@@ -536,7 +550,9 @@ void Label::set_text(const String& p_string) {
if (percent_visible<1)
visible_chars=get_total_character_count()*percent_visible;
update();
- minimum_size_changed();
+ if (!autowrap) {
+ minimum_size_changed();
+ }
}
@@ -639,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);