Plugins tab - Added missing button

Profile editor - Color tweaks
Layer adaption hints - Color tweaks
Layer adaption hints - Save on close
Layer properties - Fix loading of keyframes
This commit is contained in:
Robert committed 2022-07-25 22:39:29 +02:00
1 parent a2ce3b9d9c
commit eccad3042a
6 files changed
+67 -66

No files matched your search

+10 -38
View File
@@ -4,7 +4,6 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Immutable;
using FluentAvalonia.Styling;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Media;
using ReactiveUI;
@@ -56,19 +55,16 @@ namespace Artemis.UI.Shared
{
base.OnOpened(e);
// Enable Mica on Windows 11
FluentAvaloniaTheme? thm = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>();
if (thm != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// TODO: add Windows version to CoreWindow
if (IsWindows11 && thm.RequestedTheme != FluentAvaloniaTheme.HighContrastModeString)
{
TransparencyBackgroundFallback = Brushes.Transparent;
TransparencyLevelHint = WindowTransparencyLevel.Mica;
TryEnableMicaEffect(thm);
}
}
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !IsWindows11)
return;
// Enable Mica on Windows 11, based on the FluentAvalonia sample application
TransparencyBackgroundFallback = Brushes.Transparent;
TransparencyLevelHint = WindowTransparencyLevel.Mica;
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color) value : new Color2(32, 32, 32);
color = color.LightenPercent(-0.8f);
Background = new ImmutableSolidColorBrush(color, 0.78);
}
private void OnDataContextChanged(object? value)
@@ -85,29 +81,5 @@ namespace Artemis.UI.Shared
ClearValue(DataContextProperty);
else if (DataContext != value) DataContext = value;
}
private void TryEnableMicaEffect(FluentAvaloniaTheme thm)
{
// The background colors for the Mica brush are still based around SolidBackgroundFillColorBase resource
// BUT since we can't control the actual Mica brush color, we have to use the window background to create
// the same effect. However, we can't use SolidBackgroundFillColorBase directly since its opaque, and if
// we set the opacity the color become lighter than we want. So we take the normal color, darken it and
// apply the opacity until we get the roughly the correct color
// NOTE that the effect still doesn't look right, but it suffices. Ideally we need access to the Mica
// CompositionBrush to properly change the color but I don't know if we can do that or not
if (thm.RequestedTheme == FluentAvaloniaTheme.DarkModeString)
{
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color) value : new Color2(32, 32, 32);
color = color.LightenPercent(-0.8f);
Background = new ImmutableSolidColorBrush(color, 0.78);
}
else if (thm.RequestedTheme == FluentAvaloniaTheme.LightModeString)
{
// Similar effect here
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color) value : new Color2(243, 243, 243);
color = color.LightenPercent(0.5f);
Background = new ImmutableSolidColorBrush(color, 0.9);
}
}
}
}