summaryrefslogtreecommitdiff
path: root/editor/connections_dialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/connections_dialog.h')
-rw-r--r--editor/connections_dialog.h83
1 files changed, 52 insertions, 31 deletions
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index b9911c1cc5..8bad2d9b5b 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,10 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-/**
-@author Juan Linietsky <reduzio@gmail.com>
-*/
-
#ifndef CONNECTIONS_DIALOG_H
#define CONNECTIONS_DIALOG_H
@@ -48,6 +44,7 @@
class PopupMenu;
class ConnectDialogBinds;
+class SpinBox;
class ConnectDialog : public ConfirmationDialog {
GDCLASS(ConnectDialog, ConfirmationDialog);
@@ -59,25 +56,45 @@ public:
StringName signal;
StringName method;
uint32_t flags = 0;
+ int unbinds = 0;
Vector<Variant> binds;
- ConnectionData() {
- }
+ ConnectionData() {}
+
ConnectionData(const Connection &p_connection) {
source = Object::cast_to<Node>(p_connection.signal.get_object());
signal = p_connection.signal.get_name();
target = Object::cast_to<Node>(p_connection.callable.get_object());
- method = p_connection.callable.get_method();
flags = p_connection.flags;
- binds = p_connection.binds;
+
+ Callable base_callable;
+ if (p_connection.callable.is_custom()) {
+ CallableCustomBind *ccb = dynamic_cast<CallableCustomBind *>(p_connection.callable.get_custom());
+ if (ccb) {
+ binds = ccb->get_binds();
+ base_callable = ccb->get_callable();
+ }
+
+ CallableCustomUnbind *ccu = dynamic_cast<CallableCustomUnbind *>(p_connection.callable.get_custom());
+ if (ccu) {
+ unbinds = ccu->get_unbinds();
+ base_callable = ccu->get_callable();
+ }
+ } else {
+ base_callable = p_connection.callable;
+ }
+ method = base_callable.get_method();
}
- operator Connection() {
- Connection c;
- c.signal = ::Signal(source, signal);
- c.callable = Callable(target, method);
- c.flags = flags;
- c.binds = binds;
- return c;
+
+ Callable get_callable() {
+ if (unbinds > 0) {
+ return Callable(target, method).unbind(unbinds);
+ } else if (!binds.is_empty()) {
+ const Variant *args = binds.ptr();
+ return Callable(target, method).bind(&args, binds.size());
+ } else {
+ return Callable(target, method);
+ }
}
};
@@ -88,25 +105,28 @@ private:
StringName signal;
LineEdit *dst_method;
ConnectDialogBinds *cdbinds;
- bool bEditMode;
+ bool edit_mode;
NodePath dst_path;
VBoxContainer *vbc_right;
SceneTreeEditor *tree;
AcceptDialog *error;
+ SpinBox *unbind_count;
EditorInspector *bind_editor;
OptionButton *type_list;
CheckBox *deferred;
CheckBox *oneshot;
CheckButton *advanced;
+ Vector<Control *> bind_controls;
Label *error_label;
void ok_pressed() override;
void _cancel_pressed();
void _item_activated();
- void _text_submitted(const String &_text);
+ void _text_submitted(const String &p_text);
void _tree_node_selected();
+ void _unbind_count_changed(double p_count);
void _add_bind();
void _remove_bind();
void _advanced_pressed();
@@ -123,13 +143,14 @@ public:
void set_dst_node(Node *p_node);
StringName get_dst_method_name() const;
void set_dst_method(const StringName &p_method);
+ int get_unbinds() const;
Vector<Variant> get_binds() const;
bool get_deferred() const;
bool get_oneshot() const;
bool is_editing() const;
- void init(ConnectionData c, bool bEdit = false);
+ void init(ConnectionData p_cd, bool p_edit = false);
void popup_dialog(const String &p_for_signal);
ConnectDialog();
@@ -159,7 +180,7 @@ class ConnectionsDock : public VBoxContainer {
DISCONNECT
};
- Node *selectedNode;
+ Node *selected_node;
ConnectionsDockTree *tree;
EditorNode *editor;
@@ -176,21 +197,21 @@ class ConnectionsDock : public VBoxContainer {
void _filter_changed(const String &p_text);
void _make_or_edit_connection();
- void _connect(ConnectDialog::ConnectionData cToMake);
- void _disconnect(TreeItem &item);
+ void _connect(ConnectDialog::ConnectionData p_cd);
+ void _disconnect(TreeItem &p_item);
void _disconnect_all();
void _tree_item_selected();
void _tree_item_activated();
- bool _is_item_signal(TreeItem &item);
+ bool _is_item_signal(TreeItem &p_item);
- void _open_connection_dialog(TreeItem &item);
- void _open_connection_dialog(ConnectDialog::ConnectionData cToEdit);
- void _go_to_script(TreeItem &item);
+ void _open_connection_dialog(TreeItem &p_item);
+ void _open_connection_dialog(ConnectDialog::ConnectionData p_cd);
+ void _go_to_script(TreeItem &p_item);
- void _handle_signal_menu_option(int option);
- void _handle_slot_menu_option(int option);
- void _rmb_pressed(Vector2 position);
+ void _handle_signal_menu_option(int p_option);
+ void _handle_slot_menu_option(int p_option);
+ void _rmb_pressed(Vector2 p_position);
void _close();
protected:
@@ -207,4 +228,4 @@ public:
~ConnectionsDock();
};
-#endif
+#endif // CONNECTIONS_DIALOG_H