diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-02 18:43:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-02 18:43:22 +0400 |
commit | 0d12c77097b19bfa688c99480f755184ad46342b (patch) | |
tree | a37bd154a82915c9b616fcbd855c6e4aeff16939 | |
parent | 4e9162cd63badf4bf5fb312e108ffbbc58ebd342 (diff) |
bugfix [#23635] property limits don't work when added via scripting\
also fix for bug where soft limits could be greater then hard limits with bpy.props.* functions.
-rw-r--r-- | release/scripts/modules/rna_prop_ui.py | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 12 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 10 |
3 files changed, 24 insertions, 5 deletions
diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 4ee0b40faa8..4a9460d8271 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -84,6 +84,8 @@ def draw(layout, context, context_member, use_edit=True): props.data_path = context_member del row + rna_properties = {prop.identifier for prop in rna_item.bl_rna.properties if prop.is_runtime} if items else None + for key, val in items: if key == '_RNA_UI': @@ -113,7 +115,10 @@ def draw(layout, context, context_member, use_edit=True): if convert_to_pyobject and not hasattr(val_orig, "len"): row.label(text=val_draw) else: - row.prop(rna_item, '["%s"]' % key, text="") + if key in rna_properties: + row.prop(rna_item, key, text="") + else: + row.prop(rna_item, '["%s"]' % key, text="") if use_edit: row = split.row(align=True) diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 4bfd0e4fd41..81b0df1d840 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -493,6 +493,13 @@ static int rna_Property_registered_optional_get(PointerRNA *ptr) return prop->flag & PROP_REGISTER_OPTIONAL; } +static int rna_Property_runtime_get(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + return prop->flag & PROP_RUNTIME; +} + + static int rna_BoolProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -1018,6 +1025,11 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_registered_optional_get", NULL); RNA_def_property_ui_text(prop, "Registered Optionally", "Property is optionally registered as part of type registration"); + + prop= RNA_def_property(srna, "is_runtime", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Property_runtime_get", NULL); + RNA_def_property_ui_text(prop, "Read Only", "Property is editable through RNA"); } static void rna_def_function(BlenderRNA *brna) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 9535741f2b5..9ae7507a72a 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -26,6 +26,8 @@ #include "bpy_rna.h" #include "bpy_util.h" +#include "BKE_utildefines.h" + #include "RNA_define.h" /* for defining our own rna */ #include "RNA_enum_types.h" @@ -294,7 +296,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_int_default(prop, def); RNA_def_property_range(prop, min, max); RNA_def_property_ui_text(prop, name, description); - RNA_def_property_ui_range(prop, soft_min, soft_max, step, 3); + RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); @@ -371,7 +373,7 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw) if(pydef) RNA_def_property_int_array_default(prop, def); RNA_def_property_range(prop, min, max); RNA_def_property_ui_text(prop, name, description); - RNA_def_property_ui_range(prop, soft_min, soft_max, step, 3); + RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); @@ -448,7 +450,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_float_default(prop, def); RNA_def_property_range(prop, min, max); RNA_def_property_ui_text(prop, name, description); - RNA_def_property_ui_range(prop, soft_min, soft_max, step, precision); + RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); @@ -525,7 +527,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw) if(pydef) RNA_def_property_float_array_default(prop, def); RNA_def_property_range(prop, min, max); RNA_def_property_ui_text(prop, name, description); - RNA_def_property_ui_range(prop, soft_min, soft_max, step, precision); + RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); |