Asset Browser: For assets without preview, show type icon in sidebar
Otherwise it would just show empty space where the icon is supposed to be. Unfortunately this icon is upscaled quite a bit and doesn't look too great. Would be good to improve but not a high priority.
This commit is contained in:
parent
7ed69bd672
commit
5c5550f7b8
|
@ -30,6 +30,7 @@ extern "C" {
|
|||
struct ARegion;
|
||||
struct FileAssetSelectParams;
|
||||
struct FileSelectParams;
|
||||
struct FileDirEntry;
|
||||
struct Scene;
|
||||
struct ScrArea;
|
||||
struct SpaceFile;
|
||||
|
@ -154,6 +155,7 @@ struct ScrArea *ED_fileselect_handler_area_find(const struct wmWindow *win,
|
|||
|
||||
int ED_path_extension_type(const char *path);
|
||||
int ED_file_extension_icon(const char *path);
|
||||
int ED_file_icon(const struct FileDirEntry *file);
|
||||
|
||||
void ED_file_read_bookmarks(void);
|
||||
|
||||
|
|
|
@ -1178,7 +1178,7 @@ ImBuf *filelist_geticon_image(struct FileList *filelist, const int index)
|
|||
return filelist_geticon_image_ex(file);
|
||||
}
|
||||
|
||||
static int filelist_geticon_ex(FileDirEntry *file,
|
||||
static int filelist_geticon_ex(const FileDirEntry *file,
|
||||
const char *root,
|
||||
const bool is_main,
|
||||
const bool ignore_libdir)
|
||||
|
@ -1217,7 +1217,7 @@ static int filelist_geticon_ex(FileDirEntry *file,
|
|||
if (file->redirection_path) {
|
||||
target = file->redirection_path;
|
||||
}
|
||||
else {
|
||||
else if (root) {
|
||||
BLI_join_dirfile(fullpath, sizeof(fullpath), root, file->relpath);
|
||||
BLI_path_slash_ensure(fullpath);
|
||||
}
|
||||
|
@ -1301,6 +1301,12 @@ int filelist_geticon(struct FileList *filelist, const int index, const bool is_m
|
|||
return filelist_geticon_ex(file, filelist->filelist.root, is_main, false);
|
||||
}
|
||||
|
||||
int ED_file_icon(const FileDirEntry *file)
|
||||
{
|
||||
return file->preview_icon_id ? file->preview_icon_id :
|
||||
filelist_geticon_ex(file, NULL, false, false);
|
||||
}
|
||||
|
||||
/* ********** Main ********** */
|
||||
|
||||
static void parent_dir_until_exists_or_default_root(char *dir)
|
||||
|
|
|
@ -2602,7 +2602,7 @@ static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr)
|
|||
static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr)
|
||||
{
|
||||
const FileDirEntry *entry = ptr->data;
|
||||
return entry->preview_icon_id;
|
||||
return ED_file_icon(entry);
|
||||
}
|
||||
|
||||
static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr)
|
||||
|
|
Loading…
Reference in New Issue