[Bf-blender-cvs] [ae46e8a] master: RNA: add rna_space_api.c for space functions

Campbell Barton noreply at git.blender.org
Tue Jan 28 21:33:18 CET 2014


Commit: ae46e8a6982c5c5a9b79dcd1d4f57b84c40e2d91
Author: Campbell Barton
Date:   Wed Jan 29 07:30:42 2014 +1100
https://developer.blender.org/rBae46e8a6982c5c5a9b79dcd1d4f57b84c40e2d91

RNA: add rna_space_api.c for space functions

===================================================================

M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_space.c
A	source/blender/makesrna/intern/rna_space_api.c

===================================================================

diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 240927e..6a0208a 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -117,6 +117,7 @@ set(APISRC
 	rna_scene_api.c
 	rna_sensor_api.c
 	rna_sequencer_api.c
+	rna_space_api.c
 	rna_text_api.c
 	rna_ui_api.c
 	rna_wm_api.c
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 160de41..f1ecb8d 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3276,7 +3276,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
 	{"rna_sensor.c", "rna_sensor_api.c", RNA_def_sensor},
 	{"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
 	{"rna_smoke.c", NULL, RNA_def_smoke},
-	{"rna_space.c", NULL, RNA_def_space},
+	{"rna_space.c", "rna_space_api.c", RNA_def_space},
 	{"rna_speaker.c", NULL, RNA_def_speaker},
 	{"rna_test.c", NULL, RNA_def_test},
 	{"rna_text.c", "rna_text_api.c", RNA_def_text},
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 2113945..d75ee25 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -284,6 +284,8 @@ void RNA_api_text(struct StructRNA *srna);
 void RNA_api_ui_layout(struct StructRNA *srna);
 void RNA_api_window(struct StructRNA *srna);
 void RNA_api_wm(struct StructRNA *srna);
+void RNA_api_space_node(struct StructRNA *srna);
+void RNA_api_region_view3d(struct StructRNA *srna);
 void RNA_api_sensor(struct StructRNA *srna);
 void RNA_api_controller(struct StructRNA *srna);
 void RNA_api_actuator(struct StructRNA *srna);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 520aa32..81389b9 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -546,25 +546,6 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
 	ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
 }
 
-/* api call */
-static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
-{
-	bScreen *sc = (bScreen *)id;
-
-	ScrArea *sa;
-	ARegion *ar;
-
-	area_region_from_regiondata(sc, rv3d, &sa, &ar);
-
-	if (sa && ar && sa->spacetype == SPACE_VIEW3D) {
-		View3D *v3d;
-
-		v3d = (View3D *)sa->spacedata.first;
-
-		ED_view3d_update_viewmat(sc->scene, v3d, ar, NULL, NULL);
-	}
-}
-
 static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr)
 {
 	Scene *scene = ((bScreen *)ptr->id.data)->scene;
@@ -2185,14 +2166,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Camera Offset", "View shift in camera view");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
-	/* until we have real api call */
-	{
-		FunctionRNA *func;
-
-		func = RNA_def_function(srna, "update", "rna_RegionView3D_update");
-		RNA_def_function_flag(func, FUNC_USE_SELF_ID);
-		RNA_def_function_ui_description(func, "Recalculate the view matrices");
-	}
+	RNA_api_region_view3d(srna);
 }
 
 static void rna_def_space_buttons(BlenderRNA *brna)
@@ -3348,8 +3322,7 @@ static void rna_def_space_node_path_api(BlenderRNA *brna, PropertyRNA *cprop)
 static void rna_def_space_node(BlenderRNA *brna)
 {
 	StructRNA *srna;
-	PropertyRNA *prop, *parm;
-	FunctionRNA *func;
+	PropertyRNA *prop;
 
 	static EnumPropertyItem texture_type_items[] = {
 		{SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"},
@@ -3488,13 +3461,7 @@ static void rna_def_space_node(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Cursor Location", "Location for adding new nodes");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
 
-	func = RNA_def_function(srna, "cursor_location_from_region", "rna_SpaceNodeEditor_cursor_location_from_region");
-	RNA_def_function_ui_description(func, "Set the cursor location using region coordinates");
-	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
-	parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "x", "Region x coordinate", -10000, 10000);
-	RNA_def_property_flag(parm, PROP_REQUIRED);
-	parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "y", "Region y coordinate", -10000, 10000);
-	RNA_def_property_flag(parm, PROP_REQUIRED);
+	RNA_api_space_node(srna);
 }
 
 static void rna_def_space_logic(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
new file mode 100644
index 0000000..aed7737
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -0,0 +1,77 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation (2008)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/makesrna/intern/rna_space_api.c
+ *  \ingroup RNA
+ */
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "rna_internal.h"
+
+#ifdef RNA_RUNTIME
+
+static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
+{
+	bScreen *sc = (bScreen *)id;
+
+	ScrArea *sa;
+	ARegion *ar;
+
+	area_region_from_regiondata(sc, rv3d, &sa, &ar);
+
+	if (sa && ar && sa->spacetype == SPACE_VIEW3D) {
+		View3D *v3d;
+
+		v3d = (View3D *)sa->spacedata.first;
+
+		ED_view3d_update_viewmat(sc->scene, v3d, ar, NULL, NULL);
+	}
+}
+
+#else
+
+void RNA_api_region_view3d(StructRNA *srna)
+{
+	FunctionRNA *func;
+
+	func = RNA_def_function(srna, "update", "rna_RegionView3D_update");
+	RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+	RNA_def_function_ui_description(func, "Recalculate the view matrices");
+}
+
+void RNA_api_space_node(StructRNA *srna)
+{
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	func = RNA_def_function(srna, "cursor_location_from_region", "rna_SpaceNodeEditor_cursor_location_from_region");
+	RNA_def_function_ui_description(func, "Set the cursor location using region coordinates");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+	parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "x", "Region x coordinate", -10000, 10000);
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "y", "Region y coordinate", -10000, 10000);
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+}
+
+#endif




More information about the Bf-blender-cvs mailing list