Fix: Make it easier to tell if Color Swatches are greyed out or not
authorJoshua Leung <aligorith@gmail.com>
Mon, 18 Apr 2016 12:42:59 +0000 (00:42 +1200)
committerJoshua Leung <aligorith@gmail.com>
Mon, 18 Apr 2016 12:42:59 +0000 (00:42 +1200)
This commit makes disabled/inactive color swatches look more obviously disabled
by halving their alpha values. It is necessary because the results of
ui_widget_color_disabled() (which is usually used when disabling widgets)
get overwritten by the color filling code here.

To avoid confusion, the checkerboard background (when the color genuinely has
alpha) will still only show in those cases. That is, when disabled, color swatches
won't show the checkerboard unless the color actually has an alpha component if it
wasn't disabled.

source/blender/editors/interface/interface_widgets.c

index 841b76c676b8f25770969be00514f0a503f558b3..d1461f1acecd66c6fee3d127e717b343c3596c1b 100644 (file)
@@ -3042,6 +3042,15 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
 
        wcol->shaded = 0;
        wcol->alpha_check = (wcol->inner[3] < 255);
+       
+       if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
+               /* Now we reduce alpha of the inner color (i.e. the color shown)
+                * so that this setting can look greyed out, while retaining
+                * the checkboard (for transparent values). This is needed
+                * here as the effects of ui_widget_color_disabled() are overwritten.
+                */
+               wcol->inner[3] /= 2;
+       }
 
        widgetbase_draw(&wtb, wcol);