diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-06-04 16:08:25 +0200 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-06-04 16:08:25 +0200 |
commit | f1cd33b53916f47ee4b60440f5b37dd08bec0c9e (patch) | |
tree | d075af6d09f82e8d55924113f964423f004b547b | |
parent | 4b0bae97998dc337c0ca3cfb84332fe2d06d3433 (diff) | |
parent | 5f7b42cb874764b9e23724ed4a99c1b165b84f8a (diff) |
Merge pull request #5030 from sanikoyes/Pr-fix-label-minsize
fix line_edit&label get min size bug&draw problem
-rw-r--r-- | scene/gui/label.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 09c6a77b42..8652aab649 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -488,9 +488,9 @@ void Label::regenerate_word_cache() { if (!autowrap) { minsize.width=width; if (max_lines_visible > 0 && line_count > max_lines_visible) { - minsize.height=(font->get_height()+line_spacing)*max_lines_visible; + minsize.height=(font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1)); } else { - minsize.height=(font->get_height()+line_spacing)*line_count; + minsize.height=(font->get_height() * line_count)+(line_spacing * (line_count - 1)); } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ca2d09dd27..44cc798447 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -454,7 +454,7 @@ void LineEdit::_notification(int p_what) { } break; } - int ofs_max=width-style->get_minimum_size().width; + int ofs_max=width-style->get_minimum_size().width+x_ofs; int char_ofs=window_pos; int y_area=height-style->get_minimum_size().height; @@ -799,8 +799,7 @@ Size2 LineEdit::get_minimum_size() const { Ref<Font> font=get_font("font"); Size2 min=style->get_minimum_size(); - min.height+=font->get_height(); - min.width+=get_constant("minimum_spaces")*font->get_char_size(' ').x; + min+=font->get_string_size(this->text); return min; } |