summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-12 17:18:50 +0100
committerGitHub <noreply@github.com>2021-02-12 17:18:50 +0100
commit45c6d3c5767f0ebc60ef1334aec5720680191eec (patch)
treecdb7b5a85d71a3cafb890ef261783c19670ff43b /scene
parent5e528f35505ba946cbda5f7c1fc800ed578b52dc (diff)
parent28537d8c84a03bf88e99f3cae0ca5ded0fc95df6 (diff)
Merge pull request #45923 from reduz/fix-lineedit-minimum-width
Fix LineEdit minimum width
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/line_edit.cpp6
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
3 files changed, 5 insertions, 5 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 14c84eb256..654507b933 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1568,12 +1568,12 @@ Size2 LineEdit::get_minimum_size() const {
Size2 min_size;
// Minimum size of text.
- int space_size = font->get_char_size(' ', 0, font_size).x;
- min_size.width = get_theme_constant("minimum_spaces") * space_size;
+ int em_space_size = font->get_char_size('M', 0, font_size).x;
+ min_size.width = get_theme_constant("minimum_character_width'") * em_space_size;
if (expand_to_text_length) {
// Add a space because some fonts are too exact, and because cursor needs a bit more when at the end.
- min_size.width = MAX(min_size.width, full_width + space_size);
+ min_size.width = MAX(min_size.width, full_width + em_space_size);
}
min_size.height = MAX(TS->shaped_text_get_size(text_rid).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM), font->get_height(font_size));
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 85587c6f5f..3306a11dd0 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1380,7 +1380,7 @@ void TextEdit::_notification(int p_what) {
l_caret.size.y = h;
}
l_caret.position += Vector2(char_margin + ofs_x, ofs_y);
- l_caret.size.x = cache.font->get_char_size('m', 0, cache.font_size).x;
+ l_caret.size.x = cache.font->get_char_size('M', 0, cache.font_size).x;
draw_rect(l_caret, cache.caret_color, false);
}
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 31bc00e528..e66de82ed9 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -394,7 +394,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("clear_button_color", "LineEdit", control_font_color);
theme->set_color("clear_button_color_pressed", "LineEdit", control_font_pressed_color);
- theme->set_constant("minimum_spaces", "LineEdit", 12 * scale);
+ theme->set_constant("minimum_character_width", "LineEdit", 4);
theme->set_icon("clear", "LineEdit", make_icon(line_edit_clear_png));