mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
CmdPal: Transparent window (#45159)
## Summary This PR adds: - Backdrop material customization - Alongside acrylic, the following options are now available: - Transparent background - Mica background - Background material opacity - Lets you control how transparent the background is ## Pictures? Pictures! <img width="1491" height="928" alt="image" src="https://github.com/user-attachments/assets/ff4e9e06-fcf1-4f05-bc0a-fb70dc4f39be" /> https://github.com/user-attachments/assets/84e83279-afab-481e-b904-f054318c5d2f <img width="977" height="628" alt="image" src="https://github.com/user-attachments/assets/241a228d-af3f-448a-94a6-0a282218bd8c" /> ## PR Checklist - [x] Closes: #44197 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
// 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;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration parameters for a backdrop style.
|
||||
/// </summary>
|
||||
public sealed record BackdropStyleConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of system backdrop controller to use.
|
||||
/// </summary>
|
||||
public required BackdropControllerKind ControllerKind { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base tint opacity before user adjustments.
|
||||
/// </summary>
|
||||
public required float BaseTintOpacity { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base luminosity opacity before user adjustments.
|
||||
/// </summary>
|
||||
public required float BaseLuminosityOpacity { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush type to use for preview approximation.
|
||||
/// </summary>
|
||||
public required PreviewBrushKind PreviewBrush { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fixed opacity for styles that don't support user adjustment (e.g., Mica).
|
||||
/// When <see cref="SupportsOpacity"/> is false, this value is used as the effective opacity.
|
||||
/// </summary>
|
||||
public float FixedOpacity { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this backdrop style supports custom colorization (tint colors).
|
||||
/// </summary>
|
||||
public bool SupportsColorization { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this backdrop style supports custom background images.
|
||||
/// </summary>
|
||||
public bool SupportsBackgroundImage { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this backdrop style supports opacity adjustment.
|
||||
/// </summary>
|
||||
public bool SupportsOpacity { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Computes the effective tint opacity based on this style's configuration.
|
||||
/// </summary>
|
||||
/// <param name="userOpacity">User's backdrop opacity setting (0-1 normalized).</param>
|
||||
/// <param name="baseTintOpacityOverride">Optional override for base tint opacity (used by colorful theme).</param>
|
||||
/// <returns>The effective opacity to apply.</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user