[Bf-blender-cvs] [42fbb8af834] blender2.8: Util to get collection UI name

Dalai Felinto noreply at git.blender.org
Tue Nov 13 22:09:08 CET 2018


Commit: 42fbb8af8342e916b8f4e8d4591ad49574a88fe4
Author: Dalai Felinto
Date:   Tue Nov 13 18:10:30 2018 -0200
Branches: blender2.8
https://developer.blender.org/rB42fbb8af8342e916b8f4e8d4591ad49574a88fe4

Util to get collection UI name

Note we still have hardcoded IFACE_("Scene Collection") in the outliner.
I'm ok with getting of them as well, though no strong feelings here.

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

M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_outliner/outliner_tree.c

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

diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index a9539b3a3c4..d78133499ce 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -103,6 +103,7 @@ struct Base *BKE_collection_or_layer_objects(const struct ViewLayer *view_layer,
 
 struct Collection *BKE_collection_from_index(struct Scene *scene, const int index);
 void BKE_collection_new_name_get(struct Collection *collection_parent, char *rname);
+const char *BKE_collection_ui_name_get(struct Collection *collection);
 bool BKE_collection_objects_select(struct ViewLayer *view_layer, struct Collection *collection, bool deselect);
 
 /* Collection children */
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 9cec20a8f2b..47fb3622c66 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -298,6 +298,19 @@ void BKE_collection_new_name_get(Collection *collection_parent, char *rname)
 	MEM_freeN(name);
 }
 
+/**
+ * The name to show in the interface.
+ */
+const char *BKE_collection_ui_name_get(struct Collection *collection)
+{
+	if (collection->flag & COLLECTION_IS_MASTER) {
+		return IFACE_("Scene Collection");
+	}
+	else {
+		return collection->id.name + 2;
+	}
+}
+
 /* **************** Object List Cache *******************/
 
 static void collection_object_cache_fill(ListBase *lb, Collection *collection, int parent_restrict)
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index aa148512e16..18f5f7f0207 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1960,14 +1960,7 @@ static void move_to_collection_menus_free(MoveToCollectionData **menu)
 static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout, void *menu_v)
 {
 	MoveToCollectionData *menu = menu_v;
-	const char *name;
-
-	if (menu->collection->flag & COLLECTION_IS_MASTER) {
-		name = IFACE_("Scene Collection");
-	}
-	else {
-		name = menu->collection->id.name + 2;
-	}
+	const char *name = BKE_collection_ui_name_get(menu->collection);
 
 	uiItemIntO(layout,
 	           name,
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 74510c3b02f..86d909220e2 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1345,13 +1345,7 @@ static void outliner_add_view_layer(SpaceOops *soops, ListBase *tree, TreeElemen
 
 BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection)
 {
-	if (collection->flag & COLLECTION_IS_MASTER) {
-		te->name = IFACE_("Scene Collection");
-	}
-	else {
-		te->name = collection->id.name + 2;
-	}
-
+	te->name = BKE_collection_ui_name_get(collection);
 	te->directdata = collection;
 }



More information about the Bf-blender-cvs mailing list