diff options
author | Dan Eicher <dan@eu.phorio.us> | 2012-10-08 00:07:30 +0400 |
---|---|---|
committer | Dan Eicher <dan@eu.phorio.us> | 2012-10-08 00:07:30 +0400 |
commit | 7b37e78c91d2a7a9c95c7a0f5bbe74fbca18c07c (patch) | |
tree | 9b420c7dbcd4f7317d58d42808d46825e4f2ad55 /source/blender/makesrna/intern/rna_main_api.c | |
parent | 9fcb7cd520dd5b1befcff9115a707a2b4cfa718a (diff) |
Grease Pencil py-api
* new/remove for GPencil frames/strokes/
* add/pop for points
* clear for frame/layer & grease_pencil
* copy for frame
+ fix for free_gpencil_frames() not clearing the active frame
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f5c59aa583a..cd9b3965713 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -71,6 +71,7 @@ #include "BKE_speaker.h" #include "BKE_movieclip.h" #include "BKE_mask.h" +#include "BKE_gpencil.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -92,6 +93,7 @@ #include "DNA_node_types.h" #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "DNA_gpencil_types.h" #include "ED_screen.h" @@ -561,6 +563,19 @@ static void rna_Main_masks_remove(Main *bmain, Mask *mask) /* XXX python now has invalid pointer? */ } +static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, bGPdata *gpd) +{ + if (ID_REAL_USERS(gpd) <= 0) { + BKE_gpencil_free(gpd); + BKE_libblock_free(&bmain->gpencil, gpd); + } + else + BKE_reportf(reports, RPT_ERROR, "Grease Pencil \"%s\" must have zero users to be removed, found %d", + gpd->id.name + 2, ID_REAL_USERS(gpd)); + + /* XXX python now has invalid pointer? */ +} + /* tag functions, all the same */ static void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); } static void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); } @@ -1509,6 +1524,20 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + func = RNA_def_function(srna, "new", "gpencil_data_addnew"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the datablock"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil datablock"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_grease_pencil_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a grease pencil instance from the current blendfile"); + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "Grease Pencil to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL); |