[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27925] trunk/blender/source/blender/ makesrna/intern: scene.timeline_markers.add/remove() support.

Campbell Barton ideasman42 at gmail.com
Thu Apr 1 14:10:22 CEST 2010


Revision: 27925
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27925
Author:   campbellbarton
Date:     2010-04-01 14:10:21 +0200 (Thu, 01 Apr 2010)

Log Message:
-----------
scene.timeline_markers.add/remove() support.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_action.c
    trunk/blender/source/blender/makesrna/intern/rna_scene.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-04-01 11:59:27 UTC (rev 27924)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-04-01 12:10:21 UTC (rev 27925)
@@ -67,7 +67,7 @@
 	
 	/* try to remove the F-Curve from the action */
 	if (!BLI_remlink_safe(&act->groups, agrp)) {
-		BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name);
+		BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name+2);
 		return;
 	}
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c	2010-04-01 11:59:27 UTC (rev 27924)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c	2010-04-01 12:10:21 UTC (rev 27925)
@@ -814,6 +814,29 @@
 		G.fileflags &= ~G_FILE_AUTOPLAY;
 }
 
+
+static TimeMarker *rna_TimeLine_add(Scene *scene, char name[])
+{
+	TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+	marker->flag= SELECT;
+	marker->frame= 1;
+	BLI_strncpy(marker->name, name, sizeof(marker->name));
+	BLI_addtail(&scene->markers, marker);
+	return marker;
+}
+
+static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *marker)
+{
+	/* try to remove the F-Curve from the action */
+	if (!BLI_remlink_safe(&scene->markers, marker)) {
+		BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in action '%s'", marker->name, scene->id.name+2);
+		return;
+	}
+
+	/* XXX, invalidates PyObject */
+	MEM_freeN(marker);
+}
+
 #else
 
 static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -2664,6 +2687,35 @@
 	RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
 }
 
+/* scene.timeline_markers */
+static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+	StructRNA *srna;
+
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	RNA_def_property_srna(cprop, "TimelineMarkers");
+	srna= RNA_def_struct(brna, "TimelineMarkers", NULL);
+	RNA_def_struct_sdna(srna, "Scene");
+	RNA_def_struct_ui_text(srna, "Timeline Markers", "Collection of timeline markers");
+
+	func= RNA_def_function(srna, "add", "rna_TimeLine_add");
+	RNA_def_function_ui_description(func, "Add a keyframe to the curve.");
+	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 timeline marker");
+	RNA_def_function_return(func, parm);
+
+
+	func= RNA_def_function(srna, "remove", "rna_TimeLine_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);
+}
+
 void RNA_def_scene(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -2905,6 +2957,7 @@
 	RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
 	RNA_def_property_struct_type(prop, "TimelineMarker");
 	RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene");
+	rna_def_timeline_markers(brna, prop);
 
 	/* Audio Settings */
 	prop= RNA_def_property(srna, "mute_audio", PROP_BOOLEAN, PROP_NONE);





More information about the Bf-blender-cvs mailing list