// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
namespace FlaxEngine.GUI
{
///
/// The blur panel that applied the Gaussian-blur to all content beneath the control.
///
///
public class BlurPanel : ContainerControl
{
///
/// Gets or sets the blur strength. Defines how blurry the background is. Larger numbers increase blur, resulting in a larger runtime cost on the GPU.
///
[EditorOrder(0), Limit(0, 100, 0.1f)]
public float BlurStrength { get; set; }
///
/// If checked, the blur strength will be scaled with the control size, which makes it resolution-independent.
///
[EditorOrder(10)]
public bool BlurScaleWithSize { get; set; } = false;
///
/// Initializes a new instance of the class.
///
public BlurPanel()
{
AutoFocus = false;
}
///
public override void DrawSelf()
{
base.DrawSelf();
var size = Size;
var strength = BlurStrength;
if (BlurScaleWithSize)
strength *= size.MinValue / 1000.0f;
if (strength > Mathf.Epsilon)
{
Render2D.DrawBlur(new Rectangle(Float2.Zero, size), strength);
}
}
}
}