[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22813] branches/blender2.5/blender/source /blender: Grease Pencil: RNA Wrapping

Joshua Leung aligorith at gmail.com
Thu Aug 27 08:03:41 CEST 2009


Revision: 22813
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22813
Author:   aligorith
Date:     2009-08-27 08:03:41 +0200 (Thu, 27 Aug 2009)

Log Message:
-----------
Grease Pencil: RNA Wrapping

* Wrapped Grease Pencil datatypes in RNA.
* Hooked up Grease Pencil access in RNA (i.e. via Main, ID, and Scene)

TODO:
Updates to properties are currently lacking property-update calls, since there's no good notifier for this.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesdna/DNA_gpencil_types.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_action.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_animation.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_main.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_gpencil_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_gpencil_types.h	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_gpencil_types.h	2009-08-27 06:03:41 UTC (rev 22813)
@@ -33,7 +33,7 @@
 /* Grease-Pencil Annotations - 'Stroke Point'
  *	-> Coordinates may either be 2d or 3d depending on settings at the time
  * 	-> Coordinates of point on stroke, in proportions of window size
- *		(i.e. n/1000). This assumes that the bottom-left corner is (0,0)
+ *	   This assumes that the bottom-left corner is (0,0)
  */
 typedef struct bGPDspoint {
 	float x, y, z;			/* co-ordinates of point (usually 2d, but can be 3d as well) */				
@@ -135,12 +135,14 @@
 /* bGPdata->flag */
 // XXX many of these flags should be depreceated for more general ideas in 2.5
 	/* don't allow painting to occur at all */
+	// XXX is depreceated - not well understood
 #define GP_DATA_LMBPLOCK	(1<<0)
 	/* show debugging info in viewport (i.e. status print) */
 #define GP_DATA_DISPINFO	(1<<1)
 	/* in Action Editor, show as expanded channel */
 #define GP_DATA_EXPAND		(1<<2)
 	/* is the block overriding all clicks? */
+	// XXX is depreceated - nasty old concept
 #define GP_DATA_EDITPAINT	(1<<3)
 	/* new strokes are added in viewport space */
 #define GP_DATA_VIEWALIGN	(1<<4)

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-08-27 06:03:41 UTC (rev 22813)
@@ -213,6 +213,11 @@
 extern StructRNA RNA_GameStringProperty;
 extern StructRNA RNA_GameTimerProperty;
 extern StructRNA RNA_GlowSequence;
+extern StructRNA RNA_GreasePencil;
+extern StructRNA RNA_GPencilLayer;
+extern StructRNA RNA_GPencilFrame;
+extern StructRNA RNA_GPencilStroke;
+extern StructRNA RNA_GPencilStrokePoint;
 extern StructRNA RNA_Group;
 extern StructRNA RNA_Header;
 extern StructRNA RNA_HemiLamp;

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2009-08-27 06:03:41 UTC (rev 22813)
@@ -1964,6 +1964,7 @@
 	{"rna_curve.c", NULL, RNA_def_curve},
 	{"rna_fcurve.c", NULL, RNA_def_fcurve},
 	{"rna_fluidsim.c", NULL, RNA_def_fluidsim},
+	{"rna_gpencil.c", NULL, RNA_def_gpencil},
 	{"rna_group.c", NULL, RNA_def_group},
 	{"rna_image.c", NULL, RNA_def_image},
 	{"rna_key.c", NULL, RNA_def_key},

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2009-08-27 06:03:41 UTC (rev 22813)
@@ -97,6 +97,7 @@
 		case ID_BR: return &RNA_Brush;
 		case ID_CA: return &RNA_Camera;
 		case ID_CU: return &RNA_Curve;
+		case ID_GD: return &RNA_GreasePencil;
 		case ID_GR: return &RNA_Group;
 		case ID_IM: return &RNA_Image;
 		case ID_KE: return &RNA_Key;

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_action.c	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_action.c	2009-08-27 06:03:41 UTC (rev 22813)
@@ -42,15 +42,15 @@
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
-
+	
 	srna= RNA_def_struct(brna, "ActionGroup", NULL);
 	RNA_def_struct_sdna(srna, "bActionGroup");
 	RNA_def_struct_ui_text(srna, "Action Group", "Groups of F-Curves.");
-
+	
 	prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Name", "");
 	RNA_def_struct_name_property(srna, prop);
-
+	
 	/* dna warns not to treat the Action Channel listbase in the Action Group struct like a
 	   normal listbase. I'll leave this here but comment out, for Joshua to review. He can 
  	   probably shed some more light on why this is */
@@ -58,19 +58,19 @@
 	RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
 	RNA_def_property_struct_type(prop, "FCurve");
 	RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group.");*/
-
+	
 	prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED);
 	RNA_def_property_ui_text(prop, "Selected", "Action Group is selected.");
-
+	
 	prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED);
 	RNA_def_property_ui_text(prop, "Locked", "Action Group is locked.");
-
+	
 	prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED);
 	RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded.");
-
+	
 	prop= RNA_def_property(srna, "custom_color", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "customCol");
 	RNA_def_property_ui_text(prop, "Custom Color", "Index of custom color set.");
@@ -85,17 +85,17 @@
 	RNA_def_struct_sdna(srna, "bAction");
 	RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation.");
 	RNA_def_struct_ui_icon(srna, ICON_ACTION);
-
+	
 	prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
 	RNA_def_property_struct_type(prop, "FCurve");
 	RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action.");
-
+	
 	prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "groups", NULL);
 	RNA_def_property_struct_type(prop, "ActionGroup");
 	RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves.");
-
+	
 	prop= RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
 	RNA_def_property_struct_type(prop, "TimelineMarker");

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_animation.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_animation.c	2009-08-27 01:57:09 UTC (rev 22812)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_animation.c	2009-08-27 06:03:41 UTC (rev 22813)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * Contributor(s): Blender Foundation (2008), Roland Hess
+ * Contributor(s): Blender Foundation (2009), Joshua Leung
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -157,7 +157,6 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYINGSET_BUILTIN);
 	RNA_def_property_ui_text(prop, "Built-In", "Keying Set is a built-in to Blender.");
 	
-		/* TODO: for now, this is editable, but do we really want this to happen? */
 	prop= RNA_def_property(srna, "absolute", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYINGSET_ABSOLUTE);
 	RNA_def_property_ui_text(prop, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");

Added: branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c	2009-08-27 06:03:41 UTC (rev 22813)
@@ -0,0 +1,242 @@
+/**
+ * $Id: rna_gpencil.c 22756 2009-08-25 04:05:37Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2009), Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+#include "RNA_enum_types.h"
+
+#include "rna_internal.h"
+
+#include "DNA_gpencil_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#ifdef RNA_RUNTIME
+
+static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
+{
+	bGPDlayer *gpl= (bGPDlayer *)ptr->data;
+	
+	/* surely there must be other criteria too... */
+	if (gpl->flag & GP_LAYER_LOCKED)
+		return 0;
+	else
+		return 1;
+}
+
+void rna_GPencilLayer_active_set(PointerRNA *ptr, int value)
+{
+	bGPdata *gpd= ptr->id.data;
+	bGPDlayer *gpl= ptr->data;
+	
+	/* disabled all other layers anyway */
+	if (GS(gpd->id.name) == ID_GD) {
+		bGPDlayer *gl;
+		
+		for (gl= gpd->layers.first; gl; gl= gl->next)
+			gl->flag &= ~GP_LAYER_ACTIVE;
+	}	
+	
+	/* if enabling value, make it active */
+	if (value)
+		gpl->flag |= GP_LAYER_ACTIVE;
+}
+
+#else
+
+void rna_def_gpencil_stroke_point(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+	
+	srna= RNA_def_struct(brna, "GPencilStrokePoint", NULL);
+	RNA_def_struct_sdna(srna, "bGPDspoint");
+	RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Point", "Data point for freehand stroke curve.");
+	
+	prop= RNA_def_property(srna, "coordinates", PROP_FLOAT, PROP_NONE);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list