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
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')
-rw-r--r--source/blender/editors/include/UI_interface.h3
-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
-rw-r--r--source/blender/editors/screen/area.c7
5 files changed, 14 insertions, 25 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7628d8a37c6..c5acb2c1d25 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -676,7 +676,6 @@ char UI_block_emboss_get(uiBlock *block);
void UI_block_emboss_set(uiBlock *block, char emboss);
bool UI_block_is_search_only(const uiBlock *block);
void UI_block_set_search_only(uiBlock *block, bool search_only);
-void UI_block_set_search_filter(uiBlock *block, const char *search_filter);
void UI_block_free(const struct bContext *C, uiBlock *block);
void UI_blocklist_free(const struct bContext *C, struct ListBase *lb);
@@ -1870,7 +1869,7 @@ uiLayout *UI_block_layout(uiBlock *block,
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
-bool UI_block_apply_search_filter(uiBlock *block);
+bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter);
void UI_region_message_subscribe(struct ARegion *region, struct wmMsgBus *mbus);
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);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index f06633c1c92..2e9f297b705 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2607,7 +2607,6 @@ static void ed_panel_draw(const bContext *C,
strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN);
}
uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS);
- UI_block_set_search_filter(block, search_filter);
UI_block_set_search_only(block, search_only);
bool open;
@@ -2634,7 +2633,7 @@ static void ed_panel_draw(const bContext *C,
pt->draw_header_preset(C, panel);
- UI_block_apply_search_filter(block);
+ UI_block_apply_search_filter(block, search_filter);
UI_block_layout_resolve(block, &xco, &yco);
UI_block_translate(block, headerend - xco, 0);
panel->layout = NULL;
@@ -2666,7 +2665,7 @@ static void ed_panel_draw(const bContext *C,
pt->draw_header(C, panel);
- UI_block_apply_search_filter(block);
+ UI_block_apply_search_filter(block, search_filter);
UI_block_layout_resolve(block, &xco, &yco);
panel->labelofs = xco - labelx;
panel->layout = NULL;
@@ -2703,7 +2702,7 @@ static void ed_panel_draw(const bContext *C,
pt->draw(C, panel);
- UI_block_apply_search_filter(block);
+ UI_block_apply_search_filter(block, search_filter);
UI_block_layout_resolve(block, &xco, &yco);
panel->layout = NULL;