diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-01 13:39:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-01 13:39:43 +0400 |
commit | 2c072d8f85fe38e3188813dd09147d1d32c775b5 (patch) | |
tree | 1543955ea10360b4c4b6953214bf2b633e08adc5 /source/blender/makesrna | |
parent | f01ac19c3c720505b35aca520935845e9c8af862 (diff) |
rna api - set hard min/max for colors which are float properties but internally use chars to 0/1.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index e0771dbedb7..0a67aa6e65e 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -448,11 +448,9 @@ static int rna_enum_bitmask(PropertyRNA *prop) static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp) { - if(prop->type == PROP_FLOAT && (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA)) - if(strcmp(dp->dnatype, "float") != 0 && strcmp(dp->dnatype, "double") != 0) - return 1; - - return 0; + return ( (prop->type == PROP_FLOAT) && + (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA) && + (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) ); } static const char *rna_function_string(void *func) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index caf43793996..53944f7ec5c 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1628,6 +1628,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname) { PropertyDefRNA *dp; + FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; StructRNA *srna= DefRNA.laststruct; if(!DefRNA.preprocess) { @@ -1652,6 +1653,11 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons } } } + + if(dp->dnatype && strcmp(dp->dnatype, "char") == 0) { + fprop->hardmin= fprop->softmin= 0.0f; + fprop->hardmax= fprop->softmax= 1.0f; + } } rna_def_property_sdna(prop, structname, propname); |