Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-13 21:10:41 +0300
committerHans Goudey <h.goudey@me.com>2020-10-13 21:10:41 +0300
commit7c633686e99512d33391f30e4602213ed3890802 (patch)
tree5c0b651851d9de7896ea9687d83ed62059f84492 /source/blender/makesrna
parent96dd299055a1ce35819480f3c4b938f8e6f91537 (diff)
Property Search: Find results in all tabs
This patch enables property search for all tabs in the property editor. To make interaction faster, if the editor's current tab doesn't have a result, the current tab changes to the next tab that has a match. This patch implements basic code that only searches panels. While we could run the existing "single tab" property search for every tab, that would also do everything else related to the layout pass, which would be less efficient, and maybe more complicated to maintain. The search match status for every current tab of the property editor is stored in a runtime bitfield and them displayed later by dimming icons in the tab selector panel to the left. Using `BLI_bitmap` properly in the runtime struct required moving it to `buttons_intern.h` and adding a small API to access the search filter instead. To make sure the editor isn't influenced by anything that happens while building the layout for other tabs, most of the context is duplicated and the new search is run in the duplicated editor. Note that the tool settings tab works slightly different than the other tabs, so I've disabled searching it for this commit. That would be a relatively simple improvement, but would just require a bit of refactoring of existing code. Differential Revision: https://developer.blender.org/D8859
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_space.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2a4bc6bae06..5b34281ffa0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1825,6 +1825,53 @@ static void rna_SpaceProperties_context_update(Main *UNUSED(bmain),
}
}
+static int rna_SpaceProperties_tab_search_results_getlength(PointerRNA *ptr,
+ int length[RNA_MAX_ARRAY_DIMENSION])
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
+ const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
+
+ length[0] = tabs_len;
+
+ return length[0];
+}
+
+static void rna_SpaceProperties_tab_search_results_get(PointerRNA *ptr, bool *values)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
+ const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
+
+ for (int i = 0; i < tabs_len; i++) {
+ values[i] = ED_buttons_tab_has_search_result(sbuts, i);
+ }
+}
+
+static void rna_SpaceProperties_search_filter_get(PointerRNA *ptr, char *value)
+{
+ SpaceProperties *sbuts = ptr->data;
+ const char *search_filter = ED_buttons_search_string_get(sbuts);
+
+ strcpy(value, search_filter);
+}
+
+static int rna_SpaceProperties_search_filter_length(PointerRNA *ptr)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ return ED_buttons_search_string_length(sbuts);
+}
+
+static void rna_SpaceProperties_search_filter_set(struct PointerRNA *ptr, const char *value)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ ED_buttons_search_string_set(sbuts, value);
+}
+
static void rna_SpaceProperties_search_filter_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -4514,8 +4561,23 @@ static void rna_def_space_properties(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pin ID", "Use the pinned context");
/* Property search. */
+
+ prop = RNA_def_property(srna, "tab_search_results", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_array(prop, 0); /* Dynamic length, see next line. */
+ RNA_def_property_flag(prop, PROP_DYNAMIC);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, "rna_SpaceProperties_tab_search_results_get", NULL);
+ RNA_def_property_dynamic_array_funcs(prop, "rna_SpaceProperties_tab_search_results_getlength");
+ RNA_def_property_ui_text(
+ prop, "Tab Search Results", "Whether or not each visible tab has a search result");
+
prop = RNA_def_property(srna, "search_filter", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "runtime->search_string");
+ /* The search filter is stored in the property editor's runtime struct which
+ * is only defined in an internal header, so use the getter / setter here. */
+ RNA_def_property_string_funcs(prop,
+ "rna_SpaceProperties_search_filter_get",
+ "rna_SpaceProperties_search_filter_length",
+ "rna_SpaceProperties_search_filter_set");
RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string");
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(