GPv3: Python API for frame, drawing and drawing attributes #124787

Merged
Falk David merged 22 commits from filedescriptor/blender:gpv3-drawing-python-api into main 2024-07-26 16:30:21 +02:00
Showing only changes of commit 92225140f5 - Show all commits

View File

@ -904,6 +904,14 @@ static void rna_AttributeGroupGreasePencilDrawing_active_set(PointerRNA *ptr,
BKE_attributes_active_set(owner, layer->name);
}
static bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA *ptr,
const PointerRNA value)
{
AttributeOwner owner = owner_from_attribute_pointer_rna(&value);
filedescriptor marked this conversation as resolved Outdated
In file included from /home/jacques/blender/build_debug/source/blender/makesrna/intern/rna_attribute_gen.cc:36:
/home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc: In function ‘bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA*, PointerRNA)’:
/home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc:910:59: error: invalid conversion from ‘const PointerRNA*’ to ‘PointerRNA*’ [-fpermissive]
  910 |   AttributeOwner owner = owner_from_attribute_pointer_rna(&value);
      |                                                           ^~~~~~
      |                                                           |
      |                                                           const PointerRNA*
/home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc:187:68: note:   initializing argument 1 of ‘AttributeOwner owner_from_attribute_pointer_rna(PointerRNA*)’
  187 | static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr)
      |                                                        ~~~~~~~~~~~~^~~
``` In file included from /home/jacques/blender/build_debug/source/blender/makesrna/intern/rna_attribute_gen.cc:36: /home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc: In function ‘bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA*, PointerRNA)’: /home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc:910:59: error: invalid conversion from ‘const PointerRNA*’ to ‘PointerRNA*’ [-fpermissive] 910 | AttributeOwner owner = owner_from_attribute_pointer_rna(&value); | ^~~~~~ | | | const PointerRNA* /home/jacques/blender/blender/source/blender/makesrna/intern/rna_attribute.cc:187:68: note: initializing argument 1 of ‘AttributeOwner owner_from_attribute_pointer_rna(PointerRNA*)’ 187 | static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr) | ~~~~~~~~~~~~^~~ ```

Sorry about that, fixed now.

Sorry about that, fixed now.
return owner.is_valid() && owner.type() == AttributeOwnerType::GreasePencilDrawing &&
owner.get_grease_pencil_drawing() == static_cast<GreasePencilDrawing *>(ptr->data);
}
static int rna_AttributeGroupGreasePencilDrawing_active_index_get(PointerRNA *ptr)
{
GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
@ -1628,7 +1636,7 @@ static void rna_def_attribute_group_grease_pencil_drawing(BlenderRNA *brna)
"rna_AttributeGroupGreasePencilDrawing_active_get",
"rna_AttributeGroupGreasePencilDrawing_active_set",
nullptr,
nullptr);
"rna_AttributeGroupGreasePencilDrawing_active_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_update(prop, 0, "rna_AttributeGroupID_update_active");
filedescriptor marked this conversation as resolved Outdated

I find it weird to use a function named rna_AttributeGroupID_update_active for non-ID-owned attribute data?

Would suggest to either rename that one to a generic rna_AttributeGroup_update_activename, or to add a rna_AttributeGroupGreasePencilDrawing_update_active one (which could then call rna_AttributeGroupID_update_active if it's fine to do so)?

I find it weird to use a function named `rna_AttributeGroupID_update_active` for non-ID-owned attribute data? Would suggest to either rename that one to a generic `rna_AttributeGroup_update_active`name, or to add a `rna_AttributeGroupGreasePencilDrawing_update_active` one (which could then call `rna_AttributeGroupID_update_active` if it's fine to do so)?