Merged changes in the trunk up to revision 34996.
[blender.git] / source / blender / makesrna / intern / rna_main_api.c
index 56c2f44ed7304e0b02d487ed2be1c802c3f0debb..fb282fc0f6d315cf1f45f6590a71c1ea81f6bdf0 100644 (file)
@@ -58,6 +58,7 @@
 #include "BKE_particle.h"
 #include "BKE_font.h"
 #include "BKE_node.h"
+#include "BKE_linestyle.h"
 
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
@@ -474,6 +475,22 @@ void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSetting
        /* XXX python now has invalid pointer? */
 }
 
+FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char* name)
+{
+       FreestyleLineStyle *linestyle = FRS_new_linestyle(name, bmain);
+       linestyle->id.us--;
+       return linestyle;
+}
+void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle)
+{
+       if(ID_REAL_USERS(linestyle) <= 0)
+               free_libblock(&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? */
+}
+
 /* tag functions, all the same */
 void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); }
 void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); }
@@ -502,6 +519,7 @@ void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armatu
 void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); }
 void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); }
 void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); }
+void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); }
 
 #else
 
@@ -769,7 +787,7 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
        StructRNA *srna;
        FunctionRNA *func;
        PropertyRNA *parm;
-
+    
        RNA_def_property_srna(cprop, "BlendDataWindowManagers");
        srna= RNA_def_struct(brna, "BlendDataWindowManagers", NULL);
        RNA_def_struct_ui_text(srna, "Main Window Managers", "Collection of window managers");
@@ -1208,6 +1226,30 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
        parm= RNA_def_boolean(func, "value", 0, "Value", "");
        RNA_def_property_flag(parm, PROP_REQUIRED);
 }
+void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
+{
+       StructRNA *srna;
+       FunctionRNA *func;
+       PropertyRNA *parm;
+
+       RNA_def_property_srna(cprop, "MainLineStyles");
+       srna= RNA_def_struct(brna, "MainLineStyles", NULL);
+       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