diff options
author | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2018-10-04 14:33:34 -0300 |
---|---|---|
committer | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2018-12-14 12:09:47 -0200 |
commit | 64e52f5bdb89f7abbf9ac200768519f6fdc2811a (patch) | |
tree | ae1017253f9e77b05cd637c4a144bb85c859da8d | |
parent | 0a4a3f71570163955976ac29e9764423523049c9 (diff) |
Fix tree item editable cell not updating when windows was resized
-rw-r--r-- | scene/gui/tree.cpp | 17 | ||||
-rw-r--r-- | scene/gui/tree.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index f441364c44..479b035f86 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2701,6 +2701,7 @@ bool Tree::edit_selected() { Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); Point2i textedpos = get_global_position() + rect.position - ofs; + cache.text_editor_position = textedpos; text_editor->set_position(textedpos); text_editor->set_size(rect.size); text_editor->clear(); @@ -2956,6 +2957,21 @@ void Tree::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED) { update_cache(); } + + if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) { + + if (popup_edited_item != NULL) { + Rect2 rect = popup_edited_item->get_meta("__focus_rect"); + Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); + Point2i textedpos = get_global_position() + rect.position - ofs; + + if (cache.text_editor_position != textedpos) { + cache.text_editor_position = textedpos; + text_editor->set_position(textedpos); + value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height)); + } + } + } } Size2 Tree::get_minimum_size() const { @@ -3884,6 +3900,7 @@ Tree::Tree() { value_editor->set_as_toplevel(true); text_editor->set_as_toplevel(true); + set_notify_transform(true); updating_value_editor = false; pressed_button = -1; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 886ce66e2c..8622184bf8 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -457,6 +457,8 @@ private: TreeItem *hover_item; int hover_cell; + Point2i text_editor_position; + } cache; int _get_title_button_height() const; |