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.
This commit is contained in:
@@ -84,6 +84,8 @@ def draw(layout, context, context_member, use_edit=True):
|
|||||||
props.data_path = context_member
|
props.data_path = context_member
|
||||||
del row
|
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:
|
for key, val in items:
|
||||||
|
|
||||||
if key == '_RNA_UI':
|
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"):
|
if convert_to_pyobject and not hasattr(val_orig, "len"):
|
||||||
row.label(text=val_draw)
|
row.label(text=val_draw)
|
||||||
else:
|
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:
|
if use_edit:
|
||||||
row = split.row(align=True)
|
row = split.row(align=True)
|
||||||
|
@@ -493,6 +493,13 @@ static int rna_Property_registered_optional_get(PointerRNA *ptr)
|
|||||||
return prop->flag & PROP_REGISTER_OPTIONAL;
|
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)
|
static int rna_BoolProperty_default_get(PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_boolean_funcs(prop, "rna_Property_registered_optional_get", NULL);
|
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");
|
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)
|
static void rna_def_function(BlenderRNA *brna)
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#include "bpy_rna.h"
|
#include "bpy_rna.h"
|
||||||
#include "bpy_util.h"
|
#include "bpy_util.h"
|
||||||
|
|
||||||
|
#include "BKE_utildefines.h"
|
||||||
|
|
||||||
#include "RNA_define.h" /* for defining our own rna */
|
#include "RNA_define.h" /* for defining our own rna */
|
||||||
#include "RNA_enum_types.h"
|
#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_int_default(prop, def);
|
||||||
RNA_def_property_range(prop, min, max);
|
RNA_def_property_range(prop, min, max);
|
||||||
RNA_def_property_ui_text(prop, name, description);
|
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(pyopts) {
|
||||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
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);
|
if(pydef) RNA_def_property_int_array_default(prop, def);
|
||||||
RNA_def_property_range(prop, min, max);
|
RNA_def_property_range(prop, min, max);
|
||||||
RNA_def_property_ui_text(prop, name, description);
|
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(pyopts) {
|
||||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
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_float_default(prop, def);
|
||||||
RNA_def_property_range(prop, min, max);
|
RNA_def_property_range(prop, min, max);
|
||||||
RNA_def_property_ui_text(prop, name, description);
|
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(pyopts) {
|
||||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
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);
|
if(pydef) RNA_def_property_float_array_default(prop, def);
|
||||||
RNA_def_property_range(prop, min, max);
|
RNA_def_property_range(prop, min, max);
|
||||||
RNA_def_property_ui_text(prop, name, description);
|
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(pyopts) {
|
||||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
Reference in New Issue
Block a user