When widgets (Slate or UMG) are disabled, they usually appear greyed out. This happens on top of any styling that we define for widgets. An example: UMG buttons allow us to set a background style for when the button is disabled. The greying-out is applied to the button and its children on top of what we defined as the desired disabled styling.
This is a huge pain as it effectively prevents us to make disabled widgets appear exactly as we want them to. The reason why this happens is that Slate adds certain effects to widgets under certain circumstances. The types of effects are defined in the ESlateDrawEffect
enum. One possible value of that enum is ESlateDrawEffect::DisabledEffect
, which causes the widget to be greyed out as seen in the code snippet below.
int32 SImage::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
...
const bool bIsEnabled = ShouldBeEnabled(bParentEnabled);
const ESlateDrawEffect DrawEffects = bIsEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
...
}
This code causes an image to receive the greyed-out effect if it is a child of a disabled button, for example.
What I propose is one of two things:
- Get rid of this specific effect entirely. Or rather, get rid of hardcoding it in a way that forces us to override SWidget classes just for the sake of having true control over widget styling. Having a default visual cue for when an interactive element is disabled is without a doubt a good thing. Making it impossible to replace with something else, less so.
- Add an option to UI developer settings that allows us to disable the behavior on a per-project basis. I’m thinking about something similar to how the focus outline is handled. Let us check a box that disables the effect and puts us in complete control over disabled widget styling.