-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor various transparency effects so only one can be activ…
…e at a time
- Loading branch information
1 parent
d87b1f4
commit ffd9550
Showing
12 changed files
with
318 additions
and
289 deletions.
There are no files selected for viewing
140 changes: 0 additions & 140 deletions
140
FoxTunes.UI.Windows/Behaviours/WindowAccentBehaviour.cs
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
FoxTunes.UI.Windows/Behaviours/WindowAccentBehaviourConfiguration.cs
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
FoxTunes.UI.Windows/Behaviours/WindowAcrylicBlurBehaviour.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using FoxTunes.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Media; | ||
|
||
namespace FoxTunes | ||
{ | ||
[WindowsUserInterfaceDependency] | ||
//Requires Windows 11 22H2. | ||
[PlatformDependency(Major = 6, Minor = 2, Build = 22621)] | ||
public class WindowAcrylicBlurBehaviour : WindowBlurProvider | ||
{ | ||
public const string ID = "BBBBC45C-11A4-4A2A-83F2-4FFED3C72C3E"; | ||
|
||
public override string Id | ||
{ | ||
get | ||
{ | ||
return this.Id; | ||
} | ||
} | ||
|
||
public WindowAcrylicBlurBehaviour() | ||
{ | ||
this.AccentColors = new Dictionary<IntPtr, Color>(); | ||
} | ||
|
||
public IDictionary<IntPtr, Color> AccentColors { get; private set; } | ||
|
||
public Color AccentColor { get; private set; } | ||
|
||
public override void InitializeComponent(ICore core) | ||
{ | ||
base.InitializeComponent(core); | ||
this.Configuration.GetElement<TextConfigurationElement>( | ||
WindowAcrylicBlurBehaviourConfiguration.SECTION, | ||
WindowAcrylicBlurBehaviourConfiguration.ACCENT_COLOR | ||
).ConnectValue(value => | ||
{ | ||
if (string.IsNullOrEmpty(value)) | ||
{ | ||
AccentColor = WindowExtensions.DefaultAccentColor; | ||
} | ||
else | ||
{ | ||
AccentColor = value.ToColor(); | ||
} | ||
if (this.AccentColors.Any()) | ||
{ | ||
this.Refresh(); | ||
} | ||
}); | ||
} | ||
|
||
protected override void Refresh() | ||
{ | ||
var windows = new HashSet<IntPtr>(); | ||
foreach (var window in WindowBase.Active) | ||
{ | ||
windows.Add(window.Handle); | ||
var color = default(Color); | ||
if (AccentColors.TryGetValue(window.Handle, out color) && color == this.AccentColor) | ||
{ | ||
continue; | ||
} | ||
WindowExtensions.EnableAcrylicBlur(window.Handle, this.AccentColor); | ||
this.AccentColors[window.Handle] = this.AccentColor; | ||
} | ||
foreach (var handle in AccentColors.Keys.ToArray()) | ||
{ | ||
if (!windows.Contains(handle)) | ||
{ | ||
AccentColors.Remove(handle); | ||
} | ||
} | ||
} | ||
|
||
public override IEnumerable<ConfigurationSection> GetConfigurationSections() | ||
{ | ||
return WindowAcrylicBlurBehaviourConfiguration.GetConfigurationSections(); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
FoxTunes.UI.Windows/Behaviours/WindowAcrylicBlurBehaviourConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes | ||
{ | ||
public static class WindowAcrylicBlurBehaviourConfiguration | ||
{ | ||
public const string SECTION = WindowsUserInterfaceConfiguration.SECTION; | ||
|
||
public const string TRANSPARENCY_PROVIDER = WindowsUserInterfaceConfiguration.TRANSPARENCY_PROVIDER; | ||
|
||
public const string ACCENT_COLOR = "OOOO5DBB-8ACE-4FFC-B975-9131D4D82947"; | ||
|
||
public static IEnumerable<ConfigurationSection> GetConfigurationSections() | ||
{ | ||
yield return new ConfigurationSection(SECTION) | ||
.WithElement( | ||
new SelectionConfigurationElement(TRANSPARENCY_PROVIDER).WithOptions(GetProviders())) | ||
.WithElement( | ||
new TextConfigurationElement(ACCENT_COLOR, Strings.WindowsUserInterfaceConfiguration_AccentColor).DependsOn(SECTION, TRANSPARENCY_PROVIDER, WindowAcrylicBlurBehaviour.ID) | ||
); | ||
} | ||
|
||
private static IEnumerable<SelectionConfigurationOption> GetProviders() | ||
{ | ||
yield return new SelectionConfigurationOption(WindowAcrylicBlurBehaviour.ID, Strings.WindowAcrylicBlurBehaviour_Name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
FoxTunes.UI.Windows/Behaviours/WindowBlurBehaviourConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes | ||
{ | ||
public static class WindowBlurBehaviourConfiguration | ||
{ | ||
public const string SECTION = WindowsUserInterfaceConfiguration.SECTION; | ||
|
||
public const string TRANSPARENCY_PROVIDER = WindowsUserInterfaceConfiguration.TRANSPARENCY_PROVIDER; | ||
|
||
public static IEnumerable<ConfigurationSection> GetConfigurationSections() | ||
{ | ||
yield return new ConfigurationSection(SECTION) | ||
.WithElement( | ||
new SelectionConfigurationElement(TRANSPARENCY_PROVIDER).WithOptions(GetProviders()) | ||
); | ||
} | ||
|
||
private static IEnumerable<SelectionConfigurationOption> GetProviders() | ||
{ | ||
yield return new SelectionConfigurationOption(WindowBlurBehaviour.ID, Strings.WindowBlurBehaviour_Name).Default(); | ||
} | ||
} | ||
} |
Oops, something went wrong.