// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.CmdPal.UI.ViewModels;
///
/// Configuration parameters for a backdrop style.
///
public sealed record BackdropStyleConfig
{
///
/// Gets the type of system backdrop controller to use.
///
public required BackdropControllerKind ControllerKind { get; init; }
///
/// Gets the base tint opacity before user adjustments.
///
public required float BaseTintOpacity { get; init; }
///
/// Gets the base luminosity opacity before user adjustments.
///
public required float BaseLuminosityOpacity { get; init; }
///
/// Gets the brush type to use for preview approximation.
///
public required PreviewBrushKind PreviewBrush { get; init; }
///
/// Gets the fixed opacity for styles that don't support user adjustment (e.g., Mica).
/// When is false, this value is used as the effective opacity.
///
public float FixedOpacity { get; init; }
///
/// Gets whether this backdrop style supports custom colorization (tint colors).
///
public bool SupportsColorization { get; init; } = true;
///
/// Gets whether this backdrop style supports custom background images.
///
public bool SupportsBackgroundImage { get; init; } = true;
///
/// Gets whether this backdrop style supports opacity adjustment.
///
public bool SupportsOpacity { get; init; } = true;
///
/// Computes the effective tint opacity based on this style's configuration.
///
/// User's backdrop opacity setting (0-1 normalized).
/// Optional override for base tint opacity (used by colorful theme).
/// The effective opacity to apply.
public float ComputeEffectiveOpacity(float userOpacity, float? baseTintOpacityOverride = null)
{
// For styles that don't support opacity (Mica), use FixedOpacity
if (!SupportsOpacity && FixedOpacity > 0)
{
return FixedOpacity;
}
// For Solid: only user opacity matters (controls alpha of solid color)
if (ControllerKind == BackdropControllerKind.Solid)
{
return userOpacity;
}
// For blur effects: multiply base opacity with user opacity
var baseTint = baseTintOpacityOverride ?? BaseTintOpacity;
return baseTint * userOpacity;
}
}