diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 15:23:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 15:23:05 +0400 |
commit | 3406bafc59220a592c2e0d68a1f6a6b348a2212e (patch) | |
tree | 91b426f68c12acfb2e7296e7fb625683ec9b12c3 /source/blender/makesrna/intern/rna_define.c | |
parent | e11d22a6b751c750c40226cb027e7805adb7d4e4 (diff) |
comments for RNA_def_property_ui_range() and clamp some out-of-range values.
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index ac307139860..4e6c3748230 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1210,6 +1210,15 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive) prop->flag |= PROP_ICONS_CONSECUTIVE; } +/** + * The values hare are a little confusing: + * + * \param step For floats this is (step / 100), why /100? - nobody knows. + * for int's, whole values are used. + * + * \param precision The number of zeros to show + * (as a whole number - common range is 1 - 6), see PRECISION_FLOAT_MAX + */ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision) { StructRNA *srna = DefRNA.laststruct; @@ -1230,6 +1239,21 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double fprop->softmax = (float)max; fprop->step = (float)step; fprop->precision = (int)precision; +#if 0 /* handy but annoying */ + if (DefRNA.preprocess) { + /* check we're not over PRECISION_FLOAT_MAX */ + if (fprop->precision > 6) { + fprintf(stderr, "%s: \"%s.%s\", precision value over maximum.\n", + __func__, srna->identifier, prop->identifier); + DefRNA.error = 1; + } + else if (fprop->precision < 1) { + fprintf(stderr, "%s: \"%s.%s\", precision value under minimum.\n", + __func__, srna->identifier, prop->identifier); + DefRNA.error = 1; + } + } +#endif break; } default: |