Fix tree item editable cell not updating when windows was resized

This commit is contained in:
Guilherme Felipe 2018-10-04 14:33:34 -03:00
parent 0a4a3f7157
commit 64e52f5bdb
2 changed files with 19 additions and 0 deletions

View file

@ -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;

View file

@ -457,6 +457,8 @@ private:
TreeItem *hover_item;
int hover_cell;
Point2i text_editor_position;
} cache;
int _get_title_button_height() const;