Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/modules/rna_prop_ui.py1
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c2
-rw-r--r--source/blender/makesrna/intern/rna_rna.c7
-rw-r--r--source/blender/python/intern/bpy_rna.c88
4 files changed, 95 insertions, 3 deletions
diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py
index ef853b395ea..3c12d4304d1 100644
--- a/release/scripts/modules/rna_prop_ui.py
+++ b/release/scripts/modules/rna_prop_ui.py
@@ -177,6 +177,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
exec_str = "item['%s'] = %s" % (prop, value_eval)
# print(exec_str)
exec(exec_str)
+ self._last_prop[:] = [prop]
prop_type = type(item[prop])
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 67d562da23b..10a4a9f5fbd 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -649,7 +649,7 @@ static void rna_def_drivertarget(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_DriverTarget_id_typef");
- RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from");
+ RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from (id_type property must be set first)");
//RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX disabled for now, until we can turn off auto updates
prop= RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 4218724d7df..f8adb1a79d8 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -428,7 +428,12 @@ static int rna_Property_unit_get(PointerRNA *ptr)
static int rna_Property_editable_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
- return RNA_property_editable(ptr, prop);
+
+ /* dont use this becaure it will call functions that check the internal
+ * data for introspection we only need to know if it can be edited so the
+ * flag is better for this */
+// return RNA_property_editable(ptr, prop);
+ return prop->flag & PROP_EDITABLE ? 1:0;
}
static int rna_Property_use_return_get(PointerRNA *ptr)
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 22beb79ef59..b05483f8576 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1391,7 +1391,6 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
return result;
}
-
static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
{
char *name;
@@ -1434,6 +1433,59 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
Py_RETURN_NONE;
}
+static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args)
+{
+ char *name= NULL;
+ char *path;
+ PropertyRNA *prop;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, "|s:path_to_id", &name))
+ return NULL;
+
+ if(name) {
+ prop= RNA_struct_find_property(&self->ptr, name);
+ if(prop==NULL) {
+ PyErr_Format(PyExc_TypeError, "path_to_id(\"%.200s\") not found", name);
+ return NULL;
+ }
+
+ path= RNA_path_from_ID_to_property(&self->ptr, prop);
+ }
+ else {
+ path= RNA_path_from_ID_to_struct(&self->ptr);
+ }
+
+ if(path==NULL) {
+ if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_to_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name);
+ else PyErr_Format(PyExc_TypeError, "%.200s.path_to_id() does not support path creation for this type", name);
+ return NULL;
+ }
+
+ ret= PyUnicode_FromString(path);
+ MEM_freeN(path);
+
+ return ret;
+}
+
+static PyObject *pyrna_prop_path_to_id(BPy_PropertyRNA *self)
+{
+ char *path;
+ PropertyRNA *prop;
+ PyObject *ret;
+
+ path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
+
+ if(path==NULL) {
+ PyErr_Format(PyExc_TypeError, "%.200s.%.200s.path_to_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
+ return NULL;
+ }
+
+ ret= PyUnicode_FromString(path);
+ MEM_freeN(path);
+
+ return ret;
+}
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
{
@@ -1890,6 +1942,34 @@ static PyObject *pyrna_prop_values(BPy_PropertyRNA *self)
return ret;
}
+static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
+{
+ IDProperty *group, *idprop;
+
+ char *key;
+ PyObject* def = Py_None;
+
+ if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
+ return NULL;
+
+ /* mostly copied from BPy_IDGroup_Map_GetItem */
+ if(RNA_struct_idproperties_check(&self->ptr)==0) {
+ PyErr_SetString( PyExc_TypeError, "this type doesn't support IDProperties");
+ return NULL;
+ }
+
+ group= RNA_struct_idproperties(&self->ptr, 0);
+ if(group) {
+ idprop= IDP_GetPropertyFromGroup(group, key);
+
+ if(idprop)
+ return BPy_IDGroup_WrapData(self->ptr.id.data, idprop);
+ }
+
+ Py_INCREF(def);
+ return def;
+}
+
static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args)
{
PointerRNA newptr;
@@ -2182,12 +2262,15 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"values", (PyCFunction)pyrna_struct_values, METH_NOARGS, NULL},
{"items", (PyCFunction)pyrna_struct_items, METH_NOARGS, NULL},
+ {"get", (PyCFunction)pyrna_struct_get, METH_VARARGS, NULL},
+
/* maybe this become and ID function */
{"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL},
{"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
{"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},
{"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_O, NULL},
+ {"path_to_id", (PyCFunction)pyrna_struct_path_to_id, METH_VARARGS, NULL},
{"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
@@ -2203,6 +2286,9 @@ static struct PyMethodDef pyrna_prop_methods[] = {
{"add", (PyCFunction)pyrna_prop_add, METH_NOARGS, NULL},
{"remove", (PyCFunction)pyrna_prop_remove, METH_O, NULL},
+ /* almost the same as the srna function */
+ {"path_to_id", (PyCFunction)pyrna_prop_path_to_id, METH_NOARGS, NULL},
+
/* array accessor function */
{"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
{"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},