Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-08 13:34:18 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-08 13:36:33 +0300
commit0bb33294c12163191c180dda41533c690eea1b3a (patch)
treecada238ad2bb9afa82ac3293be4b6bff569cc5ec /source/blender/makesrna/intern/rna_layer.c
parentaba4a567032a18b8e4c600b49b9839a538eb5c7c (diff)
RNA API: ViewLayers: add name to LayerCollection struct.
Just use Collection name (same as for material slots e.g.). That way, one can access those by their names as well, in LayerCollection.children ... collection property (yeah, collection, collection, and moar collection).
Diffstat (limited to 'source/blender/makesrna/intern/rna_layer.c')
-rw-r--r--source/blender/makesrna/intern/rna_layer.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 727364a5bda..693d7a06a79 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -192,6 +192,18 @@ static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scen
ED_object_base_select(base, mode);
}
+static void rna_LayerCollection_name_get(struct PointerRNA *ptr, char *value)
+{
+ ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
+ BLI_strncpy(value, id->name + 2, sizeof(id->name) - 2);
+}
+
+int rna_LayerCollection_name_length(PointerRNA *ptr)
+{
+ ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
+ return strlen(id->name + 2);
+}
+
static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -222,6 +234,13 @@ static void rna_def_layer_collection(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "collection->id.name");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Name", "Name of this view layer (same as its collection one)");
+ RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", NULL);
+ RNA_def_struct_name_property(srna, prop);
+
prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
RNA_def_property_struct_type(prop, "LayerCollection");