Browse Source

Add collapse/expand right click option to remote scene view

Kasper Frandsen 1 year ago
parent
commit
5ad7cd33bd
2 changed files with 17 additions and 0 deletions
  1. 16 0
      editor/debugger/editor_debugger_tree.cpp
  2. 1 0
      editor/debugger/editor_debugger_tree.h

+ 16 - 0
editor/debugger/editor_debugger_tree.cpp

@@ -124,6 +124,7 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position, Mou
 	item_menu->clear();
 	item_menu->add_icon_item(get_editor_theme_icon(SNAME("CreateNewSceneFrom")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE);
 	item_menu->add_icon_item(get_editor_theme_icon(SNAME("CopyNodePath")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH);
+	item_menu->add_icon_item(get_editor_theme_icon(SNAME("Collapse")), TTR("Expand/Collapse Branch"), ITEM_MENU_EXPAND_COLLAPSE);
 	item_menu->set_position(get_screen_position() + get_local_mouse_position());
 	item_menu->reset_size();
 	item_menu->popup();
@@ -359,6 +360,21 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
 			}
 			DisplayServer::get_singleton()->clipboard_set(text);
 		} break;
+		case ITEM_MENU_EXPAND_COLLAPSE: {
+			TreeItem *s_item = get_selected();
+
+			if (!s_item) {
+				s_item = get_root();
+				if (!s_item) {
+					break;
+				}
+			}
+
+			bool collapsed = s_item->is_any_collapsed();
+			s_item->set_collapsed_recursive(!collapsed);
+
+			ensure_cursor_is_visible();
+		}
 	}
 }
 

+ 1 - 0
editor/debugger/editor_debugger_tree.h

@@ -43,6 +43,7 @@ private:
 	enum ItemMenu {
 		ITEM_MENU_SAVE_REMOTE_NODE,
 		ITEM_MENU_COPY_NODE_PATH,
+		ITEM_MENU_EXPAND_COLLAPSE,
 	};
 
 	ObjectID inspected_object_id;