Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add right click popup options in Connections to Method dialog. #100814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ void ConnectionsDock::_make_or_edit_connection() {
/*
* Creates single connection w/ undo-redo functionality.
*/
void ConnectionsDock::_connect(const ConnectDialog::ConnectionData &p_cd) {
void ConnectionsDock::_connect(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action) {
Node *source = Object::cast_to<Node>(p_cd.source);
Node *target = Object::cast_to<Node>(p_cd.target);

Expand All @@ -1018,13 +1018,15 @@ void ConnectionsDock::_connect(const ConnectDialog::ConnectionData &p_cd) {
undo_redo->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree"); // To force redraw of scene tree.
undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");

undo_redo->commit_action();
if (commit_action) {
undo_redo->commit_action();
}
}

/*
* Break single connection w/ undo-redo functionality.
*/
void ConnectionsDock::_disconnect(const ConnectDialog::ConnectionData &p_cd) {
void ConnectionsDock::_disconnect(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action) {
ERR_FAIL_COND(p_cd.source != selected_node); // Shouldn't happen but... Bugcheck.

EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
Expand All @@ -1038,7 +1040,9 @@ void ConnectionsDock::_disconnect(const ConnectDialog::ConnectionData &p_cd) {
undo_redo->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree"); // To force redraw of scene tree.
undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");

undo_redo->commit_action();
if (commit_action) {
undo_redo->commit_action();
}
}

/*
Expand Down Expand Up @@ -1589,6 +1593,8 @@ void ConnectionsDock::update_tree() {
connect_button->set_disabled(true);
}

ConnectionsDock *ConnectionsDock::singleton = nullptr;

ConnectionsDock::ConnectionsDock() {
set_name(TTR("Signals"));

Expand Down Expand Up @@ -1657,6 +1663,8 @@ ConnectionsDock::ConnectionsDock() {
tree->connect(SceneStringName(gui_input), callable_mp(this, &ConnectionsDock::_tree_gui_input));

add_theme_constant_override("separation", 3 * EDSCALE);

singleton = this;
}

ConnectionsDock::~ConnectionsDock() {
Expand Down
13 changes: 11 additions & 2 deletions editor/connections_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ class ConnectionsDockTree : public Tree {
class ConnectionsDock : public VBoxContainer {
GDCLASS(ConnectionsDock, VBoxContainer);

static ConnectionsDock *singleton;

enum TreeItemType {
TREE_ITEM_TYPE_ROOT,
TREE_ITEM_TYPE_CLASS,
Expand Down Expand Up @@ -237,8 +239,8 @@ class ConnectionsDock : public VBoxContainer {
void _filter_changed(const String &p_text);

void _make_or_edit_connection();
void _connect(const ConnectDialog::ConnectionData &p_cd);
void _disconnect(const ConnectDialog::ConnectionData &p_cd);
void _connect(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action = true);
void _disconnect(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action = true);
void _disconnect_all();

void _tree_item_selected();
Expand All @@ -265,6 +267,13 @@ class ConnectionsDock : public VBoxContainer {
static void _bind_methods();

public:
static ConnectionsDock *get_singleton() { return singleton; }
void connect_connection(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action = true) {
_connect(p_cd, commit_action);
}
void disconnect_connection(const ConnectDialog::ConnectionData &p_cd, const bool &commit_action = true) {
_disconnect(p_cd, commit_action);
}
void set_node(Node *p_node);
void update_tree();

Expand Down
Loading