[Bf-blender-cvs] [5c5550f7b82] master: Asset Browser: For assets without preview, show type icon in sidebar

Julian Eisel noreply at git.blender.org
Wed Dec 16 16:39:01 CET 2020


Commit: 5c5550f7b821cb6c67009682fec85ce0929474a3
Author: Julian Eisel
Date:   Wed Dec 16 16:10:53 2020 +0100
Branches: master
https://developer.blender.org/rB5c5550f7b821cb6c67009682fec85ce0929474a3

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.

===================================================================

M	source/blender/editors/include/ED_fileselect.h
M	source/blender/editors/space_file/filelist.c
M	source/blender/makesrna/intern/rna_space.c

===================================================================

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)



More information about the Bf-blender-cvs mailing list