Przeglądaj źródła

Fix tree item editable cell not updating when windows was resized

Guilherme Felipe 7 lat temu
rodzic
commit
64e52f5bdb
2 zmienionych plików z 19 dodań i 0 usunięć
  1. 17 0
      scene/gui/tree.cpp
  2. 2 0
      scene/gui/tree.h

+ 17 - 0
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;

+ 2 - 0
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;