Improve inspector filtering
This commit is contained in:
parent
5d806b435b
commit
7bdca99d51
|
@ -43,6 +43,20 @@
|
||||||
#include "scene/property_utils.h"
|
#include "scene/property_utils.h"
|
||||||
#include "scene/resources/packed_scene.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_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Size2 EditorProperty::get_minimum_size() const {
|
Size2 EditorProperty::get_minimum_size() const {
|
||||||
Size2 ms;
|
Size2 ms;
|
||||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
|
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
|
||||||
|
@ -2657,15 +2671,14 @@ void EditorInspector::update_tree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the property label's string.
|
// Get the property label's string.
|
||||||
String property_label_string = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path;
|
String name_override = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path;
|
||||||
|
String property_label_string = name_override;
|
||||||
if (capitalize_paths) {
|
if (capitalize_paths) {
|
||||||
// Capitalize paths.
|
// Capitalize paths.
|
||||||
int dot = property_label_string.find(".");
|
int dot = property_label_string.find(".");
|
||||||
if (dot != -1) {
|
if (dot != -1) {
|
||||||
String ov = property_label_string.substr(dot);
|
name_override = name_override.substr(0, dot);
|
||||||
property_label_string = property_label_string.substr(0, dot);
|
property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override) + property_label_string.substr(dot);
|
||||||
property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string);
|
|
||||||
property_label_string += ov;
|
|
||||||
} else {
|
} else {
|
||||||
property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string);
|
property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string);
|
||||||
}
|
}
|
||||||
|
@ -2681,7 +2694,8 @@ void EditorInspector::update_tree() {
|
||||||
|
|
||||||
// Ignore properties that do not fit the filter.
|
// Ignore properties that do not fit the filter.
|
||||||
if (use_filter && !filter.is_empty()) {
|
if (use_filter && !filter.is_empty()) {
|
||||||
if (!filter.is_subsequence_ofn(path) && !filter.is_subsequence_ofn(property_label_string) && !property_prefix.to_lower().contains(filter.to_lower())) {
|
const String property_path = property_prefix + (path.is_empty() ? "" : path + "/") + name_override;
|
||||||
|
if (!_property_path_matches(property_path, filter)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,20 @@
|
||||||
#include "editor/editor_property_name_processor.h"
|
#include "editor/editor_property_name_processor.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/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_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
class SectionedInspectorFilter : public Object {
|
class SectionedInspectorFilter : public Object {
|
||||||
GDCLASS(SectionedInspectorFilter, Object);
|
GDCLASS(SectionedInspectorFilter, Object);
|
||||||
|
|
||||||
|
@ -232,7 +246,7 @@ void SectionedInspector::update_category_list() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter.is_empty() && pi.name.findn(filter) == -1 && pi.name.replace("/", " ").capitalize().findn(filter) == -1) {
|
if (!filter.is_empty() && !_property_path_matches(pi.name, filter)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,6 +617,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
||||||
general_settings_inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
|
general_settings_inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
|
||||||
general_settings_inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
general_settings_inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
general_settings_inspector->register_search_box(search_box);
|
general_settings_inspector->register_search_box(search_box);
|
||||||
|
general_settings_inspector->get_inspector()->set_use_filter(true);
|
||||||
general_settings_inspector->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected));
|
general_settings_inspector->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected));
|
||||||
general_settings_inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited));
|
general_settings_inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited));
|
||||||
general_settings_inspector->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
|
general_settings_inspector->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
|
||||||
|
|
Loading…
Reference in New Issue