Fix: GPv3: Python: Missing parent_group property on layer groups
This property was available for `layers` but was missed for layer groups. Adds a `parent_group` property for layer groups that returns the parent group if the group is inside another group. For groups that are inside the root, returns `None`. Pull Request: https://projects.blender.org/blender/blender/pulls/129168
This commit is contained in:
@@ -497,6 +497,19 @@ static void rna_GreasePencil_active_layer_set(PointerRNA *ptr,
|
||||
WM_main_add_notifier(NC_GPENCIL | NA_EDITED | NA_SELECTED, grease_pencil);
|
||||
}
|
||||
|
||||
static PointerRNA rna_GreasePencilLayerGroup_parent_group_get(PointerRNA *ptr)
|
||||
{
|
||||
blender::bke::greasepencil::LayerGroup &layer_group =
|
||||
static_cast<GreasePencilLayerTreeGroup *>(ptr->data)->wrap();
|
||||
blender::bke::greasepencil::LayerGroup *parent_group = layer_group.as_node().parent_group();
|
||||
/* Return None when group is in the root group. */
|
||||
if (!parent_group || parent_group == rna_grease_pencil(ptr)->root_group_ptr) {
|
||||
return PointerRNA_NULL;
|
||||
}
|
||||
return rna_pointer_inherit_refine(
|
||||
ptr, &RNA_GreasePencilLayerGroup, static_cast<void *>(parent_group));
|
||||
}
|
||||
|
||||
static PointerRNA rna_GreasePencil_active_group_get(PointerRNA *ptr)
|
||||
{
|
||||
GreasePencil *grease_pencil = rna_grease_pencil(ptr);
|
||||
@@ -1088,6 +1101,13 @@ static void rna_def_grease_pencil_layer_group(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Onion Skinning", "Display onion skins before and after the current frame");
|
||||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
|
||||
|
||||
/* Parent group. */
|
||||
prop = RNA_def_property(srna, "parent_group", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "GreasePencilLayerGroup");
|
||||
RNA_def_property_pointer_funcs(
|
||||
prop, "rna_GreasePencilLayerGroup_parent_group_get", nullptr, nullptr, nullptr);
|
||||
RNA_def_property_ui_text(prop, "Parent Group", "The parent group this group is part of");
|
||||
}
|
||||
|
||||
static void rna_def_grease_pencil_layer_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
||||
Reference in New Issue
Block a user