Fix alpha transparency slider range being influenced by RGB values

For buttons that edit array properties, the soft min/max and slider ranges are
based on the range of all values in the array. However for alpha this does not
make much sense, the only reasonable range is 0..1 even when there are RGB
values larger than 1. So treat alpha as an individual property.
This commit is contained in:
Brecht Van Lommel 2021-01-27 15:00:27 +01:00
parent 3726aa68c3
commit a51ff5208b
1 changed files with 5 additions and 3 deletions

View File

@ -3201,6 +3201,7 @@ void ui_but_range_set_soft(uiBut *but)
if (but->rnaprop) {
const PropertyType type = RNA_property_type(but->rnaprop);
const PropertySubType subtype = RNA_property_subtype(but->rnaprop);
double softmin, softmax /*, step, precision*/;
double value_min;
double value_max;
@ -3224,7 +3225,7 @@ void ui_but_range_set_soft(uiBut *but)
value_max = (double)value_range[1];
}
else {
value_min = value_max = (double)RNA_property_int_get(&but->rnapoin, but->rnaprop);
value_min = value_max = ui_but_value_get(but);
}
}
else if (type == PROP_FLOAT) {
@ -3237,14 +3238,15 @@ void ui_but_range_set_soft(uiBut *but)
/*step = fstep;*/ /*UNUSED*/
/*precision = fprecision;*/ /*UNUSED*/
if (is_array) {
/* Use shared min/max for array values, except for color alpha. */
if (is_array && !(subtype == PROP_COLOR && but->rnaindex == 3)) {
float value_range[2];
RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range);
value_min = (double)value_range[0];
value_max = (double)value_range[1];
}
else {
value_min = value_max = (double)RNA_property_float_get(&but->rnapoin, but->rnaprop);
value_min = value_max = ui_but_value_get(but);
}
}
else {