rna api - set hard min/max for colors which are float properties but internally use chars to 0/1.

This commit is contained in:
2012-01-01 09:39:43 +00:00
parent f01ac19c3c
commit 2c072d8f85
2 changed files with 9 additions and 5 deletions

View File

@@ -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)

View File

@@ -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);