Skip to content

Commit

Permalink
Feature: Added support for "Thin acrylic" system backdrop (#15406)
Browse files Browse the repository at this point in the history
Co-authored-by: Yair <[email protected]>
  • Loading branch information
heftymouse and yaira2 committed May 16, 2024
1 parent 42becc1 commit ea18185
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/Files.App/Data/Enums/BackdropMaterialType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public enum BackdropMaterialType
/// <summary>
/// Arcylic backdrop.
/// </summary>
Acrylic
Acrylic,

/// <summary>
/// Thin Acrylic backdrop.
/// </summary>
ThinAcrylic
}
}
26 changes: 15 additions & 11 deletions src/Files.App/Helpers/UI/AppSystemBackdrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;

namespace Files.App.Helpers
Expand Down Expand Up @@ -47,11 +42,11 @@ protected override void OnDefaultSystemBackdropConfigurationChanged(IComposition
{
base.OnDefaultSystemBackdropConfigurationChanged(target, xamlRoot);
var configuration = GetDefaultSystemBackdropConfiguration(target, xamlRoot);
if (controller is not DesktopAcrylicController acrylicController || configuration.Theme == prevTheme)
if (controller is not DesktopAcrylicController acrylicController || acrylicController.Kind != DesktopAcrylicKind.Thin || configuration.Theme == prevTheme)
return;

prevTheme = configuration.Theme;
SetAcrylicBackdropProperties(acrylicController, configuration.Theme);
SetThinAcrylicBackdropProperties(acrylicController, configuration.Theme);
}

protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop disconnectedTarget)
Expand Down Expand Up @@ -103,18 +98,27 @@ private void OnSettingChanged(object? sender, SettingChangedEventArgs e)
};

case BackdropMaterialType.Acrylic:
var acrylicController = new DesktopAcrylicController();
SetAcrylicBackdropProperties(acrylicController, theme);
return new DesktopAcrylicController()
{
Kind = DesktopAcrylicKind.Base,
};

case BackdropMaterialType.ThinAcrylic:
var acrylicController = new DesktopAcrylicController()
{
Kind = DesktopAcrylicKind.Thin
};
SetThinAcrylicBackdropProperties(acrylicController, theme);
return acrylicController;

default:
return null;
}
}

private void SetAcrylicBackdropProperties(DesktopAcrylicController controller, SystemBackdropTheme theme)
private void SetThinAcrylicBackdropProperties(DesktopAcrylicController controller, SystemBackdropTheme theme)
{
// This sets all properties to work around a bug where other properties stop updating when fallback color is changed
// This sets all properties to work around other properties not updating when fallback color is changed
// This uses the Thin Acrylic recipe from the WinUI Figma toolkit

switch(theme)
Expand Down
4 changes: 4 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3796,6 +3796,10 @@
<data name="VerticalAlignment" xml:space="preserve">
<value>Vertical alignment</value>
</data>
<data name="ThinAcrylic" xml:space="preserve">
<value>Thin Acrylic</value>
<comment>This is a type of backdrop for the application background</comment>
</data>
<data name="AllLocations" xml:space="preserve">
<value>Show for all locations</value>
<comment>Setting where users can choose to display "Open IDE" button for Git Repos</comment>
Expand Down
8 changes: 3 additions & 5 deletions src/Files.App/ViewModels/Settings/AppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public AppearanceViewModel(IUserSettingsService userSettingsService, IResourcesS
"DarkTheme".GetLocalizedResource()
];

// TODO: Re-add Solid and regular Mica when theming is revamped
//BackdropMaterialTypes.Add(BackdropMaterialType.Solid, "Solid".GetLocalizedResource());

BackdropMaterialTypes.Add(BackdropMaterialType.Solid, "None".GetLocalizedResource());
BackdropMaterialTypes.Add(BackdropMaterialType.Acrylic, "Acrylic".GetLocalizedResource());

//BackdropMaterialTypes.Add(BackdropMaterialType.Mica, "Mica".GetLocalizedResource());
BackdropMaterialTypes.Add(BackdropMaterialType.ThinAcrylic, "ThinAcrylic".GetLocalizedResource());
BackdropMaterialTypes.Add(BackdropMaterialType.Mica, "Mica".GetLocalizedResource());
BackdropMaterialTypes.Add(BackdropMaterialType.MicaAlt, "MicaAlt".GetLocalizedResource());

selectedBackdropMaterial = BackdropMaterialTypes[UserSettingsService.AppearanceSettingsService.AppThemeBackdropMaterial];
Expand Down

0 comments on commit ea18185

Please sign in to comment.