diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-15 11:32:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-15 12:06:07 +0300 |
commit | ece7ebb3a8b880b45977db7c1915c671c90f2817 (patch) | |
tree | ee2f7585452ac757aabea20bb586d63d4b48fbf6 /source | |
parent | fbf6eb509a71f31140746309b592fbb85e423437 (diff) |
Fix text after '|' being right aligned in the ID selector
Only use this to right align libraries when they are added to the name.
Caused by d62bbf4079323.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 19 |
2 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7d856a51720..1ce1e2950d5 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -364,8 +364,10 @@ static bool id_search_add(const bContext *C, BKE_id_full_name_ui_prefix_get(name_ui, id, UI_SEP_CHAR); int iconid = ui_id_icon_get(C, id, template_ui->preview); + bool has_sep_char = (id->lib != NULL); - if (!UI_search_item_add(items, name_ui, id, iconid, UI_BUT_HAS_SEP_CHAR)) { + if (!UI_search_item_add( + items, name_ui, id, iconid, has_sep_char ? UI_BUT_HAS_SEP_CHAR : 0)) { return false; } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 15db947bff6..3737b607305 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -384,6 +384,7 @@ typedef struct CollItemSearch { char *name; int index; int iconid; + uint has_sep_char : 1; } CollItemSearch; static int sort_search_items_list(const void *a, const void *b) @@ -405,7 +406,8 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, uiSearchItems *items) { uiRNACollectionSearch *data = arg; - int i = 0, iconid = 0, flag = RNA_property_flag(data->target_prop); + const int flag = RNA_property_flag(data->target_prop); + int i = 0; ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list"); CollItemSearch *cis; const bool is_ptr_target = (RNA_property_type(data->target_prop) == PROP_POINTER); @@ -433,7 +435,9 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, } } - iconid = 0; + int iconid = ICON_NONE; + bool has_sep_char = false; + if (itemptr.type && RNA_struct_is_ID(itemptr.type)) { iconid = ui_id_icon_get(C, itemptr.data, false); @@ -441,10 +445,12 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, name = RNA_struct_name_get_alloc(&itemptr, name_buf, sizeof(name_buf), NULL); } else { - BKE_id_full_name_ui_prefix_get(name_buf, itemptr.data, UI_SEP_CHAR); + const ID *id = itemptr.data; + BKE_id_full_name_ui_prefix_get(name_buf, id, UI_SEP_CHAR); BLI_STATIC_ASSERT(sizeof(name_buf) >= MAX_ID_FULL_NAME_UI, "Name string buffer should be big enough to hold full UI ID name"); name = name_buf; + has_sep_char = (id->lib != NULL); } } else { @@ -458,6 +464,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, cis->name = BLI_strdup(name); cis->index = i; cis->iconid = iconid; + cis->has_sep_char = has_sep_char; BLI_addtail(items_list, cis); } if (name != name_buf) { @@ -473,7 +480,11 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, /* add search items from temporary list */ for (cis = items_list->first; cis; cis = cis->next) { - if (!UI_search_item_add(items, cis->name, cis->data, cis->iconid, UI_BUT_HAS_SEP_CHAR)) { + if (!UI_search_item_add(items, + cis->name, + cis->data, + cis->iconid, + cis->has_sep_char ? UI_BUT_HAS_SEP_CHAR : 0)) { break; } } |