diff options
Diffstat (limited to 'editor/connections_dialog.h')
-rw-r--r-- | editor/connections_dialog.h | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index c30413953a..48fdb91f5a 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -50,9 +50,38 @@ class PopupMenu; class ConnectDialogBinds; class ConnectDialog : public ConfirmationDialog { - GDCLASS(ConnectDialog, ConfirmationDialog); +public: + struct ConnectionData { + Node *source = nullptr; + Node *target = nullptr; + StringName signal; + StringName method; + uint32_t flags = 0; + Vector<Variant> binds; + + 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; + } + operator Connection() { + Connection c; + c.signal = ::Signal(source, signal); + c.callable = Callable(target, method); + c.flags = flags; + c.binds = binds; + return c; + } + }; + +private: Label *connect_to_label; LineEdit *from_signal; Node *source; @@ -73,10 +102,11 @@ class ConnectDialog : public ConfirmationDialog { Label *error_label; - void ok_pressed(); + void ok_pressed() override; void _cancel_pressed(); + void _item_activated(); + void _text_entered(const String &_text); void _tree_node_selected(); - void _tree_item_activated(); void _add_bind(); void _remove_bind(); void _advanced_pressed(); @@ -99,7 +129,7 @@ public: bool get_oneshot() const; bool is_editing() const; - void init(Connection c, bool bEdit = false); + void init(ConnectionData c, bool bEdit = false); void popup_dialog(const String &p_for_signal); ConnectDialog(); @@ -111,12 +141,10 @@ public: // Custom Tree needed to use a RichTextLabel as tooltip control // when display signal documentation. class ConnectionsDockTree : public Tree { - virtual Control *make_custom_tooltip(const String &p_text) const; }; class ConnectionsDock : public VBoxContainer { - GDCLASS(ConnectionsDock, VBoxContainer); //Right-click Pop-up Menu Options. @@ -141,11 +169,14 @@ class ConnectionsDock : public VBoxContainer { PopupMenu *signal_menu; PopupMenu *slot_menu; UndoRedo *undo_redo; + LineEdit *search_box; + + Map<StringName, Map<StringName, String>> descr_cache; - Map<StringName, Map<StringName, String> > descr_cache; + void _filter_changed(const String &p_text); void _make_or_edit_connection(); - void _connect(Connection cToMake); + void _connect(ConnectDialog::ConnectionData cToMake); void _disconnect(TreeItem &item); void _disconnect_all(); @@ -154,7 +185,7 @@ class ConnectionsDock : public VBoxContainer { bool _is_item_signal(TreeItem &item); void _open_connection_dialog(TreeItem &item); - void _open_connection_dialog(Connection cToEdit); + void _open_connection_dialog(ConnectDialog::ConnectionData cToEdit); void _go_to_script(TreeItem &item); void _handle_signal_menu_option(int option); @@ -172,7 +203,7 @@ public: void set_node(Node *p_node); void update_tree(); - ConnectionsDock(EditorNode *p_editor = NULL); + ConnectionsDock(EditorNode *p_editor = nullptr); ~ConnectionsDock(); }; |