Skip to content

Commit a76c1ac

Browse files
committed
Merge pull request godotengine#104141 from BrotherShort/treeitem-rename-edit-offset
Fix the TreeItem rename LineEdit is offset
2 parents 17ae1d7 + 08f93fc commit a76c1ac

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scene/gui/tree.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4085,7 +4085,7 @@ bool Tree::edit_selected(bool p_force_edit) {
40854085
return false;
40864086
}
40874087

4088-
float popup_scale = popup_editor->is_embedded() ? 1.0 : popup_editor->get_parent_visible_window()->get_content_scale_factor();
4088+
real_t popup_scale = popup_editor->is_embedded() ? 1.0 : popup_editor->get_parent_visible_window()->get_content_scale_factor();
40894089
Rect2 rect = _get_item_focus_rect(s);
40904090
rect.position *= popup_scale;
40914091
popup_edited_item = s;
@@ -4127,13 +4127,16 @@ bool Tree::edit_selected(bool p_force_edit) {
41274127
Vector2 ofs(0, Math::floor((MAX(line_editor->get_minimum_size().height, rect.size.height - value_editor_height) - rect.size.height) / 2));
41284128

41294129
// Account for icon.
4130-
Size2 icon_size = _get_cell_icon_size(c) * popup_scale;
4130+
real_t icon_ofs = 0;
4131+
if (c.icon.is_valid()) {
4132+
icon_ofs = _get_cell_icon_size(c).x * popup_scale + theme_cache.h_separation;
4133+
}
41314134

41324135
popup_rect.size = rect.size;
4133-
popup_rect.size.x -= icon_size.x + theme_cache.h_separation;
4136+
popup_rect.size.x -= icon_ofs;
41344137

41354138
popup_rect.position = rect.position - ofs;
4136-
popup_rect.position.x += icon_size.x + theme_cache.h_separation;
4139+
popup_rect.position.x += icon_ofs;
41374140
if (cache.rtl) {
41384141
popup_rect.position.x = get_size().width - popup_rect.position.x - popup_rect.size.x;
41394142
}

0 commit comments

Comments
 (0)