Assets: Rename "Import Type" to "Import Method" in code/BPY

It was already called that way in the UI, since it's referring to a
behavior, not a type. Update the code to match that. Note that this is
a BPY compatibility breaking change for 4.0.
This commit is contained in:
Julian Eisel
2023-09-26 16:20:49 +02:00
parent 395f279166
commit ca2a8be15f
11 changed files with 25 additions and 24 deletions

View File

@@ -25,7 +25,7 @@ class FILEBROWSER_HT_header(Header):
layout.separator_spacer()
if params.asset_library_reference not in {'LOCAL', 'ESSENTIALS'}:
layout.prop(params, "import_type", text="")
layout.prop(params, "import_method", text="")
layout.separator_spacer()

View File

@@ -2476,14 +2476,14 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
}
FOREACH_NODETREE_END;
if (!DNA_struct_member_exists(fd->filesdna, "FileAssetSelectParams", "short", "import_type")) {
if (!DNA_struct_member_exists(fd->filesdna, "FileAssetSelectParams", "short", "import_method")) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
if (sfile->asset_params) {
sfile->asset_params->import_type = FILE_ASSET_IMPORT_APPEND;
sfile->asset_params->import_method = FILE_ASSET_IMPORT_APPEND;
}
}
}
@@ -3035,9 +3035,9 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
FILE_PARAMS_FLAG_UNUSED_3 | FILE_PATH_TOKENS_ALLOW);
}
/* New default import type: Append with reuse. */
/* New default import method: Append with reuse. */
if (sfile->asset_params) {
sfile->asset_params->import_type = FILE_ASSET_IMPORT_APPEND_REUSE;
sfile->asset_params->import_method = FILE_ASSET_IMPORT_APPEND_REUSE;
}
break;
}
@@ -4324,8 +4324,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
/* When an asset browser uses the default import method, make it follow the new
* preference setting. This means no effective default behavior change. */
if (sfile->asset_params->import_type == FILE_ASSET_IMPORT_APPEND_REUSE) {
sfile->asset_params->import_type = FILE_ASSET_IMPORT_FOLLOW_PREFS;
if (sfile->asset_params->import_method == FILE_ASSET_IMPORT_APPEND_REUSE) {
sfile->asset_params->import_method = FILE_ASSET_IMPORT_FOLLOW_PREFS;
}
}
}

View File

@@ -1872,7 +1872,7 @@ void UI_but_drag_attach_image(uiBut *but, const ImBuf *imb, float scale);
*/
void UI_but_drag_set_asset(uiBut *but,
const blender::asset_system::AssetRepresentation *asset,
int import_type, /* eAssetImportType */
int import_method, /* eAssetImportMethod */
int icon,
const ImBuf *imb,
float scale);

View File

@@ -31,12 +31,12 @@ void UI_but_drag_attach_image(uiBut *but, const ImBuf *imb, const float scale)
void UI_but_drag_set_asset(uiBut *but,
const blender::asset_system::AssetRepresentation *asset,
int import_type,
int import_method,
int icon,
const ImBuf *imb,
float scale)
{
wmDragAsset *asset_drag = WM_drag_create_asset_data(asset, import_type);
wmDragAsset *asset_drag = WM_drag_create_asset_data(asset, import_method);
but->dragtype = WM_DRAG_ASSET;
ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */

View File

@@ -110,7 +110,7 @@ static void fileselect_ensure_updated_asset_params(SpaceFile *sfile)
asset_params->base_params.details_flags = U_default.file_space_data.details_flags;
asset_params->asset_library_ref.type = ASSET_LIBRARY_ALL;
asset_params->asset_library_ref.custom_library_index = -1;
asset_params->import_type = FILE_ASSET_IMPORT_FOLLOW_PREFS;
asset_params->import_method = FILE_ASSET_IMPORT_FOLLOW_PREFS;
}
FileSelectParams *base_params = &asset_params->base_params;
@@ -519,12 +519,12 @@ int ED_fileselect_asset_import_method_get(const SpaceFile *sfile, const FileDirE
const FileAssetSelectParams *params = ED_fileselect_get_asset_params(sfile);
if (params->import_type == FILE_ASSET_IMPORT_FOLLOW_PREFS) {
if (params->import_method == FILE_ASSET_IMPORT_FOLLOW_PREFS) {
std::optional import_method = file->asset->get_import_method();
return import_method ? *import_method : -1;
}
switch (eFileAssetImportType(params->import_type)) {
switch (eFileAssetImportMethod(params->import_method)) {
case FILE_ASSET_IMPORT_LINK:
return ASSET_IMPORT_LINK;
case FILE_ASSET_IMPORT_APPEND:

View File

@@ -846,11 +846,11 @@ typedef struct FileAssetSelectParams {
* catalog to show. */
bUUID catalog_id;
short import_type; /* eFileAssetImportType */
short import_method; /* eFileAssetImportMethod */
char _pad2[6];
} FileAssetSelectParams;
typedef enum eFileAssetImportType {
typedef enum eFileAssetImportMethod {
/** Regular data-block linking. */
FILE_ASSET_IMPORT_LINK = 0,
/** Regular data-block appending (basically linking + "Make Local"). */
@@ -861,7 +861,7 @@ typedef enum eFileAssetImportType {
FILE_ASSET_IMPORT_APPEND_REUSE = 2,
/** Default: Follow the preference setting for this asset library. */
FILE_ASSET_IMPORT_FOLLOW_PREFS = 3,
} eFileAssetImportType;
} eFileAssetImportMethod;
/**
* A wrapper to store previous and next folder lists (#FolderList) for a specific browse mode

View File

@@ -76,6 +76,7 @@ DNA_STRUCT_RENAME_ELEM(Editing, over_border, overlay_frame_rect)
DNA_STRUCT_RENAME_ELEM(Editing, over_cfra, overlay_frame_abs)
DNA_STRUCT_RENAME_ELEM(Editing, over_flag, overlay_frame_flag)
DNA_STRUCT_RENAME_ELEM(Editing, over_ofs, overlay_frame_ofs)
DNA_STRUCT_RENAME_ELEM(FileAssetSelectParams, import_type, import_method)
DNA_STRUCT_RENAME_ELEM(FileGlobal, filename, filepath)
DNA_STRUCT_RENAME_ELEM(FluidDomainSettings, cache_frame_pause_guiding, cache_frame_pause_guide)
DNA_STRUCT_RENAME_ELEM(FluidDomainSettings, guiding_alpha, guide_alpha)

View File

@@ -6945,7 +6945,7 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static const EnumPropertyItem asset_import_type_items[] = {
static const EnumPropertyItem asset_import_method_items[] = {
{FILE_ASSET_IMPORT_FOLLOW_PREFS,
"FOLLOW_PREFS",
0,
@@ -6996,11 +6996,11 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
"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);
prop = RNA_def_property(srna, "import_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, asset_import_method_items);
RNA_def_property_ui_text(prop, "Import Method", "Determine how the asset will be imported");
/* Asset drag info saved by buttons stores the import method, so the space must redraw when
* import type changes. */
* import method changes. */
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}

View File

@@ -1369,7 +1369,7 @@ bool WM_drag_is_ID_type(const wmDrag *drag, int idcode);
* \note Does not store \a asset in any way, so it's fine to pass a temporary.
*/
wmDragAsset *WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset,
int /* #eAssetImportMethod */ import_type);
int /* #eAssetImportMethod */ import_method);
wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode);
AssetMetaData *WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode);

View File

@@ -1117,7 +1117,7 @@ struct wmDragID {
};
struct wmDragAsset {
int import_method; /* eAssetImportType */
int import_method; /* eAssetImportMethod */
const AssetRepresentationHandle *asset;
};

View File

@@ -568,12 +568,12 @@ bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
}
wmDragAsset *WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset,
int import_type)
int import_method)
{
wmDragAsset *asset_drag = MEM_new<wmDragAsset>(__func__);
asset_drag->asset = asset;
asset_drag->import_method = import_type;
asset_drag->import_method = import_method;
return asset_drag;
}