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:
authorJulian Eisel <julian@blender.org>2020-12-16 18:10:53 +0300
committerJulian Eisel <julian@blender.org>2020-12-16 18:38:56 +0300
commit5c5550f7b821cb6c67009682fec85ce0929474a3 (patch)
tree21b2eceebe2627fa79e3a85bae113693ff1838fb
parent7ed69bd672555f6bbedc598aacda56efb6eeafbb (diff)
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.
-rw-r--r--source/blender/editors/include/ED_fileselect.h2
-rw-r--r--source/blender/editors/space_file/filelist.c10
-rw-r--r--source/blender/makesrna/intern/rna_space.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 6c66a6162b8..7b240e0569f 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -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);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 8202a87864d..d66219c7549 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -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)
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7405bc541c9..2f821dad811 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -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)