Cleanup: naming consistency for find functions
- find_from_name -> find_by_name. - find_from_index -> find_index. This matches naming used elsewhere in Blender API's.
This commit is contained in:
parent
0701c65d93
commit
9e3dc02bed
|
@ -234,8 +234,7 @@ bUserAssetLibrary *AssetLibraryService::find_custom_preferences_asset_library_fr
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return BKE_preferences_asset_library_find_from_name(&U,
|
||||
asset_reference.asset_library_identifier);
|
||||
return BKE_preferences_asset_library_find_by_name(&U, asset_reference.asset_library_identifier);
|
||||
}
|
||||
|
||||
AssetLibrary *AssetLibraryService::find_loaded_on_disk_asset_library_from_name(
|
||||
|
@ -428,7 +427,7 @@ bUserAssetLibrary *AssetLibraryService::find_custom_asset_library_from_library_r
|
|||
BLI_assert(library_reference.type == ASSET_LIBRARY_CUSTOM);
|
||||
BLI_assert(library_reference.custom_library_index >= 0);
|
||||
|
||||
return BKE_preferences_asset_library_find_from_index(&U, library_reference.custom_library_index);
|
||||
return BKE_preferences_asset_library_find_index(&U, library_reference.custom_library_index);
|
||||
}
|
||||
|
||||
std::string AssetLibraryService::root_path_from_library_ref(
|
||||
|
|
|
@ -47,10 +47,12 @@ void BKE_preferences_asset_library_name_set(struct UserDef *userdef,
|
|||
void BKE_preferences_asset_library_path_set(struct bUserAssetLibrary *library, const char *path)
|
||||
ATTR_NONNULL();
|
||||
|
||||
struct bUserAssetLibrary *BKE_preferences_asset_library_find_from_index(
|
||||
const struct UserDef *userdef, int index) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
|
||||
struct bUserAssetLibrary *BKE_preferences_asset_library_find_from_name(
|
||||
const struct UserDef *userdef, const char *name) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
|
||||
struct bUserAssetLibrary *BKE_preferences_asset_library_find_index(const struct UserDef *userdef,
|
||||
int index)
|
||||
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
|
||||
struct bUserAssetLibrary *BKE_preferences_asset_library_find_by_name(const struct UserDef *userdef,
|
||||
const char *name)
|
||||
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Return the bUserAssetLibrary that contains the given file/directory path. The given path can be
|
||||
|
|
|
@ -79,13 +79,13 @@ void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const ch
|
|||
}
|
||||
}
|
||||
|
||||
bUserAssetLibrary *BKE_preferences_asset_library_find_from_index(const UserDef *userdef, int index)
|
||||
bUserAssetLibrary *BKE_preferences_asset_library_find_index(const UserDef *userdef, int index)
|
||||
{
|
||||
return static_cast<bUserAssetLibrary *>(BLI_findlink(&userdef->asset_libraries, index));
|
||||
}
|
||||
|
||||
bUserAssetLibrary *BKE_preferences_asset_library_find_from_name(const UserDef *userdef,
|
||||
const char *name)
|
||||
bUserAssetLibrary *BKE_preferences_asset_library_find_by_name(const UserDef *userdef,
|
||||
const char *name)
|
||||
{
|
||||
return static_cast<bUserAssetLibrary *>(
|
||||
BLI_findstring(&userdef->asset_libraries, name, offsetof(bUserAssetLibrary, name)));
|
||||
|
|
|
@ -36,7 +36,7 @@ class StringSearchBase {
|
|||
* of type T attached that is used to identify it.
|
||||
*
|
||||
* When querying, the a match score is computed between the query string and each item. Items that
|
||||
* don't match are fitered out, the rest is sorted by the score. Elements with the same score are
|
||||
* don't match are filtered out, the rest is sorted by the score. Elements with the same score are
|
||||
* further sorted based on the optionally provided weight and other heuristics.
|
||||
*
|
||||
* The usage is simple. First #add all the search items and then use the #query method.
|
||||
|
|
|
@ -32,7 +32,7 @@ int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *librar
|
|||
|
||||
/* Note that the path isn't checked for validity here. If an invalid library path is used, the
|
||||
* Asset Browser can give a nice hint on what's wrong. */
|
||||
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_index(
|
||||
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_index(
|
||||
&U, library->custom_library_index);
|
||||
if (user_library) {
|
||||
return ASSET_LIBRARY_CUSTOM + library->custom_library_index;
|
||||
|
@ -53,7 +53,7 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
|
|||
return library;
|
||||
}
|
||||
|
||||
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_index(
|
||||
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_index(
|
||||
&U, value - ASSET_LIBRARY_CUSTOM);
|
||||
|
||||
/* Note that there is no check if the path exists here. If an invalid library path is used, the
|
||||
|
|
|
@ -844,7 +844,7 @@ static const bUserAssetLibrary *selected_asset_library(wmOperator *op)
|
|||
{
|
||||
const int enum_value = RNA_enum_get(op->ptr, "asset_library_ref");
|
||||
const AssetLibraryReference lib_ref = ED_asset_library_reference_from_enum_value(enum_value);
|
||||
const bUserAssetLibrary *lib = BKE_preferences_asset_library_find_from_index(
|
||||
const bUserAssetLibrary *lib = BKE_preferences_asset_library_find_index(
|
||||
&U, lib_ref.custom_library_index);
|
||||
return lib;
|
||||
}
|
||||
|
|
|
@ -9596,7 +9596,7 @@ static int ui_list_handle_click_drag(bContext *C,
|
|||
static void ui_list_activate_row_from_index(
|
||||
bContext *C, ARegion *region, uiBut *listbox, uiList *ui_list, int index)
|
||||
{
|
||||
uiBut *new_active_row = ui_list_row_find_from_index(region, index, listbox);
|
||||
uiBut *new_active_row = ui_list_row_find_index(region, index, listbox);
|
||||
if (new_active_row) {
|
||||
/* Preferred way to update the active item, also calls the custom activate operator
|
||||
* (#uiListDyn::custom_activate_optype). */
|
||||
|
|
|
@ -1347,9 +1347,9 @@ uiBut *ui_list_find_mouse_over(const ARegion *region,
|
|||
uiBut *ui_list_find_from_row(const ARegion *region, const uiBut *row_but) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_list_row_find_mouse_over(const ARegion *region, const int xy[2])
|
||||
ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_list_row_find_from_index(const ARegion *region,
|
||||
int index,
|
||||
uiBut *listbox) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_list_row_find_index(const ARegion *region,
|
||||
int index,
|
||||
uiBut *listbox) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_view_item_find_mouse_over(const ARegion *region, const int xy[2]) ATTR_NONNULL(1, 2);
|
||||
uiBut *ui_view_item_find_active(const ARegion *region);
|
||||
|
||||
|
|
|
@ -437,7 +437,7 @@ static bool ui_but_is_listrow_at_index(const uiBut *but, const void *customdata)
|
|||
(but->hardmax == find_data->index);
|
||||
}
|
||||
|
||||
uiBut *ui_list_row_find_from_index(const ARegion *region, const int index, uiBut *listbox)
|
||||
uiBut *ui_list_row_find_index(const ARegion *region, const int index, uiBut *listbox)
|
||||
{
|
||||
BLI_assert(listbox->type == UI_BTYPE_LISTBOX);
|
||||
ListRowFindIndexData data = {};
|
||||
|
|
|
@ -1063,7 +1063,7 @@ static bool filelist_compare_asset_libraries(const AssetLibraryReference *librar
|
|||
}
|
||||
if (library_a->type == ASSET_LIBRARY_CUSTOM) {
|
||||
/* Don't only check the index, also check that it's valid. */
|
||||
bUserAssetLibrary *library_ptr_a = BKE_preferences_asset_library_find_from_index(
|
||||
bUserAssetLibrary *library_ptr_a = BKE_preferences_asset_library_find_index(
|
||||
&U, library_a->custom_library_index);
|
||||
return (library_ptr_a != nullptr) &&
|
||||
(library_a->custom_library_index == library_b->custom_library_index);
|
||||
|
|
|
@ -424,8 +424,7 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params)
|
|||
if (library->type == ASSET_LIBRARY_CUSTOM) {
|
||||
BLI_assert(library->custom_library_index >= 0);
|
||||
|
||||
user_library = BKE_preferences_asset_library_find_from_index(&U,
|
||||
library->custom_library_index);
|
||||
user_library = BKE_preferences_asset_library_find_index(&U, library->custom_library_index);
|
||||
if (!user_library) {
|
||||
library->type = ASSET_LIBRARY_ALL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue