Merge pull request #101787 from Break-Ben/signals-and-groups-docks
Separate Node editor dock
This commit is contained in:
57
editor/docks/groups_dock.cpp
Normal file
57
editor/docks/groups_dock.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/**************************************************************************/
|
||||
/* groups_dock.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "groups_dock.h"
|
||||
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
|
||||
void GroupsDock::set_selection(const Vector<Node *> &p_nodes) {
|
||||
groups->set_selection(p_nodes);
|
||||
}
|
||||
|
||||
GroupsDock::GroupsDock() {
|
||||
singleton = this;
|
||||
set_name(TTRC("Groups"));
|
||||
set_icon_name("Groups");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("docks/open_groups", TTRC("Open Groups Dock")));
|
||||
set_default_slot(DockConstants::DOCK_SLOT_RIGHT_UL);
|
||||
|
||||
VBoxContainer *main_vb = memnew(VBoxContainer);
|
||||
add_child(main_vb);
|
||||
|
||||
groups = memnew(GroupsEditor);
|
||||
main_vb->add_child(groups);
|
||||
groups->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
}
|
||||
|
||||
GroupsDock::~GroupsDock() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
50
editor/docks/groups_dock.h
Normal file
50
editor/docks/groups_dock.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**************************************************************************/
|
||||
/* groups_dock.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "editor/docks/groups_editor.h"
|
||||
|
||||
class GroupsDock : public EditorDock {
|
||||
GDCLASS(GroupsDock, EditorDock);
|
||||
|
||||
GroupsEditor *groups = nullptr;
|
||||
|
||||
static inline GroupsDock *singleton = nullptr;
|
||||
|
||||
public:
|
||||
static GroupsDock *get_singleton() { return singleton; }
|
||||
|
||||
void set_selection(const Vector<Node *> &p_nodes);
|
||||
|
||||
GroupsDock();
|
||||
~GroupsDock();
|
||||
};
|
||||
@ -1,137 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/* node_dock.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "node_dock.h"
|
||||
|
||||
#include "core/io/config_file.h"
|
||||
#include "editor/scene/connections_dialog.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
|
||||
void NodeDock::show_groups() {
|
||||
groups_button->set_pressed(true);
|
||||
connections_button->set_pressed(false);
|
||||
groups->show();
|
||||
connections->hide();
|
||||
}
|
||||
|
||||
void NodeDock::show_connections() {
|
||||
groups_button->set_pressed(false);
|
||||
connections_button->set_pressed(true);
|
||||
groups->hide();
|
||||
connections->show();
|
||||
}
|
||||
|
||||
void NodeDock::save_layout_to_config(Ref<ConfigFile> &p_layout, const String &p_section) const {
|
||||
p_layout->set_value(p_section, "current_tab", int(groups_button->is_pressed()));
|
||||
}
|
||||
|
||||
void NodeDock::load_layout_from_config(const Ref<ConfigFile> &p_layout, const String &p_section) {
|
||||
const int current_tab = p_layout->get_value(p_section, "current_tab", 0);
|
||||
if (current_tab == 0) {
|
||||
show_connections();
|
||||
} else if (current_tab == 1) {
|
||||
show_groups();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDock::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
connections_button->set_button_icon(get_editor_theme_icon(SNAME("Signals")));
|
||||
groups_button->set_button_icon(get_editor_theme_icon(SNAME("Groups")));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDock::update_lists() {
|
||||
connections->update_tree();
|
||||
}
|
||||
|
||||
void NodeDock::set_selection(const Vector<Object *> &p_objects) {
|
||||
connections->set_selection(p_objects);
|
||||
|
||||
Vector<Node *> nodes;
|
||||
for (Object *obj : p_objects) {
|
||||
Node *n = Object::cast_to<Node>(obj);
|
||||
if (n) {
|
||||
nodes.append(n);
|
||||
}
|
||||
}
|
||||
groups->set_selection(nodes);
|
||||
}
|
||||
|
||||
NodeDock::NodeDock() {
|
||||
singleton = this;
|
||||
set_name(TTRC("Node"));
|
||||
set_icon_name("Object");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("docks/open_node", TTRC("Open Node Dock")));
|
||||
set_default_slot(DockConstants::DOCK_SLOT_RIGHT_UL);
|
||||
|
||||
VBoxContainer *main_vb = memnew(VBoxContainer);
|
||||
add_child(main_vb);
|
||||
|
||||
mode_hb = memnew(HBoxContainer);
|
||||
main_vb->add_child(mode_hb);
|
||||
|
||||
connections_button = memnew(Button);
|
||||
connections_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
connections_button->set_text(TTRC("Signals"));
|
||||
connections_button->set_toggle_mode(true);
|
||||
connections_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
connections_button->set_clip_text(true);
|
||||
mode_hb->add_child(connections_button);
|
||||
connections_button->connect(SceneStringName(pressed), callable_mp(this, &NodeDock::show_connections));
|
||||
|
||||
groups_button = memnew(Button);
|
||||
groups_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
groups_button->set_text(TTRC("Groups"));
|
||||
groups_button->set_toggle_mode(true);
|
||||
groups_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
groups_button->set_clip_text(true);
|
||||
mode_hb->add_child(groups_button);
|
||||
groups_button->connect(SceneStringName(pressed), callable_mp(this, &NodeDock::show_groups));
|
||||
|
||||
connections = memnew(ConnectionsDock);
|
||||
main_vb->add_child(connections);
|
||||
connections->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
connections->hide();
|
||||
|
||||
groups = memnew(GroupsEditor);
|
||||
main_vb->add_child(groups);
|
||||
groups->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
groups->hide();
|
||||
|
||||
show_connections();
|
||||
}
|
||||
|
||||
NodeDock::~NodeDock() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
@ -38,8 +38,9 @@
|
||||
#include "editor/animation/animation_player_editor_plugin.h"
|
||||
#include "editor/debugger/editor_debugger_node.h"
|
||||
#include "editor/docks/filesystem_dock.h"
|
||||
#include "editor/docks/groups_dock.h"
|
||||
#include "editor/docks/inspector_dock.h"
|
||||
#include "editor/docks/node_dock.h"
|
||||
#include "editor/docks/signals_dock.h"
|
||||
#include "editor/editor_main_screen.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
@ -1351,7 +1352,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path());
|
||||
_node_replace_owner(node, node, root);
|
||||
_node_strip_signal_inheritance(node);
|
||||
NodeDock::get_singleton()->set_selection(Vector<Object *>{ node }); // Refresh.
|
||||
SignalsDock::get_singleton()->set_object(node); // Refresh.
|
||||
GroupsDock::get_singleton()->set_selection(Vector<Node *>{ node }); // Refresh.
|
||||
undo_redo->add_do_method(scene_tree, "update_tree");
|
||||
undo_redo->add_undo_method(scene_tree, "update_tree");
|
||||
undo_redo->commit_action();
|
||||
@ -2855,7 +2857,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
|
||||
editor_history->cleanup_history();
|
||||
InspectorDock::get_singleton()->call("_prepare_history");
|
||||
InspectorDock::get_singleton()->update(nullptr);
|
||||
NodeDock::get_singleton()->set_selection(Vector<Object *>{});
|
||||
SignalsDock::get_singleton()->set_object(nullptr);
|
||||
GroupsDock::get_singleton()->set_selection(Vector<Node *>());
|
||||
}
|
||||
|
||||
void SceneTreeDock::_update_script_button() {
|
||||
|
||||
62
editor/docks/signals_dock.cpp
Normal file
62
editor/docks/signals_dock.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/**************************************************************************/
|
||||
/* signals_dock.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "signals_dock.h"
|
||||
|
||||
#include "editor/scene/connections_dialog.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
|
||||
void SignalsDock::update_lists() {
|
||||
connections->update_tree();
|
||||
}
|
||||
|
||||
void SignalsDock::set_object(Object *p_object) {
|
||||
connections->set_object(p_object);
|
||||
}
|
||||
|
||||
SignalsDock::SignalsDock() {
|
||||
singleton = this;
|
||||
set_name(TTRC("Signals"));
|
||||
set_icon_name("Signals");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("docks/open_signals", TTRC("Open Signals Dock")));
|
||||
set_default_slot(DockConstants::DOCK_SLOT_RIGHT_UL);
|
||||
|
||||
VBoxContainer *main_vb = memnew(VBoxContainer);
|
||||
add_child(main_vb);
|
||||
|
||||
connections = memnew(ConnectionsDock);
|
||||
main_vb->add_child(connections);
|
||||
connections->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
}
|
||||
|
||||
SignalsDock::~SignalsDock() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/**************************************************************************/
|
||||
/* node_dock.h */
|
||||
/* signals_dock.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -31,42 +31,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "groups_editor.h"
|
||||
|
||||
class ConfigFile;
|
||||
class ConnectionsDock;
|
||||
|
||||
class NodeDock : public EditorDock {
|
||||
GDCLASS(NodeDock, EditorDock);
|
||||
|
||||
Button *connections_button = nullptr;
|
||||
Button *groups_button = nullptr;
|
||||
class SignalsDock : public EditorDock {
|
||||
GDCLASS(SignalsDock, EditorDock);
|
||||
|
||||
ConnectionsDock *connections = nullptr;
|
||||
GroupsEditor *groups = nullptr;
|
||||
|
||||
HBoxContainer *mode_hb = nullptr;
|
||||
|
||||
private:
|
||||
inline static NodeDock *singleton = nullptr;
|
||||
static inline SignalsDock *singleton = nullptr;
|
||||
|
||||
public:
|
||||
static NodeDock *get_singleton() { return singleton; }
|
||||
static SignalsDock *get_singleton() { return singleton; }
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
virtual void save_layout_to_config(Ref<ConfigFile> &p_layout, const String &p_section) const override;
|
||||
virtual void load_layout_from_config(const Ref<ConfigFile> &p_layout, const String &p_section) override;
|
||||
|
||||
public:
|
||||
void set_selection(const Vector<Object *> &p_objects);
|
||||
|
||||
void show_groups();
|
||||
void show_connections();
|
||||
void set_object(Object *p_object);
|
||||
|
||||
void update_lists();
|
||||
|
||||
NodeDock();
|
||||
~NodeDock();
|
||||
SignalsDock();
|
||||
~SignalsDock();
|
||||
};
|
||||
Reference in New Issue
Block a user