1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Separate Node editor dock

This commit is contained in:
Break
2025-11-08 12:22:34 +08:00
parent 235a32ad11
commit ef9738005a
19 changed files with 268 additions and 223 deletions

View File

@@ -84,11 +84,12 @@
#include "editor/doc/editor_help.h"
#include "editor/docks/editor_dock_manager.h"
#include "editor/docks/filesystem_dock.h"
#include "editor/docks/groups_dock.h"
#include "editor/docks/history_dock.h"
#include "editor/docks/import_dock.h"
#include "editor/docks/inspector_dock.h"
#include "editor/docks/node_dock.h"
#include "editor/docks/scene_tree_dock.h"
#include "editor/docks/signals_dock.h"
#include "editor/editor_data.h"
#include "editor/editor_interface.h"
#include "editor/editor_log.h"
@@ -2896,7 +2897,8 @@ void EditorNode::push_node_item(Node *p_node) {
void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) {
if (!p_object) {
InspectorDock::get_inspector_singleton()->edit(nullptr);
NodeDock::get_singleton()->set_selection(Vector<Object *>());
SignalsDock::get_singleton()->set_object(nullptr);
GroupsDock::get_singleton()->set_selection(Vector<Node *>());
SceneTreeDock::get_singleton()->set_selected(nullptr);
InspectorDock::get_singleton()->update(nullptr);
hide_unused_editors();
@@ -3007,7 +3009,8 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
if (!current_obj) {
SceneTreeDock::get_singleton()->set_selected(nullptr);
InspectorDock::get_inspector_singleton()->edit(nullptr);
NodeDock::get_singleton()->set_selection(Vector<Object *>());
SignalsDock::get_singleton()->set_object(nullptr);
GroupsDock::get_singleton()->set_selection(Vector<Node *>());
InspectorDock::get_singleton()->update(nullptr);
EditorDebuggerNode::get_singleton()->clear_remote_tree_selection();
hide_unused_editors();
@@ -3041,7 +3044,8 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
if (!p_skip_inspector_update) {
InspectorDock::get_inspector_singleton()->edit(current_res);
SceneTreeDock::get_singleton()->set_selected(nullptr);
NodeDock::get_singleton()->set_selection(Vector<Object *>{ current_res });
SignalsDock::get_singleton()->set_object(current_res);
GroupsDock::get_singleton()->set_selection(Vector<Node *>());
InspectorDock::get_singleton()->update(nullptr);
EditorDebuggerNode::get_singleton()->clear_remote_tree_selection();
ImportDock::get_singleton()->set_edit_path(current_res->get_path());
@@ -3071,7 +3075,8 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
InspectorDock::get_inspector_singleton()->edit(current_node);
if (current_node->is_inside_tree()) {
NodeDock::get_singleton()->set_selection(Vector<Object *>{ current_node });
SignalsDock::get_singleton()->set_object(current_node);
GroupsDock::get_singleton()->set_selection(Vector<Node *>{ current_node });
SceneTreeDock::get_singleton()->set_selected(current_node);
SceneTreeDock::get_singleton()->set_selection({ current_node });
InspectorDock::get_singleton()->update(current_node);
@@ -3083,7 +3088,8 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
}
}
} else {
NodeDock::get_singleton()->set_selection(Vector<Object *>());
SignalsDock::get_singleton()->set_object(nullptr);
GroupsDock::get_singleton()->set_selection(Vector<Node *>());
SceneTreeDock::get_singleton()->set_selected(nullptr);
InspectorDock::get_singleton()->update(nullptr);
}
@@ -3130,15 +3136,9 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
EditorDebuggerNode::get_singleton()->clear_remote_tree_selection();
}
// TODO: This can be replaced by some casting operator.
Vector<Object *> nodes_as_objects;
nodes_as_objects.reserve_exact(multi_nodes.size());
for (Node *n : multi_nodes) {
nodes_as_objects.append(n);
}
InspectorDock::get_inspector_singleton()->edit(current_obj);
NodeDock::get_singleton()->set_selection(nodes_as_objects);
SignalsDock::get_singleton()->set_object(nullptr);
GroupsDock::get_singleton()->set_selection(multi_nodes);
SceneTreeDock::get_singleton()->set_selected(selected_node);
SceneTreeDock::get_singleton()->set_selection(multi_nodes);
InspectorDock::get_singleton()->update(nullptr);
@@ -7574,7 +7574,8 @@ void EditorNode::_resource_loaded(Ref<Resource> p_resource, const String &p_path
void EditorNode::_feature_profile_changed() {
Ref<EditorFeatureProfile> profile = feature_profile_manager->get_current_profile();
if (profile.is_valid()) {
editor_dock_manager->set_dock_enabled(NodeDock::get_singleton(), !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_NODE_DOCK));
editor_dock_manager->set_dock_enabled(SignalsDock::get_singleton(), !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SIGNALS_DOCK));
editor_dock_manager->set_dock_enabled(GroupsDock::get_singleton(), !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GROUPS_DOCK));
// The Import dock is useless without the FileSystem dock. Ensure the configuration is valid.
bool fs_dock_disabled = profile->is_feature_disabled(EditorFeatureProfile::FEATURE_FILESYSTEM_DOCK);
editor_dock_manager->set_dock_enabled(FileSystemDock::get_singleton(), !fs_dock_disabled);
@@ -7591,7 +7592,8 @@ void EditorNode::_feature_profile_changed() {
}
} else {
editor_dock_manager->set_dock_enabled(ImportDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(NodeDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(SignalsDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(GroupsDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(FileSystemDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(history_dock, true);
editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_3D, true);
@@ -8749,15 +8751,18 @@ EditorNode::EditorNode() {
memnew(InspectorDock(editor_data));
editor_dock_manager->add_dock(InspectorDock::get_singleton());
memnew(NodeDock);
editor_dock_manager->add_dock(NodeDock::get_singleton());
memnew(SignalsDock);
editor_dock_manager->add_dock(SignalsDock::get_singleton());
memnew(GroupsDock);
editor_dock_manager->add_dock(GroupsDock::get_singleton());
history_dock = memnew(HistoryDock);
editor_dock_manager->add_dock(history_dock);
// Add some offsets to left_r and main hsplits to make LEFT_R and RIGHT_L docks wider than minsize.
left_r_hsplit->set_split_offset(270 * EDSCALE);
main_hsplit->set_split_offset(-270 * EDSCALE);
main_hsplit->set_split_offset(-360 * EDSCALE);
// Define corresponding default layout.
@@ -8766,7 +8771,7 @@ EditorNode::EditorNode() {
// Dock numbers are based on DockSlot enum value + 1.
default_layout->set_value(docks_section, "dock_3", "Scene,Import");
default_layout->set_value(docks_section, "dock_4", "FileSystem");
default_layout->set_value(docks_section, "dock_5", "Inspector,Node,History");
default_layout->set_value(docks_section, "dock_5", "Inspector,Signals,Groups,History");
int hsplits[] = { 0, 270, -270, 0 };
DEV_ASSERT((int)std_size(hsplits) == editor_dock_manager->get_hsplit_count());