From 7e622b7353844efa5a578968619cb74953c6fa7b Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 9 Mar 2025 09:46:30 +0900 Subject: [PATCH] Add BackdropType in setting --- .../UserSettings/Settings.cs | 10 ++++ .../ViewModels/SettingsPaneThemeViewModel.cs | 50 +++++++++++++++++++ .../SettingPages/Views/SettingsPaneTheme.xaml | 19 +++++++ 3 files changed, 79 insertions(+) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0fb6e2b3c..e62090724 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -76,6 +76,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings } public bool UseDropShadowEffect { get; set; } = true; + public BackdropTypes BackdropType{ get; set; } = BackdropTypes.None; + /* Appearance Settings. It should be separated from the setting later.*/ public double WindowHeightSize { get; set; } = 42; public double ItemHeightSize { get; set; } = 58; @@ -426,4 +428,12 @@ namespace Flow.Launcher.Infrastructure.UserSettings Fast, Custom } + + public enum BackdropTypes + { + None, + Acrylic, + Mica, + MicaAlt + } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index d05fe98a8..56fc38ff7 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -15,6 +15,8 @@ using Flow.Launcher.ViewModel; using ModernWpf; using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager; using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager; +using static Flow.Launcher.Core.Resource.Theme; +using System.Windows.Interop; namespace Flow.Launcher.SettingPages.ViewModels; @@ -177,6 +179,54 @@ public partial class SettingsPaneThemeViewModel : BaseModel public class AnimationSpeedData : DropdownDataGeneric { } public List AnimationSpeeds { get; } = DropdownDataGeneric.GetValues("AnimationSpeed"); + public class BackdropTypeData : DropdownDataGeneric + { + public void ApplyBackdrop() + { + IntPtr hWnd = new WindowInteropHelper(Application.Current.MainWindow).Handle; + if (hWnd == IntPtr.Zero) + return; + + int backdropValue = Value switch + { + BackdropTypes.Acrylic => 3, // ✅ Acrylic (DWM_SYSTEMBACKDROP_TYPE = 3) + BackdropTypes.Mica => 2, // ✅ Mica (DWM_SYSTEMBACKDROP_TYPE = 2) + BackdropTypes.MicaAlt => 4, // ✅ MicaAlt (DWM_SYSTEMBACKDROP_TYPE = 4) + _ => 0 // ✅ None (DWM_SYSTEMBACKDROP_TYPE = 0) + }; + + Methods.SetWindowAttribute(hWnd, ParameterTypes.DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, backdropValue); + } + } + + // ✅ BackdropTypeData 리스트 (Dropdown과 연동) + public List BackdropTypesList { get; } = + DropdownDataGeneric.GetValues("BackdropTypes"); + + // ✅ BackdropType 속성 (값 저장 + 자동 적용) + public BackdropTypes BackdropType + { + get => Enum.IsDefined(typeof(BackdropTypes), Settings.BackdropType) + ? (BackdropTypes)Settings.BackdropType + : BackdropTypes.None; + + set + { + if (!Enum.IsDefined(typeof(BackdropTypes), value)) + { + value = BackdropTypes.None; + } + + Settings.BackdropType = value; + + // ✅ BackdropTypeData 리스트에서 해당하는 값 찾기 + var backdropData = BackdropTypesList.FirstOrDefault(b => b.Value == value); + backdropData?.ApplyBackdrop(); + } + } + + + public bool UseSound { get => Settings.UseSound; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 703ae85bb..9ccd784a4 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -370,6 +370,25 @@ + + + + + + + +