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-09-24 19:22:30 +0300
committerHans Goudey <h.goudey@me.com>2020-09-24 19:22:30 +0300
commit7fb0cb2b9320a1751779b5906c68a7cffdbcd71e (patch)
treebafcac83b277844f1794debefbce57620cda8482 /source/blender/editors/interface
parentbdbe95578d54971d9e0c4957bdc3367ebae44363 (diff)
Cleanup: Remove unecessary storage of search filter in uiBlock
Since the search is applied all in one phase, there is no need to store a reference to the search filter in every uiBlock. Instead just pass it as an argument to UI_block_apply_search_filter.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c5
-rw-r--r--source/blender/editors/interface/interface_intern.h6
-rw-r--r--source/blender/editors/interface/interface_layout.c18
3 files changed, 10 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index f0d19c38537..433058260f7 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3594,11 +3594,6 @@ void UI_block_set_search_only(uiBlock *block, bool search_only)
SET_FLAG_FROM_TEST(block->flag, search_only, UI_BLOCK_SEARCH_ONLY);
}
-void UI_block_set_search_filter(uiBlock *block, const char *search_filter)
-{
- block->search_filter = search_filter;
-}
-
static void ui_but_build_drawstr_float(uiBut *but, double value)
{
size_t slen = 0;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 766c8f95565..0c49489ab4e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -524,12 +524,6 @@ struct uiBlock {
*/
char display_device[64];
- /**
- * Pointer to the space's property search string.
- * The block doesn't allocate this or change it.
- */
- const char *search_filter;
-
struct PieMenuData pie_data;
};
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 2574279f0cd..23f29760a5e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -5161,10 +5161,10 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only)
/* Disabled for performance reasons, but this could be turned on in the future. */
// #define PROPERTY_SEARCH_USE_TOOLTIPS
-static bool block_search_panel_label_matches(const uiBlock *block)
+static bool block_search_panel_label_matches(const uiBlock *block, const char *search_string)
{
if ((block->panel != NULL) && (block->panel->type != NULL)) {
- if (BLI_strcasestr(block->panel->type->label, block->search_filter)) {
+ if (BLI_strcasestr(block->panel->type->label, search_string)) {
return true;
}
}
@@ -5294,12 +5294,12 @@ static bool button_group_has_search_match(uiButtonGroup *button_group, const cha
*
* \return True if the block has any search results.
*/
-static bool block_search_filter_tag_buttons(uiBlock *block)
+static bool block_search_filter_tag_buttons(uiBlock *block, const char *search_filter)
{
bool has_result = false;
LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) {
LISTBASE_FOREACH (uiButtonGroup *, button_group, &root->button_groups) {
- if (button_group_has_search_match(button_group, block->search_filter)) {
+ if (button_group_has_search_match(button_group, search_filter)) {
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
uiBut *but = link->data;
but->flag |= UI_SEARCH_FILTER_MATCHES;
@@ -5325,15 +5325,17 @@ static void block_search_deactivate_buttons(uiBlock *block)
*
* \note Must not be run after #UI_block_layout_resolve.
*/
-bool UI_block_apply_search_filter(uiBlock *block)
+bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter)
{
- if (!(block->search_filter && block->search_filter[0])) {
+ if (search_filter == NULL || search_filter[0] == '\0') {
return false;
}
- const bool panel_label_matches = block_search_panel_label_matches(block);
+ const bool panel_label_matches = block_search_panel_label_matches(block, search_filter);
- const bool has_result = panel_label_matches ? true : block_search_filter_tag_buttons(block);
+ const bool has_result = (panel_label_matches) ?
+ true :
+ block_search_filter_tag_buttons(block, search_filter);
block_search_remove_search_only_roots(block);