From ca2a8be15fef453bacc03be3eba66d7ca837f15d Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 26 Sep 2023 16:20:49 +0200 Subject: [PATCH] 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. --- scripts/startup/bl_ui/space_filebrowser.py | 2 +- source/blender/blenloader/intern/versioning_300.cc | 12 ++++++------ source/blender/editors/include/UI_interface_c.hh | 2 +- source/blender/editors/interface/interface_drag.cc | 4 ++-- source/blender/editors/space_file/filesel.cc | 6 +++--- source/blender/makesdna/DNA_space_types.h | 6 +++--- source/blender/makesdna/intern/dna_rename_defs.h | 1 + source/blender/makesrna/intern/rna_space.cc | 8 ++++---- source/blender/windowmanager/WM_api.hh | 2 +- source/blender/windowmanager/WM_types.hh | 2 +- source/blender/windowmanager/intern/wm_dragdrop.cc | 4 ++-- 11 files changed, 25 insertions(+), 24 deletions(-) diff --git a/scripts/startup/bl_ui/space_filebrowser.py b/scripts/startup/bl_ui/space_filebrowser.py index 5dc3ab4e73a..4a834fa662e 100644 --- a/scripts/startup/bl_ui/space_filebrowser.py +++ b/scripts/startup/bl_ui/space_filebrowser.py @@ -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() diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 80b486ef225..6a15e0fa4e5 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -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; } } } diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index 5bdba57b1df..f81ef9a07e5 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -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); diff --git a/source/blender/editors/interface/interface_drag.cc b/source/blender/editors/interface/interface_drag.cc index 04210b093b5..9a9516ef5b2 100644 --- a/source/blender/editors/interface/interface_drag.cc +++ b/source/blender/editors/interface/interface_drag.cc @@ -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 */ diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index 0d4c860dec9..8ddd88c5af0 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -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: diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 237ba302e7e..00e9791b605 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -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 diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index 6a212094021..e89baee0cea 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -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) diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index 6b577532a78..b2b25891b3e 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -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); } diff --git a/source/blender/windowmanager/WM_api.hh b/source/blender/windowmanager/WM_api.hh index 6a1174d7cf5..8de51e45a34 100644 --- a/source/blender/windowmanager/WM_api.hh +++ b/source/blender/windowmanager/WM_api.hh @@ -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); diff --git a/source/blender/windowmanager/WM_types.hh b/source/blender/windowmanager/WM_types.hh index 9f7e071725b..7e2be7731e2 100644 --- a/source/blender/windowmanager/WM_types.hh +++ b/source/blender/windowmanager/WM_types.hh @@ -1117,7 +1117,7 @@ struct wmDragID { }; struct wmDragAsset { - int import_method; /* eAssetImportType */ + int import_method; /* eAssetImportMethod */ const AssetRepresentationHandle *asset; }; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 1f269149379..92ce3a08a2d 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -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(__func__); asset_drag->asset = asset; - asset_drag->import_method = import_type; + asset_drag->import_method = import_method; return asset_drag; }