diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index e9ed3aa8682..6d182ed17f0 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -72,6 +72,9 @@ #include "BKE_movieclip.h" #include "BKE_mask.h" #include "BKE_gpencil.h" +#ifdef WITH_FREESTYLE +# include "BKE_linestyle.h" +#endif #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -634,6 +637,25 @@ static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, Poin gpd->id.name + 2, ID_REAL_USERS(gpd)); } +#ifdef WITH_FREESTYLE +FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char* name) +{ + FreestyleLineStyle *linestyle = FRS_new_linestyle(name, bmain); + id_us_min(&linestyle->id); + return linestyle; +} + +void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle) +{ + if(ID_REAL_USERS(linestyle) <= 0) + BKE_libblock_free(&bmain->linestyle, linestyle); + else + BKE_reportf(reports, RPT_ERROR, "Line style '%s' must have zero users to be removed, found %d", linestyle->id.name+2, ID_REAL_USERS(linestyle)); + + /* XXX python now has invalid pointer? */ +} +#endif + /* 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); } @@ -665,6 +687,9 @@ static void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain- static void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } static void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); } static void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); } +#ifdef WITH_FREESTYLE +void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); } +#endif static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); } static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE); } @@ -1686,4 +1711,32 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } +#ifdef WITH_FREESTYLE +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "BlendDataLineStyles"); + srna = RNA_def_struct(brna, "BlendDataLineStyles", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Line Styles", "Collection of line styles"); + + func = RNA_def_function(srna, "new", "rna_Main_linestyles_new"); + RNA_def_function_ui_description(func, "Add a new line style instance to the main database"); + parm = RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the datablock"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style datablock"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_linestyles_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile"); + parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED); +} +#endif + #endif |