diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/connections_dialog.cpp | 53 | ||||
-rw-r--r-- | editor/connections_dialog.h | 3 |
2 files changed, 40 insertions, 16 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index facd57418d..fdaa66e8dc 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -528,6 +528,10 @@ struct _ConnectionsDockMethodInfoSort { } }; +void ConnectionsDock::_filter_changed(const String &p_text) { + update_tree(); +} + /* * Post-ConnectDialog callback for creating/editing connections. * Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed. @@ -903,6 +907,7 @@ void ConnectionsDock::update_tree() { String name; if (!did_script) { + // Get script signals (including signals from any base scripts). Ref<Script> scr = selectedNode->get_script(); if (scr.is_valid()) { scr->get_script_signal_list(&node_signals2); @@ -928,15 +933,16 @@ void ConnectionsDock::update_tree() { icon = get_theme_icon("Object", "EditorIcons"); } - TreeItem *pitem = nullptr; + TreeItem *section_item = nullptr; + // Create subsections. if (node_signals2.size()) { - pitem = tree->create_item(root); - pitem->set_text(0, name); - pitem->set_icon(0, icon); - pitem->set_selectable(0, false); - pitem->set_editable(0, false); - pitem->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + section_item = tree->create_item(root); + section_item->set_text(0, name); + section_item->set_icon(0, icon); + section_item->set_selectable(0, false); + section_item->set_editable(0, false); + section_item->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); node_signals2.sort(); } @@ -946,6 +952,12 @@ void ConnectionsDock::update_tree() { StringName signal_name = mi.name; String signaldesc = "("; PackedStringArray argnames; + + String filter_text = search_box->get_text(); + if (!filter_text.is_subsequence_ofi(signal_name)) { + continue; + } + if (mi.arguments.size()) { for (int i = 0; i < mi.arguments.size(); i++) { PropertyInfo &pi = mi.arguments[i]; @@ -965,13 +977,14 @@ void ConnectionsDock::update_tree() { } signaldesc += ")"; - TreeItem *item = tree->create_item(pitem); - item->set_text(0, String(signal_name) + signaldesc); + // Create the children of the subsection - the actual list of signals. + TreeItem *signal_item = tree->create_item(section_item); + signal_item->set_text(0, String(signal_name) + signaldesc); Dictionary sinfo; sinfo["name"] = signal_name; sinfo["args"] = argnames; - item->set_metadata(0, sinfo); - item->set_icon(0, get_theme_icon("Signal", "EditorIcons")); + signal_item->set_metadata(0, sinfo); + signal_item->set_icon(0, get_theme_icon("Signal", "EditorIcons")); // Set tooltip with the signal's documentation. { @@ -1007,7 +1020,7 @@ void ConnectionsDock::update_tree() { } // "::" separators used in make_custom_tooltip for formatting. - item->set_tooltip(0, String(signal_name) + "::" + signaldesc + "::" + descr); + signal_item->set_tooltip(0, String(signal_name) + "::" + signaldesc + "::" + descr); } // List existing connections @@ -1044,11 +1057,11 @@ void ConnectionsDock::update_tree() { path += ")"; } - TreeItem *item2 = tree->create_item(item); - item2->set_text(0, path); + TreeItem *connection_item = tree->create_item(signal_item); + connection_item->set_text(0, path); Connection cd = c; - item2->set_metadata(0, cd); - item2->set_icon(0, get_theme_icon("Slot", "EditorIcons")); + connection_item->set_metadata(0, cd); + connection_item->set_icon(0, get_theme_icon("Slot", "EditorIcons")); } } @@ -1069,6 +1082,14 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { VBoxContainer *vbc = this; + search_box = memnew(LineEdit); + search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); + search_box->set_placeholder(TTR("Filter signals")); + search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_clear_button_enabled(true); + search_box->connect("text_changed", callable_mp(this, &ConnectionsDock::_filter_changed)); + vbc->add_child(search_box); + tree = memnew(ConnectionsDockTree); tree->set_columns(1); tree->set_select_mode(Tree::SELECT_ROW); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 9da9a8fb2c..48fdb91f5a 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -169,9 +169,12 @@ class ConnectionsDock : public VBoxContainer { PopupMenu *signal_menu; PopupMenu *slot_menu; UndoRedo *undo_redo; + LineEdit *search_box; Map<StringName, Map<StringName, String>> descr_cache; + void _filter_changed(const String &p_text); + void _make_or_edit_connection(); void _connect(ConnectDialog::ConnectionData cToMake); void _disconnect(TreeItem &item); |