[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28783] trunk/blender/source/blender/ makesrna: patch from Dan Eicher

Campbell Barton ideasman42 at gmail.com
Sat May 15 15:30:14 CEST 2010


Revision: 28783
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28783
Author:   campbellbarton
Date:     2010-05-15 15:30:14 +0200 (Sat, 15 May 2010)

Log Message:
-----------
patch from Dan Eicher
- pose markers new/remove
- font load/remove
- world load/remove
- particles new/remove

commented out node-tree for now since from what I can tell these have to be atteched to material/scene/texture (unlike other ID types)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/RNA_types.h
    trunk/blender/source/blender/makesrna/intern/rna_action.c
    trunk/blender/source/blender/makesrna/intern/rna_main_api.c

Modified: trunk/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_types.h	2010-05-15 12:26:05 UTC (rev 28782)
+++ trunk/blender/source/blender/makesrna/RNA_types.h	2010-05-15 13:30:14 UTC (rev 28783)
@@ -330,22 +330,31 @@
 
 /* fake struct definitions, needed otherwise collections end up owning the C
  * structs like 'Object' when defined first */
-#define MainCameras Main
-#define MainScenes Main
-#define MainArmatures Main
-#define MainMaterials Main
-#define MainMeshes Main
-#define MainLamps Main
-#define MainImages Main
-#define MainObjects Main
-#define MainTexts Main
-#define MainActions Main
-#define MainGroups Main
-#define MainTextures Main
-#define MainCurves Main
-#define MainBrushes Main
-#define MainLattices Main
-#define MainMetaBall Main
+#define MainActions		Main
+#define MainArmatures		Main
+#define MainBrushes		Main
+#define MainCameras		Main
+#define MainCurves		Main
+#define MainFonts		Main
+#define MainGreasePencils	Main
+#define MainGroups		Main
+#define MainImages		Main
+#define MainLamps		Main
+#define MainLattices		Main
+#define MainLibraries		Main
+#define MainMaterials		Main
+#define MainMeshes		Main
+#define MainMetaBalls		Main
+#define MainNodeTrees		Main
+#define MainObjects		Main
+#define MainParticles		Main
+#define MainScenes		Main
+#define MainScreens		Main
+#define MainSounds		Main
+#define MainTexts		Main
+#define MainTextures		Main
+#define MainWindowManagers	Main
+#define MainWorlds		Main
 
 #ifdef __cplusplus
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-05-15 12:26:05 UTC (rev 28782)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-05-15 13:30:14 UTC (rev 28783)
@@ -127,6 +127,27 @@
 	}
 }
 
+static TimeMarker *rna_Action_pose_markers_new(bAction *act, ReportList *reports, char name[])
+{
+	TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+	marker->flag= 1;
+	marker->frame= 1;
+	BLI_strncpy(marker->name, name, sizeof(marker->name));
+	BLI_addtail(&act->markers, marker);
+	return marker;
+}
+
+static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker)
+{
+	if (!BLI_remlink_safe(&act->markers, marker)) {
+		BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in action '%s'", marker->name, act->id.name+2);
+		return;
+	}
+
+	/* XXX, invalidates PyObject */
+	MEM_freeN(marker);
+}
+
 #else
 
 static void rna_def_dopesheet(BlenderRNA *brna)
@@ -379,6 +400,34 @@
 	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 }
 
+static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+	StructRNA *srna;
+
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	RNA_def_property_srna(cprop, "ActionPoseMarkers");
+	srna= RNA_def_struct(brna, "ActionPoseMarkers", NULL);
+	RNA_def_struct_sdna(srna, "bAction");
+	RNA_def_struct_ui_text(srna, "Action Pose Markers", "Collection of timeline markers");
+
+	func= RNA_def_function(srna, "new", "rna_Action_pose_markers_new");
+	RNA_def_function_ui_description(func, "Add a pose marker to the action.");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	parm= RNA_def_string(func, "name", "Marker", 0, "", "New name for the marker (not unique).");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+
+	parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Newly created marker");
+	RNA_def_function_return(func, parm);
+
+	func= RNA_def_function(srna, "remove", "rna_Action_pose_markers_remove");
+	RNA_def_function_ui_description(func, "Remove a timeline marker.");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove.");
+	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+}
+
 static void rna_def_action(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -405,6 +454,7 @@
 	RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
 	RNA_def_property_struct_type(prop, "TimelineMarker");
 	RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses");
+	rna_def_action_pose_markers(brna, prop);
 
 	RNA_api_action(srna);
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_main_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_main_api.c	2010-05-15 12:26:05 UTC (rev 28782)
+++ trunk/blender/source/blender/makesrna/intern/rna_main_api.c	2010-05-15 13:30:14 UTC (rev 28783)
@@ -53,6 +53,10 @@
 #include "BKE_brush.h"
 #include "BKE_lattice.h"
 #include "BKE_mball.h"
+#include "BKE_world.h"
+#include "BKE_particle.h"
+#include "BKE_font.h"
+#include "BKE_node.h"
 
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
@@ -67,6 +71,10 @@
 #include "DNA_brush_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_meta_types.h"
+#include "DNA_world_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_vfont_types.h"
+#include "DNA_node_types.h"
 
 #include "ED_screen.h"
 
@@ -196,6 +204,23 @@
 	/* XXX python now has invalid pointer? */
 }
 
+// XXX, commended for now, need to see how this can be used with node groups.
+struct bNodeTree *rna_Main_nodetree_new(Main *bmain, int type)
+{
+	bNodeTree *tree = ntreeAddTree(type);
+	tree->id.us--;
+	return tree;
+}
+void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree)
+{
+	if(ID_REAL_USERS(tree) <= 0)
+		free_libblock(&bmain->nodetree, tree);
+	else
+		BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d.", tree->id.name+2, ID_REAL_USERS(tree));
+
+	/* XXX python now has invalid pointer? */
+}
+
 Mesh *rna_Main_meshes_new(Main *bmain, char* name)
 {
 	Mesh *me= add_mesh(name);
@@ -291,6 +316,20 @@
 		BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" must have zero users to be removed, found %d.", mb->id.name+2, ID_REAL_USERS(mb));
 }
 
+VFont *rna_Main_fonts_load(Main *bmain, char *filename)
+{
+	return load_vfont(filename);
+}
+void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
+{
+	if(ID_REAL_USERS(vfont) <= 0)
+		free_libblock(&bmain->vfont, vfont);
+	else
+		BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d.", vfont->id.name+2, ID_REAL_USERS(vfont));
+
+	/* XXX python now has invalid pointer? */
+}
+
 Tex *rna_Main_textures_new(Main *bmain, char* name)
 {
 	Tex *tex= add_texture(name);
@@ -319,6 +358,20 @@
 		BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d.", brush->id.name+2, ID_REAL_USERS(brush));
 }
 
+World *rna_Main_worlds_new(Main *bmain, char* name)
+{
+	World *world = add_world(name);
+	world->id.us--;
+	return world;
+}
+void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world)
+{
+	if(ID_REAL_USERS(world) <= 0)
+		free_libblock(&bmain->world, world);
+	else
+		BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d.", world->id.name+2, ID_REAL_USERS(world));
+}
+
 Group *rna_Main_groups_new(Main *bmain, char* name)
 {
 	return add_group(name);
@@ -383,6 +436,22 @@
 	/* XXX python now has invalid pointer? */
 }
 
+ParticleSettings *rna_Main_particles_new(Main *bmain, char* name)
+{
+	ParticleSettings *part = psys_new_settings(name, bmain);
+	part->id.us--;
+	return part;
+}
+void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part)
+{
+	if(ID_REAL_USERS(part) <= 0)
+		free_libblock(&bmain->particle, part);
+	else
+		BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d.", part->id.name+2, ID_REAL_USERS(part));
+
+	/* XXX python now has invalid pointer? */
+}
+
 #else
 
 void RNA_api_main(StructRNA *srna)
@@ -510,7 +579,35 @@
 }
 void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
 {
+	StructRNA *srna;
+	FunctionRNA *func;
+	PropertyRNA *parm;
 
+	static EnumPropertyItem node_nodetree_items[] = {
+	{0, "SHADER",       0,    "Shader",       ""},
+	{1, "COMPOSITE",    0,    "Composite",    ""},
+	{2, "TEXTURE",      0,    "Texture",      ""},
+	{0, NULL, 0, NULL, NULL}};
+
+	RNA_def_property_srna(cprop, "MainNodeTrees");
+	srna= RNA_def_struct(brna, "MainNodeTrees", NULL);
+	RNA_def_struct_ui_text(srna, "Main Node Trees", "Collection of node trees");
+
+#if 0 // need to see some examples of using these functions before enabling.
+	func= RNA_def_function(srna, "new", "rna_Main_nodetree_new");
+	RNA_def_function_ui_description(func, "Add a new node tree to the main database");
+	parm= RNA_def_enum(func, "type", node_nodetree_items, 0, "Type", "The type of curve object to add");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	/* return type */
+	parm= RNA_def_pointer(func, "tree", "NodeTree", "", "New node tree datablock.");
+	RNA_def_function_return(func, parm);
+
+	func= RNA_def_function(srna, "remove", "rna_Main_nodetree_remove");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile.");
+	parm= RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove.");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+#endif
 }
 void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
 {
@@ -664,8 +761,8 @@
 	FunctionRNA *func;
 	PropertyRNA *parm;
 
-	RNA_def_property_srna(cprop, "MainMetaBall");
-	srna= RNA_def_struct(brna, "MainMetaBall", NULL);
+	RNA_def_property_srna(cprop, "MainMetaBalls");
+	srna= RNA_def_struct(brna, "MainMetaBalls", NULL);
 	RNA_def_struct_ui_text(srna, "Main MetaBall", "Collection of metaballs");
 
 	func= RNA_def_function(srna, "new", "rna_Main_metaballs_new");
@@ -684,7 +781,27 @@
 }
 void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
 {
+	StructRNA *srna;
+	FunctionRNA *func;
+	PropertyRNA *parm;
 
+	RNA_def_property_srna(cprop, "MainFonts");
+	srna= RNA_def_struct(brna, "MainFonts", NULL);
+	RNA_def_struct_ui_text(srna, "Main Fonts", "Collection of fonts");
+
+	func= RNA_def_function(srna, "load", "rna_Main_fonts_load");
+	RNA_def_function_ui_description(func, "Load a new font into the main database");
+	parm= RNA_def_string(func, "filename", "File Name", 0, "", "path of the font to load.");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	/* return type */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list