diff options
author | Julian Eisel <julian@blender.org> | 2020-06-10 16:08:23 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-06-10 16:52:10 +0300 |
commit | d62bbf40793234a3cfc3762720f0964f85206169 (patch) | |
tree | 1aa1f7828ec6fcb4df01c484ab45ac78b9a5c624 /source/blender/blenkernel | |
parent | 93c8955a722ba3f2022b92a2f8befaadc467756a (diff) |
UI: Show library names grayed out and right-aligned in menus
Should separate the data-block name better from the library name and improve
readability.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_lib_id.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id.c | 18 |
2 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h index 18ca5629d07..7f5a6e3e36a 100644 --- a/source/blender/blenkernel/BKE_lib_id.h +++ b/source/blender/blenkernel/BKE_lib_id.h @@ -250,8 +250,10 @@ void BKE_main_id_repair_duplicate_names_listbase(struct ListBase *lb); #define MAX_ID_FULL_NAME (64 + 64 + 3 + 1) /* 64 is MAX_ID_NAME - 2 */ #define MAX_ID_FULL_NAME_UI (MAX_ID_FULL_NAME + 3) /* Adds 'keycode' two letters at beginning. */ -void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const struct ID *id); -void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const struct ID *id); +void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const struct ID *id, char separator_str); +void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], + const struct ID *id, + char separator_char); char *BKE_id_to_unique_string_key(const struct ID *id); diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 19462c62496..734fe9ad9ae 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -2068,9 +2068,11 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name) * \note Result is unique to a given ID type in a given Main database. * * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME, - * will be filled with generated string. + * will be filled with generated string. + * \param separator_char: Character to use for separating name and library name. Can be 0 to use + * default (' '). */ -void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id) +void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separator_char) { strcpy(name, id->name + 2); @@ -2078,7 +2080,7 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id) const size_t idname_len = strlen(id->name + 2); const size_t libname_len = strlen(id->lib->id.name + 2); - name[idname_len] = ' '; + name[idname_len] = separator_char ? separator_char : ' '; name[idname_len + 1] = '['; strcpy(name + idname_len + 2, id->lib->id.name + 2); name[idname_len + 2 + libname_len] = ']'; @@ -2094,15 +2096,19 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id) * \note Result is unique to a given ID type in a given Main database. * * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME_UI, - * will be filled with generated string. + * will be filled with generated string. + * \param separator_char: Character to use for separating name and library name. Can be 0 to use + * default (' '). */ -void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const ID *id) +void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], + const ID *id, + char separator_char) { name[0] = id->lib ? (ID_MISSING(id) ? 'M' : 'L') : ID_IS_OVERRIDE_LIBRARY(id) ? 'O' : ' '; name[1] = (id->flag & LIB_FAKEUSER) ? 'F' : ((id->us == 0) ? '0' : ' '); name[2] = ' '; - BKE_id_full_name_get(name + 3, id); + BKE_id_full_name_get(name + 3, id, separator_char); } /** |