summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-08-25 09:56:08 +0200
committerGitHub <noreply@github.com>2022-08-25 09:56:08 +0200
commit0a5f5c85584df93863f9aed50a1ae3e1aa18f932 (patch)
tree151ead36c87c70a49026b8a03f3ac0c2160d319a /scene
parent8c1dc0c7eaa4ac498372e55d04920a9a3ef678be (diff)
parent550616293a4ed795082421014ffb43da594edde5 (diff)
Merge pull request #64536 from Mickeon/editor-tree-icon-size
Account for TreeItem's Cell icon and center the text Popup vertically
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tree.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 4a3a35383e..2b19ee4d0b 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3718,12 +3718,17 @@ bool Tree::edit_selected() {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
Rect2 popup_rect;
- Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Vector2 ofs(0, Math::floor((text_editor->get_size().height - rect.size.height) / 2)); // "floor()" centers vertically.
Point2i textedpos = get_screen_position() + rect.position - ofs;
cache.text_editor_position = textedpos;
popup_rect.position = textedpos;
popup_rect.size = rect.size;
+
+ // Account for icon.
+ popup_rect.position.x += c.get_icon_size().x;
+ popup_rect.size.x -= c.get_icon_size().x;
+
text_editor->clear();
text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
text_editor->select_all();