Revision: 20806
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20806
Author:   kazanbas
Date:     2009-06-11 13:46:12 +0200 (Thu, 11 Jun 2009)

Log Message:
-----------
Allow defining string property on py operator - a first step towards 
interfacing the file selector :)

Modified Paths:
--------------
    branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_interface.c
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.h

Modified: branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c   
2009-06-11 11:44:47 UTC (rev 20805)
+++ branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c   
2009-06-11 11:46:12 UTC (rev 20806)
@@ -2041,7 +2041,7 @@
        copy_mesh_data(me, from);
 }
 
-void RNA_api_mesh_copy_transformed()
+void RNA_api_mesh_transform(Mesh *me, float **mat)
 {
 }
 

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c      
2009-06-11 11:44:47 UTC (rev 20805)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c      
2009-06-11 11:46:12 UTC (rev 20806)
@@ -799,6 +799,12 @@
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in 
the interface.");
 
+       /*
+       // error on compile
+       prop= RNA_def_float_matrix(srna, "mat", 16, NULL, 0.0f, 0.0f, "Matrix", 
"Transform matrix of the object.", 0.0f, 0.0f);
+       RNA_def_property_float_sdna(prop, NULL, "obmat");
+       */
+
        /* collections */
        prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_struct_type(prop, "Constraint");

Modified: 
branches/soc-2009-kazanbas/source/blender/python/intern/bpy_interface.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/python/intern/bpy_interface.c     
2009-06-11 11:44:47 UTC (rev 20805)
+++ branches/soc-2009-kazanbas/source/blender/python/intern/bpy_interface.c     
2009-06-11 11:46:12 UTC (rev 20806)
@@ -102,6 +102,7 @@
                        {"FloatProperty", (PyCFunction)BPy_FloatProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
                        {"IntProperty", (PyCFunction)BPy_IntProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
                        {"BoolProperty", (PyCFunction)BPy_BoolProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
+                       {"StringProperty", (PyCFunction)BPy_StringProperty, 
METH_VARARGS|METH_KEYWORDS, ""},
                        {NULL, NULL, 0, NULL}
                };
                

Modified: branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c   
2009-06-11 11:44:47 UTC (rev 20805)
+++ branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c   
2009-06-11 11:46:12 UTC (rev 20806)
@@ -38,6 +38,7 @@
 #include "BKE_context.h"
 #include "BKE_global.h" /* evil G.* */
 #include "BKE_report.h"
+#include "BKE_utildefines.h" /* FILE_MAX */
 
 static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b )
 {
@@ -1803,6 +1804,33 @@
        }
 }
 
+PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
+{
+       static char *kwlist[] = {"attr", "name", "description", "maxlen", 
"default", NULL};
+       char *id, *name="", *description="", *def="";
+       int maxlen=FILE_MAX; // XXX need greater?
+       
+       if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", 
kwlist, &id, &name, &description, &maxlen, &def))
+               return NULL;
+       
+       if (PyTuple_Size(args) > 0) {
+               PyErr_SetString(PyExc_ValueError, "all args must be keywors"); 
// TODO - py3 can enforce this.
+               return NULL;
+       }
+       
+       if (self) {
+               StructRNA *srna = PyCObject_AsVoidPtr(self);
+               RNA_def_string(srna, id, def, maxlen, name, description);
+               Py_RETURN_NONE;
+       } else {
+               PyObject *ret = PyTuple_New(2);
+               PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void 
*)BPy_StringProperty, NULL));
+               PyTuple_SET_ITEM(ret, 1, kw);
+               Py_INCREF(kw);
+               return ret;
+       }
+}
+
 /*-------------------- Type Registration ------------------------*/
 
 static int rna_function_arg_count(FunctionRNA *func)

Modified: branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.h
===================================================================
--- branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.h   
2009-06-11 11:44:47 UTC (rev 20805)
+++ branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.h   
2009-06-11 11:46:12 UTC (rev 20806)
@@ -76,6 +76,7 @@
 PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw);
 PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw);
 PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw);
+PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw);
 
 /* function for registering types */
 PyObject *pyrna_basetype_register(PyObject *self, PyObject *args);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to