[Bf-blender-cvs] [ece7ebb3a8b] master: Fix text after '|' being right aligned in the ID selector

Campbell Barton noreply at git.blender.org
Mon Jun 15 11:08:33 CEST 2020


Commit: ece7ebb3a8b880b45977db7c1915c671c90f2817
Author: Campbell Barton
Date:   Mon Jun 15 18:32:51 2020 +1000
Branches: master
https://developer.blender.org/rBece7ebb3a8b880b45977db7c1915c671c90f2817

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.

===================================================================

M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_utils.c

===================================================================

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;
     }
   }



More information about the Bf-blender-cvs mailing list