Merge pull request #41116 from EricEzaM/signal-list-filter
Added search box to signals dock.
This commit is contained in:
commit
5100bb42ae
@ -528,6 +528,10 @@ struct _ConnectionsDockMethodInfoSort {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ConnectionsDock::_filter_changed(const String &p_text) {
|
||||||
|
update_tree();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Post-ConnectDialog callback for creating/editing connections.
|
* Post-ConnectDialog callback for creating/editing connections.
|
||||||
* Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
|
* Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
|
||||||
@ -903,6 +907,7 @@ void ConnectionsDock::update_tree() {
|
|||||||
String name;
|
String name;
|
||||||
|
|
||||||
if (!did_script) {
|
if (!did_script) {
|
||||||
|
// Get script signals (including signals from any base scripts).
|
||||||
Ref<Script> scr = selectedNode->get_script();
|
Ref<Script> scr = selectedNode->get_script();
|
||||||
if (scr.is_valid()) {
|
if (scr.is_valid()) {
|
||||||
scr->get_script_signal_list(&node_signals2);
|
scr->get_script_signal_list(&node_signals2);
|
||||||
@ -928,15 +933,16 @@ void ConnectionsDock::update_tree() {
|
|||||||
icon = get_theme_icon("Object", "EditorIcons");
|
icon = get_theme_icon("Object", "EditorIcons");
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeItem *pitem = nullptr;
|
TreeItem *section_item = nullptr;
|
||||||
|
|
||||||
|
// Create subsections.
|
||||||
if (node_signals2.size()) {
|
if (node_signals2.size()) {
|
||||||
pitem = tree->create_item(root);
|
section_item = tree->create_item(root);
|
||||||
pitem->set_text(0, name);
|
section_item->set_text(0, name);
|
||||||
pitem->set_icon(0, icon);
|
section_item->set_icon(0, icon);
|
||||||
pitem->set_selectable(0, false);
|
section_item->set_selectable(0, false);
|
||||||
pitem->set_editable(0, false);
|
section_item->set_editable(0, false);
|
||||||
pitem->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
|
section_item->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
|
||||||
node_signals2.sort();
|
node_signals2.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,6 +952,12 @@ void ConnectionsDock::update_tree() {
|
|||||||
StringName signal_name = mi.name;
|
StringName signal_name = mi.name;
|
||||||
String signaldesc = "(";
|
String signaldesc = "(";
|
||||||
PackedStringArray argnames;
|
PackedStringArray argnames;
|
||||||
|
|
||||||
|
String filter_text = search_box->get_text();
|
||||||
|
if (!filter_text.is_subsequence_ofi(signal_name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (mi.arguments.size()) {
|
if (mi.arguments.size()) {
|
||||||
for (int i = 0; i < mi.arguments.size(); i++) {
|
for (int i = 0; i < mi.arguments.size(); i++) {
|
||||||
PropertyInfo &pi = mi.arguments[i];
|
PropertyInfo &pi = mi.arguments[i];
|
||||||
@ -965,13 +977,14 @@ void ConnectionsDock::update_tree() {
|
|||||||
}
|
}
|
||||||
signaldesc += ")";
|
signaldesc += ")";
|
||||||
|
|
||||||
TreeItem *item = tree->create_item(pitem);
|
// Create the children of the subsection - the actual list of signals.
|
||||||
item->set_text(0, String(signal_name) + signaldesc);
|
TreeItem *signal_item = tree->create_item(section_item);
|
||||||
|
signal_item->set_text(0, String(signal_name) + signaldesc);
|
||||||
Dictionary sinfo;
|
Dictionary sinfo;
|
||||||
sinfo["name"] = signal_name;
|
sinfo["name"] = signal_name;
|
||||||
sinfo["args"] = argnames;
|
sinfo["args"] = argnames;
|
||||||
item->set_metadata(0, sinfo);
|
signal_item->set_metadata(0, sinfo);
|
||||||
item->set_icon(0, get_theme_icon("Signal", "EditorIcons"));
|
signal_item->set_icon(0, get_theme_icon("Signal", "EditorIcons"));
|
||||||
|
|
||||||
// Set tooltip with the signal's documentation.
|
// Set tooltip with the signal's documentation.
|
||||||
{
|
{
|
||||||
@ -1007,7 +1020,7 @@ void ConnectionsDock::update_tree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "::" separators used in make_custom_tooltip for formatting.
|
// "::" 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
|
// List existing connections
|
||||||
@ -1044,11 +1057,11 @@ void ConnectionsDock::update_tree() {
|
|||||||
path += ")";
|
path += ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeItem *item2 = tree->create_item(item);
|
TreeItem *connection_item = tree->create_item(signal_item);
|
||||||
item2->set_text(0, path);
|
connection_item->set_text(0, path);
|
||||||
Connection cd = c;
|
Connection cd = c;
|
||||||
item2->set_metadata(0, cd);
|
connection_item->set_metadata(0, cd);
|
||||||
item2->set_icon(0, get_theme_icon("Slot", "EditorIcons"));
|
connection_item->set_icon(0, get_theme_icon("Slot", "EditorIcons"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,6 +1082,14 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
|
|||||||
|
|
||||||
VBoxContainer *vbc = this;
|
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 = memnew(ConnectionsDockTree);
|
||||||
tree->set_columns(1);
|
tree->set_columns(1);
|
||||||
tree->set_select_mode(Tree::SELECT_ROW);
|
tree->set_select_mode(Tree::SELECT_ROW);
|
||||||
|
@ -169,9 +169,12 @@ class ConnectionsDock : public VBoxContainer {
|
|||||||
PopupMenu *signal_menu;
|
PopupMenu *signal_menu;
|
||||||
PopupMenu *slot_menu;
|
PopupMenu *slot_menu;
|
||||||
UndoRedo *undo_redo;
|
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 _make_or_edit_connection();
|
||||||
void _connect(ConnectDialog::ConnectionData cToMake);
|
void _connect(ConnectDialog::ConnectionData cToMake);
|
||||||
void _disconnect(TreeItem &item);
|
void _disconnect(TreeItem &item);
|
||||||
|
Loading…
Reference in New Issue
Block a user