Fix: UI: Invert button doesn't work for some UIList instances

invert button doesn't work quite well when `filter_items()` is used in
UIList (eg. workspace, attributes list). First issue is, when search
string is empty and invert button is pressed, none item is shown. Now
fixed with extra condition of `filter_byname[0]`. Another issue is when
search string is non-empty then invert button should show elements that
doens't match with the string but it doesn't work. This occurs due to
filtering elements twice. First inside
`filter_items_by_name(reverse=true)` then `UI_list_item_index_is_filtered_visible`.
Remove `UILST_FLT_EXCLUDE` so only once the items are filtered with
invert condition.

Noticed this during !138756

Pull Request: https://projects.blender.org/blender/blender/pulls/138761
This commit is contained in:
Pratik Borhade
2025-05-16 16:44:45 +02:00
committed by Pratik Borhade
parent 6b5521d49f
commit 52b8eba9eb

View File

@@ -313,8 +313,12 @@ bool UI_list_item_index_is_filtered_visible(const uiList *ui_list, const int ite
return false;
}
const int filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
return (dyn_data->items_filter_flags[item_idx] & UILST_FLT_ITEM) ^ filter_exclude;
if (ui_list->filter_byname[0] == '\0') {
/* Show all elements when search string is empty. */
return true;
}
return (dyn_data->items_filter_flags[item_idx] & UILST_FLT_ITEM);
}
/**