diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-18 23:01:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-18 23:01:35 +0300 |
commit | ae5a814f26e78dd65557773b5c00c341cdca1947 (patch) | |
tree | c605eed391e60b097820b501e588309d517acf07 /source/blender/python | |
parent | 5f6b9fd324162358ac482b151bc034e0006d6734 (diff) |
ID properties that are displayed via RNA can now define their own UI settings,
only implimented min/max precision & step.
at the moment there is no way to edit these other then via python
example of setting UI limits...
>>> C.object['foo'] = 0.5
>>> C.object['_RNA_UI'] = {'foo': {'step': 0.5, 'soft_max': 10.0, 'soft_min': 0.0, 'precision': 2, 'description': 'Some setting'}}
Also fixed typo's: precission -> precision
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ba268201b81..d12de5f2e46 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3252,9 +3252,10 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; + static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "step", "precision", "default", NULL}; char *id=NULL, *name="", *description=""; - float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, def=0.0f; + float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f; + int precision= 1; PropertyRNA *prop; StructRNA *srna; @@ -3269,10 +3270,11 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) } else if(srna) { - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffffif:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &step, &precision, &def)) return NULL; prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); + RNA_def_property_ui_range(prop, min, max, step, precision); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; } |