Merge pull request #59164 from timothyqiu/filter-property-3.x

This commit is contained in:
Rémi Verschelde 2022-03-17 19:19:16 +01:00 committed by GitHub
commit cdbc819b85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 14 deletions

View file

@ -43,6 +43,20 @@
#include "scene/property_utils.h"
#include "scene/resources/packed_scene.h"
static bool _property_path_matches(const String &p_property_path, const String &p_filter) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}
const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) {
return true;
}
}
return false;
}
Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
Ref<Font> font = get_font("font", "Tree");
@ -1547,15 +1561,13 @@ void EditorInspector::update_tree() {
}
String name = (basename.find("/") != -1) ? basename.right(basename.rfind("/") + 1) : basename;
String name_override = name;
if (capitalize_paths) {
int dot = name.find(".");
if (dot != -1) {
String ov = name.right(dot);
name = name.substr(0, dot);
name = EditorPropertyNameProcessor::get_singleton()->process_name(name);
name += ov;
name_override = name.substr(0, dot);
name = EditorPropertyNameProcessor::get_singleton()->process_name(name_override) + name.right(dot);
} else {
name = EditorPropertyNameProcessor::get_singleton()->process_name(name);
}
@ -1563,14 +1575,9 @@ void EditorInspector::update_tree() {
String path = basename.left(basename.rfind("/"));
if (use_filter && filter != "") {
String cat = path;
if (capitalize_paths) {
cat = EditorPropertyNameProcessor::get_singleton()->process_name(cat);
}
if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name) && property_prefix.to_lower().find(filter.to_lower()) == -1) {
if (use_filter && !filter.empty()) {
const String property_path = property_prefix + (path.empty() ? "" : path + "/") + name_override;
if (!_property_path_matches(property_path, filter)) {
continue;
}
}

View file

@ -33,6 +33,20 @@
#include "editor_property_name_processor.h"
#include "editor_scale.h"
static bool _property_path_matches(const String &p_property_path, const String &p_filter) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}
const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) {
return true;
}
}
return false;
}
class SectionedInspectorFilter : public Object {
GDCLASS(SectionedInspectorFilter, Object);
@ -242,7 +256,7 @@ void SectionedInspector::update_category_list() {
continue;
}
if (!filter.empty() && pi.name.findn(filter) == -1 && pi.name.replace("/", " ").capitalize().findn(filter) == -1) {
if (!filter.empty() && !_property_path_matches(pi.name, filter)) {
continue;
}