mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Take into account the clear icon's size even when not visible in LineEdit
s
This commit is contained in:
parent
c0bf18e923
commit
71c8fb26e0
@ -1686,13 +1686,17 @@ Size2 LineEdit::get_minimum_size() const {
|
|||||||
min_size.height = MAX(TS->shaped_text_get_size(text_rid).y + font->get_spacing(TextServer::SPACING_TOP) + font->get_spacing(TextServer::SPACING_BOTTOM), font->get_height(font_size));
|
min_size.height = MAX(TS->shaped_text_get_size(text_rid).y + font->get_spacing(TextServer::SPACING_TOP) + font->get_spacing(TextServer::SPACING_BOTTOM), font->get_height(font_size));
|
||||||
|
|
||||||
// Take icons into account.
|
// Take icons into account.
|
||||||
bool using_placeholder = text.is_empty() && ime_text.is_empty();
|
int icon_max_width = 0;
|
||||||
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
|
if (right_icon.is_valid()) {
|
||||||
if (right_icon.is_valid() || display_clear_icon) {
|
min_size.height = MAX(min_size.height, right_icon->get_height());
|
||||||
Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon;
|
icon_max_width = right_icon->get_width();
|
||||||
min_size.width += r_icon->get_width();
|
|
||||||
min_size.height = MAX(min_size.height, r_icon->get_height());
|
|
||||||
}
|
}
|
||||||
|
if (clear_button_enabled) {
|
||||||
|
Ref<Texture2D> clear_icon = Control::get_theme_icon(SNAME("clear"));
|
||||||
|
min_size.height = MAX(min_size.height, clear_icon->get_height());
|
||||||
|
icon_max_width = MAX(icon_max_width, clear_icon->get_width());
|
||||||
|
}
|
||||||
|
min_size.width += icon_max_width;
|
||||||
|
|
||||||
return style->get_minimum_size() + min_size;
|
return style->get_minimum_size() + min_size;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user