From bb7023ab25d7c8161a3093452c363f41b9f19e72 Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Fri, 23 Jun 2023 03:15:30 +0100 Subject: [PATCH 1/2] Added Animation Length slider Added a slider in Appearance to adjust the length of the open animation for the launcher. By default the animation should be the same as it was previously (the first part of the animation is about 10ms shorter so that the ratio is simpler - 2/3 instead of 25/36) Currently only has language support for English and the length is adjustable from 100ms to 2000ms in steps of 10. --- .../UserSettings/Settings.cs | 1 + Flow.Launcher/Languages/en.xaml | 2 ++ Flow.Launcher/MainWindow.xaml.cs | 12 +++---- Flow.Launcher/SettingWindow.xaml | 34 +++++++++++++++++++ .../ViewModel/SettingWindowViewModel.cs | 6 ++++ 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 43a68a2a627..10a1e46d184 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -53,6 +53,7 @@ public string Theme public string ResultFontStretch { get; set; } public bool UseGlyphIcons { get; set; } = true; public bool UseAnimation { get; set; } = true; + public int AnimationLength { get; set; } = 360; public bool UseSound { get; set; } = true; public bool UseClock { get; set; } = true; public bool UseDate { get; set; } = false; diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 30c1173780c..e69d9dcd8ec 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -157,6 +157,8 @@ Play a small sound when the search window opens Animation Use Animation in UI + Animation Length (ms) + The length of the UI animation in milliseconds Clock Date diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4adfccff482..e080c55b313 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -383,7 +383,7 @@ public void WindowAnimator() { From = 0, To = 1, - Duration = TimeSpan.FromSeconds(0.25), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength * 2 / 3), FillBehavior = FillBehavior.Stop }; @@ -391,7 +391,7 @@ public void WindowAnimator() { From = Top + 10, To = Top, - Duration = TimeSpan.FromSeconds(0.25), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength * 2 / 3), FillBehavior = FillBehavior.Stop }; var IconMotion = new DoubleAnimation @@ -399,7 +399,7 @@ public void WindowAnimator() From = 12, To = 0, EasingFunction = easing, - Duration = TimeSpan.FromSeconds(0.36), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), FillBehavior = FillBehavior.Stop }; @@ -408,7 +408,7 @@ public void WindowAnimator() From = 0, To = 1, EasingFunction = easing, - Duration = TimeSpan.FromSeconds(0.36), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), FillBehavior = FillBehavior.Stop }; double TargetIconOpacity = SearchIcon.Opacity; // Animation Target Opacity from Style @@ -417,7 +417,7 @@ public void WindowAnimator() From = 0, To = TargetIconOpacity, EasingFunction = easing, - Duration = TimeSpan.FromSeconds(0.36), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), FillBehavior = FillBehavior.Stop }; @@ -427,7 +427,7 @@ public void WindowAnimator() From = new Thickness(0, 12, right, 0), To = new Thickness(0, 0, right, 0), EasingFunction = easing, - Duration = TimeSpan.FromSeconds(0.36), + Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), FillBehavior = FillBehavior.Stop }; diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 665d16b8f8e..ce0b55de758 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2414,6 +2414,40 @@ + + + + + + + + + + + +  + + + Settings.UseAnimation = value; } + public int AnimationLength + { + get => Settings.AnimationLength; + set => Settings.AnimationLength = value; + } + public bool UseSound { get => Settings.UseSound; From 9d0474585d8c285d21b9c1571a54827135f545b3 Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Fri, 23 Jun 2023 18:42:36 +0100 Subject: [PATCH 2/2] Refactored to describe via discrete speed settings Can now select either Slow, Medium or Fast, or a user-defined Custom speed for the animation. Additionally, the speed is hidden when animations are disabled. --- .../UserSettings/Settings.cs | 13 ++- Flow.Launcher/Languages/en.xaml | 8 +- Flow.Launcher/MainWindow.xaml.cs | 21 +++- Flow.Launcher/SettingWindow.xaml | 103 +++++++++++------- .../ViewModel/SettingWindowViewModel.cs | 27 ++++- 5 files changed, 119 insertions(+), 53 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 10a1e46d184..ca167431564 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -53,7 +53,6 @@ public string Theme public string ResultFontStretch { get; set; } public bool UseGlyphIcons { get; set; } = true; public bool UseAnimation { get; set; } = true; - public int AnimationLength { get; set; } = 360; public bool UseSound { get; set; } = true; public bool UseClock { get; set; } = true; public bool UseDate { get; set; } = false; @@ -255,6 +254,10 @@ public bool HideNotifyIcon [JsonConverter(typeof(JsonStringEnumConverter))] public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected; + [JsonConverter(typeof(JsonStringEnumConverter))] + public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium; + public int CustomAnimationLength { get; set; } = 360; + // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); @@ -291,4 +294,12 @@ public enum SearchWindowAligns RightTop, Custom } + + public enum AnimationSpeeds + { + Slow, + Medium, + Fast, + Custom + } } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index e69d9dcd8ec..bee595772c8 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -157,8 +157,12 @@ Play a small sound when the search window opens Animation Use Animation in UI - Animation Length (ms) - The length of the UI animation in milliseconds + Animation Speed + The speed of the UI animation + Slow + Medium + Fast + Custom Clock Date diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index e080c55b313..3a914d4888f 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -24,6 +24,7 @@ using ModernWpf.Controls; using Key = System.Windows.Input.Key; using System.Media; +using static Flow.Launcher.ViewModel.SettingWindowViewModel; namespace Flow.Launcher { @@ -379,11 +380,19 @@ public void WindowAnimator() CircleEase easing = new CircleEase(); easing.EasingMode = EasingMode.EaseInOut; + var animationLength = _settings.AnimationSpeed switch + { + AnimationSpeeds.Slow => 560, + AnimationSpeeds.Medium => 360, + AnimationSpeeds.Fast => 160, + _ => _settings.CustomAnimationLength + }; + var WindowOpacity = new DoubleAnimation { From = 0, To = 1, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength * 2 / 3), + Duration = TimeSpan.FromMilliseconds(animationLength * 2 / 3), FillBehavior = FillBehavior.Stop }; @@ -391,7 +400,7 @@ public void WindowAnimator() { From = Top + 10, To = Top, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength * 2 / 3), + Duration = TimeSpan.FromMilliseconds(animationLength * 2 / 3), FillBehavior = FillBehavior.Stop }; var IconMotion = new DoubleAnimation @@ -399,7 +408,7 @@ public void WindowAnimator() From = 12, To = 0, EasingFunction = easing, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), + Duration = TimeSpan.FromMilliseconds(animationLength), FillBehavior = FillBehavior.Stop }; @@ -408,7 +417,7 @@ public void WindowAnimator() From = 0, To = 1, EasingFunction = easing, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), + Duration = TimeSpan.FromMilliseconds(animationLength), FillBehavior = FillBehavior.Stop }; double TargetIconOpacity = SearchIcon.Opacity; // Animation Target Opacity from Style @@ -417,7 +426,7 @@ public void WindowAnimator() From = 0, To = TargetIconOpacity, EasingFunction = easing, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), + Duration = TimeSpan.FromMilliseconds(animationLength), FillBehavior = FillBehavior.Stop }; @@ -427,7 +436,7 @@ public void WindowAnimator() From = new Thickness(0, 12, right, 0), To = new Thickness(0, 0, right, 0), EasingFunction = easing, - Duration = TimeSpan.FromMilliseconds(_settings.AnimationLength), + Duration = TimeSpan.FromMilliseconds(animationLength), FillBehavior = FillBehavior.Stop }; diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index ce0b55de758..1e886c022b2 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2403,6 +2403,7 @@ - + + + + + + - - + + - - + DisplayMemberPath="Display" + FontSize="14" + ItemsSource="{Binding AnimationSpeeds}" + SelectedValue="{Binding Settings.AnimationSpeed}" + SelectedValuePath="Value"> + + + + + + + - - - - - - - - + + + + + + + + + + - +  - - - - + + diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index d8d2801e576..231e65539ef 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -598,10 +598,31 @@ public bool UseAnimation set => Settings.UseAnimation = value; } - public int AnimationLength + public class AnimationSpeed { - get => Settings.AnimationLength; - set => Settings.AnimationLength = value; + public string Display { get; set; } + public AnimationSpeeds Value { get; set; } + } + + public List AnimationSpeeds + { + get + { + List speeds = new List(); + var enums = (AnimationSpeeds[])Enum.GetValues(typeof(AnimationSpeeds)); + foreach (var e in enums) + { + var key = $"AnimationSpeed{e}"; + var display = _translater.GetTranslation(key); + var m = new AnimationSpeed + { + Display = display, + Value = e, + }; + speeds.Add(m); + } + return speeds; + } } public bool UseSound