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:
-rw-r--r--release/scripts/startup/bl_ui/space_filebrowser.py29
-rw-r--r--source/blender/blenloader/intern/versioning_300.c16
-rw-r--r--source/blender/editors/asset/ED_asset_type.h3
-rw-r--r--source/blender/editors/asset/intern/asset_type.cc8
-rw-r--r--source/blender/editors/space_file/space_file.c5
-rw-r--r--source/blender/makesrna/intern/rna_space.c52
6 files changed, 105 insertions, 8 deletions
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 420481eec13..62a9343f644 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -54,6 +54,12 @@ class FILEBROWSER_HT_header(Header):
layout.prop(params, "filter_search", text="", icon='VIEWZOOM')
+ layout.popover(
+ panel="ASSETBROWSER_PT_filter",
+ text="",
+ icon='FILTER'
+ )
+
layout.operator(
"screen.region_toggle",
text="",
@@ -592,6 +598,28 @@ class ASSETBROWSER_PT_display(asset_utils.AssetBrowserPanel, Panel):
col.prop(params, "show_details_datetime", text="Date")
+class ASSETBROWSER_PT_filter(asset_utils.AssetBrowserPanel, Panel):
+ bl_region_type = 'HEADER'
+ bl_category = "Filter"
+ bl_label = "Filter"
+
+ def draw(self, context):
+ layout = self.layout
+ space = context.space_data
+ params = space.params
+ use_extended_browser = context.preferences.experimental.use_extended_asset_browser
+
+ if params.use_filter_blendid:
+ col = layout.column(align=True)
+
+ filter_id = params.filter_asset_id
+ for identifier in dir(filter_id):
+ if identifier.startswith("filter_") or (identifier.startswith("experimental_filter_") and use_extended_browser):
+ row = col.row()
+ row.label(icon=filter_id.bl_rna.properties[identifier].icon)
+ row.prop(filter_id, identifier, toggle=False)
+
+
class AssetBrowserMenu:
@classmethod
def poll(cls, context):
@@ -794,6 +822,7 @@ classes = (
FILEBROWSER_MT_select,
FILEBROWSER_MT_context_menu,
ASSETBROWSER_PT_display,
+ ASSETBROWSER_PT_filter,
ASSETBROWSER_MT_editor_menus,
ASSETBROWSER_MT_view,
ASSETBROWSER_MT_select,
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 7d93439a44d..c68bae1d4af 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -2005,6 +2005,22 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 38)) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+ if (space->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)space;
+ FileAssetSelectParams *asset_params = sfile->asset_params;
+ if (asset_params) {
+ asset_params->base_params.filter_id = FILTER_ID_ALL;
+ }
+ }
+ }
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/asset/ED_asset_type.h b/source/blender/editors/asset/ED_asset_type.h
index 1030be1ea05..5629ae189c0 100644
--- a/source/blender/editors/asset/ED_asset_type.h
+++ b/source/blender/editors/asset/ED_asset_type.h
@@ -20,6 +20,8 @@
#pragma once
+#include "DNA_ID.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -27,6 +29,7 @@ extern "C" {
struct ID;
bool ED_asset_type_id_is_non_experimental(const struct ID *id);
+#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS (FILTER_ID_MA | FILTER_ID_AC | FILTER_ID_WO)
/**
* Check if the asset type for \a id (which doesn't need to be an asset right now) can be an asset,
diff --git a/source/blender/editors/asset/intern/asset_type.cc b/source/blender/editors/asset/intern/asset_type.cc
index 5be627e3fbc..cdff538a712 100644
--- a/source/blender/editors/asset/intern/asset_type.cc
+++ b/source/blender/editors/asset/intern/asset_type.cc
@@ -29,13 +29,9 @@
bool ED_asset_type_id_is_non_experimental(const ID *id)
{
/* Remember to update #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING and
- * #asset_type_ids_non_experimental_as_filter_flags() with this! */
+ * #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS() with this! */
return ELEM(GS(id->name), ID_MA, ID_AC, ID_WO);
}
-static int64_t asset_type_ids_non_experimental_as_filter_flags()
-{
- return FILTER_ID_MA | FILTER_ID_AC | FILTER_ID_WO;
-}
bool ED_asset_type_is_supported(const ID *id)
{
@@ -58,5 +54,5 @@ int64_t ED_asset_types_supported_as_filter_flags()
return FILTER_ID_ALL;
}
- return asset_type_ids_non_experimental_as_filter_flags();
+ return ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS;
}
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index b5c395c8bc2..a875b7a2c12 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -328,8 +328,9 @@ static void file_refresh(const bContext *C, ScrArea *area)
}
if (ED_fileselect_is_asset_browser(sfile)) {
- /* Ask the asset code for appropriate ID filter flags for the supported assets. */
- params->filter_id = ED_asset_types_supported_as_filter_flags();
+ /* Ask the asset code for appropriate ID filter flags for the supported assets, and mask others
+ * out. */
+ params->filter_id &= ED_asset_types_supported_as_filter_flags();
}
filelist_settype(sfile->files, params->type);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index cd6a7b64061..c91ef25daa8 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -34,11 +34,14 @@
#include "BKE_node.h"
#include "BKE_studiolight.h"
+#include "ED_asset.h"
#include "ED_spreadsheet.h"
#include "ED_text.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_sys_types.h"
#include "BLI_uuid.h"
#include "DNA_action_types.h"
@@ -2624,6 +2627,11 @@ static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int val
params->asset_library_ref = ED_asset_library_reference_from_enum_value(value);
}
+static PointerRNA rna_FileAssetSelectParams_filter_id_get(PointerRNA *ptr)
+{
+ return rna_pointer_inherit_refine(ptr, &RNA_FileAssetSelectIDFilter, ptr->data);
+}
+
static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr)
{
const FileDirEntry *entry = ptr->data;
@@ -6351,6 +6359,40 @@ static void rna_def_fileselect_idfilter(BlenderRNA *brna)
}
}
+/* Filter for datablock types in the Asset Browser. */
+static void rna_def_fileselect_asset_idfilter(BlenderRNA *brna)
+{
+ StructRNA *srna = RNA_def_struct(brna, "FileAssetSelectIDFilter", NULL);
+ RNA_def_struct_sdna(srna, "FileSelectParams");
+ RNA_def_struct_nested(brna, srna, "FileSelectParams");
+ RNA_def_struct_ui_text(srna,
+ "File Select Asset Filter",
+ "Which asset types to show/hide, when browsing an asset library");
+
+ static char experimental_prop_names[INDEX_ID_MAX][MAX_NAME];
+
+ for (uint i = 0; rna_enum_id_type_filter_items[i].identifier; i++) {
+ const struct IDFilterEnumPropertyItem *item = &rna_enum_id_type_filter_items[i];
+ const bool is_experimental = (ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS & item->flag) == 0;
+
+ const char *identifier = rna_enum_id_type_filter_items[i].identifier;
+ if (is_experimental) {
+ /* Create name for experimental property and store in static buffer. */
+ snprintf(experimental_prop_names[i],
+ ARRAY_SIZE(experimental_prop_names[i]),
+ "experimental_%s",
+ identifier);
+ identifier = experimental_prop_names[i];
+ }
+
+ PropertyRNA *prop = RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "filter_id", item->flag);
+ RNA_def_property_ui_text(prop, item->name, item->description);
+ RNA_def_property_ui_icon(prop, item->icon, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
+}
+
static void rna_def_fileselect_entry(BlenderRNA *brna)
{
PropertyRNA *prop;
@@ -6673,6 +6715,15 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Catalog UUID", "The UUID of the catalog shown in the browser");
+ prop = RNA_def_property(srna, "filter_asset_id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_struct_type(prop, "FileAssetSelectIDFilter");
+ RNA_def_property_pointer_funcs(
+ prop, "rna_FileAssetSelectParams_filter_id_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "Filter Asset Types",
+ "Which asset types to show/hide, when browsing an asset library");
+
prop = RNA_def_property(srna, "import_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, asset_import_type_items);
RNA_def_property_ui_text(prop, "Import Type", "Determine how the asset will be imported");
@@ -7880,6 +7931,7 @@ void RNA_def_space(BlenderRNA *brna)
rna_def_fileselect_params(brna);
rna_def_fileselect_asset_params(brna);
rna_def_fileselect_idfilter(brna);
+ rna_def_fileselect_asset_idfilter(brna);
rna_def_filemenu_entry(brna);
rna_def_space_filebrowser(brna);
rna_def_space_outliner(brna);