UI: Show "No results found" for empty searches
For menu and operator searches, and for File and Asset Browser filtering, show "No Results Found" when there is nothing to show. Pull Request: https://projects.blender.org/blender/blender/pulls/116201
This commit is contained in:
parent
4f8d584325
commit
13208038da
|
@ -673,6 +673,17 @@ static void ui_searchbox_region_draw_fn(const bContext *C, ARegion *region)
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
rcti rect;
|
||||
ui_searchbox_butrect(&rect, data, 0);
|
||||
ui_draw_menu_item(&data->fstyle,
|
||||
&rect,
|
||||
IFACE_("No results found"),
|
||||
0,
|
||||
0,
|
||||
UI_MENU_ITEM_SEPARATOR_NONE,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_searchbox_region_free_fn(ARegion *region)
|
||||
|
@ -1025,6 +1036,17 @@ static void ui_searchbox_region_draw_cb__operator(const bContext * /*C*/, ARegio
|
|||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rcti rect;
|
||||
ui_searchbox_butrect(&rect, data, 0);
|
||||
ui_draw_menu_item(&data->fstyle,
|
||||
&rect,
|
||||
IFACE_("No results found"),
|
||||
0,
|
||||
0,
|
||||
UI_MENU_ITEM_SEPARATOR_NONE,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ARegion *ui_searchbox_create_operator(bContext *C, ARegion *butregion, uiButSearch *search_but)
|
||||
|
|
|
@ -1166,6 +1166,29 @@ void file_draw_list(const bContext *C, ARegion *region)
|
|||
}
|
||||
}
|
||||
|
||||
if (numfiles == 0) {
|
||||
const rcti tile_draw_rect = tile_draw_rect_get(
|
||||
v2d, layout, eFileDisplayType(params->display), 0, 0);
|
||||
const uiStyle *style = UI_style_get();
|
||||
|
||||
const bool is_filtered = params->filter_search[0] != '\0';
|
||||
|
||||
uchar text_col[4];
|
||||
UI_GetThemeColor4ubv(TH_TEXT, text_col);
|
||||
if (!is_filtered) {
|
||||
text_col[3] /= 2;
|
||||
}
|
||||
|
||||
const char *message = is_filtered ? IFACE_("No results match the search filter") :
|
||||
IFACE_("No items");
|
||||
|
||||
UI_fontstyle_draw_simple(&style->widget,
|
||||
tile_draw_rect.xmin + UI_UNIT_X,
|
||||
tile_draw_rect.ymax - UI_UNIT_Y,
|
||||
message,
|
||||
text_col);
|
||||
}
|
||||
|
||||
BLF_batch_draw_end();
|
||||
|
||||
UI_block_end(C, block);
|
||||
|
|
Loading…
Reference in New Issue