[Bf-blender-cvs] [0cad3b7f81d] asset-browser: Add list of asset categories to the left sidebar
Julian Eisel
noreply at git.blender.org
Tue Aug 25 03:02:18 CEST 2020
Commit: 0cad3b7f81d5c6033e9f202265c0fc0f0ee4449f
Author: Julian Eisel
Date: Tue Aug 25 02:29:45 2020 +0200
Branches: asset-browser
https://developer.blender.org/rB0cad3b7f81d5c6033e9f202265c0fc0f0ee4449f
Add list of asset categories to the left sidebar
The categories are the same you can find in the File Browser filter popup:
Scenes, animations, object & collections, geometry, shading, images & sounds,
environments and miscellaneous.
And again, all of this is more of a prototype, things will change a lot still.
===================================================================
M release/scripts/startup/bl_ui/space_filebrowser.py
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_file/filesel.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index da8972c2661..f8ff44fbb90 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -176,6 +176,28 @@ def panel_poll_is_asset_browsing(context):
return context.space_data.browse_mode == 'ASSETS'
+class FILEBROWSER_PT_asset_navigation_bar(Panel):
+ bl_label = "Asset Navigation"
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'TOOLS'
+ bl_options = {'HIDE_HEADER'}
+
+ @classmethod
+ def poll(cls, context):
+ return panel_poll_is_asset_browsing(context)
+
+ def draw(self, context):
+ layout = self.layout
+
+ space_file = context.space_data
+
+ col = layout.column()
+
+ col.scale_x = 1.3
+ col.scale_y = 1.3
+ col.prop(space_file.params, "asset_category", expand=True)
+
+
class FILEBROWSER_UL_dir(UIList):
def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
direntry = item
@@ -514,6 +536,7 @@ classes = (
FILEBROWSER_HT_header,
FILEBROWSER_PT_display,
FILEBROWSER_PT_filter,
+ FILEBROWSER_PT_asset_navigation_bar,
FILEBROWSER_UL_dir,
FILEBROWSER_PT_bookmarks_volumes,
FILEBROWSER_PT_bookmarks_system,
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 94a2320ff3b..feea129cc69 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2580,7 +2580,7 @@ static int filelist_readjob_list_dir(const char *root,
static int filelist_readjob_list_lib(const char *root, ListBase *entries, const bool skip_currpar)
{
FileListInternEntry *entry;
- LinkNode *ln, *names, *datablock_infos = NULL;
+ LinkNode *ln, *names = NULL, *datablock_infos = NULL;
int i, nitems, idcode = 0, nbr_entries = 0;
char dir[FILE_MAX_LIBEXTRA], *group;
bool ok;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index b2bf8711eef..b424f786405 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -311,17 +311,27 @@ short ED_fileselect_set_params(SpaceFile *sfile)
if (doc_path) {
const char *asset_blend_name = "assets.blend";
- const char *id_group_name = BKE_idtype_idcode_to_name(ID_OB);
+ // const char *id_group_name = BKE_idtype_idcode_to_name(ID_OB);
BLI_join_dirfile(params->dir, sizeof(params->dir), doc_path, asset_blend_name);
- BLI_path_join(
- params->dir, sizeof(params->dir), doc_path, asset_blend_name, id_group_name, NULL);
+ // BLI_path_join(
+ // params->dir, sizeof(params->dir), doc_path, asset_blend_name, id_group_name,
+ // NULL);
params->file[0] = '\0';
}
params->type = FILE_LOADLIB;
- params->flag |= FILE_ASSETS_ONLY;
+ /* TODO this way of using filters to realize categories is noticably slower than
+ * specifying a "group" to read. That's because all types are read and filtering is applied
+ * after the fact. */
+ params->flag |= FILE_ASSETS_ONLY | FILE_FILTER;
+ params->filter |= FILE_TYPE_BLENDERLIB;
+ params->filter_id = FILTER_ID_OB | FILTER_ID_GR;
params->display = FILE_IMGDISPLAY;
+ params->recursion_level = 1;
+ /* 'SMALL' size by default. More reasonable since this is typically used as regular editor,
+ * space is more of an issue here. */
+ params->thumbnail_size = 96;
}
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d9632ea5bf0..1ba902415a4 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2368,6 +2368,18 @@ static PointerRNA rna_FileSelectParams_filter_id_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_FileSelectIDFilter, ptr->data);
}
+static void rna_FileSelectParams_asset_category_set(PointerRNA *ptr, uint64_t value)
+{
+ FileSelectParams *params = ptr->data;
+ params->filter_id = value;
+}
+
+static uint64_t rna_FileSelectParams_asset_category_get(PointerRNA *ptr)
+{
+ FileSelectParams *params = ptr->data;
+ return params->filter_id;
+}
+
static void rna_FileBrowser_FSMenuEntry_path_get(PointerRNA *ptr, char *value)
{
char *path = ED_fsmenu_entry_get_path(ptr->data);
@@ -5637,6 +5649,47 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ /* XXX copied from rna_def_fileselect_idfilter. */
+ static const EnumPropertyItem asset_category_items[] = {
+ {FILTER_ID_SCE, "SCENES", ICON_SCENE_DATA, "Scenes", "Show scenes"},
+ {FILTER_ID_AC, "ANIMATIONS", ICON_ANIM_DATA, "Animations", "Show animation data"},
+ {FILTER_ID_OB | FILTER_ID_GR,
+ "OBJECTS_AND_COLLECTIONS",
+ ICON_GROUP,
+ "Objects & Collections",
+ "Show objects and collections"},
+ {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME
+ /* XXX avoid warning */
+ // | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO
+ ,
+ "GEOMETRY",
+ ICON_MESH_DATA,
+ "Geometry",
+ "Show meshes, curves, lattice, armatures and metaballs data"},
+ {FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE,
+ "SHADING",
+ ICON_MATERIAL_DATA,
+ "Shading",
+ "Show materials, nodetrees, textures and Freestyle's linestyles"},
+ {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
+ "IMAGES_AND_SOUNDS",
+ ICON_IMAGE_DATA,
+ "Images & Sounds",
+ "Show images, movie clips, sounds and masks"},
+ {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_LP | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS,
+ "ENVIRONMENTS",
+ ICON_WORLD_DATA,
+ "Environment",
+ "Show worlds, lights, cameras and speakers"},
+ {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT |
+ FILTER_ID_VF | FILTER_ID_CF,
+ "MISC",
+ ICON_GREASEPENCIL,
+ "Miscellaneous",
+ "Show other data types"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "FileSelectParams", NULL);
RNA_def_struct_path_func(srna, "rna_FileSelectParams_path");
RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters");
@@ -5808,6 +5861,15 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
+ prop = RNA_def_property(srna, "asset_category", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, asset_category_items);
+ RNA_def_property_enum_funcs(prop,
+ "rna_FileSelectParams_asset_category_get",
+ "rna_FileSelectParams_asset_category_set",
+ NULL);
+ RNA_def_property_ui_text(prop, "Asset Category", "Determine which kind of assets to display");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
+
prop = RNA_def_property(srna, "display_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "thumbnail_size");
RNA_def_property_enum_items(prop, display_size_items);
More information about the Bf-blender-cvs
mailing list