[Bf-blender-cvs] [a51ff5208b4] blender-v2.92-release: Fix alpha transparency slider range being influenced by RGB values

Brecht Van Lommel noreply at git.blender.org
Thu Jan 28 13:16:56 CET 2021


Commit: a51ff5208b47254122eefb4ed9cc832fb4885012
Author: Brecht Van Lommel
Date:   Wed Jan 27 15:00:27 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBa51ff5208b47254122eefb4ed9cc832fb4885012

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.

===================================================================

M	source/blender/editors/interface/interface.c

===================================================================

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7340a373573..319ae385ffc 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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 {



More information about the Bf-blender-cvs mailing list