From 2daf1ff2b38068988b538c4f7cfa1fd028fb33ba Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 22 Nov 2022 02:49:10 +0900 Subject: [PATCH] - Adjust Animation / Formatting --- Flow.Launcher/MainWindow.xaml.cs | 89 ++++++++++++++++++++++------ Flow.Launcher/Themes/Base.xaml | 32 ++++------ Flow.Launcher/Themes/Win11Light.xaml | 1 + 3 files changed, 85 insertions(+), 37 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 10b22e33a..6d6549250 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -30,6 +30,10 @@ using System.Windows.Data; using ModernWpf.Controls; using System.Drawing; using System.Windows.Forms.Design.Behavior; +using System.Security.Cryptography; +using System.Runtime.CompilerServices; +using Microsoft.VisualBasic.Devices; +using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames; namespace Flow.Launcher { @@ -105,7 +109,6 @@ namespace Flow.Launcher // since the default main window visibility is visible // so we need set focus during startup QueryTextBox.Focus(); - _viewModel.PropertyChanged += (o, e) => { switch (e.PropertyName) @@ -243,7 +246,9 @@ namespace Flow.Launcher Icon = Properties.Resources.app, Visible = !_settings.HideNotifyIcon }; + contextMenu = new ContextMenu(); + var openIcon = new FontIcon { Glyph = "\ue71e" }; var open = new MenuItem { @@ -280,9 +285,11 @@ namespace Flow.Launcher positionreset.Click += (o, e) => PositionReset(); settings.Click += (o, e) => App.API.OpenSettingDialog(); exit.Click += (o, e) => Close(); - contextMenu.Items.Add(open); + gamemode.ToolTip = InternationalizationManager.Instance.GetTranslation("GameModeToolTip"); positionreset.ToolTip = InternationalizationManager.Instance.GetTranslation("PositionResetToolTip"); + + contextMenu.Items.Add(open); contextMenu.Items.Add(gamemode); contextMenu.Items.Add(positionreset); contextMenu.Items.Add(settings); @@ -359,11 +366,14 @@ namespace Flow.Launcher _animating = true; UpdatePosition(); - Storyboard sb = new Storyboard(); + + Storyboard windowsb = new Storyboard(); + Storyboard clocksb = new Storyboard(); Storyboard iconsb = new Storyboard(); - CircleEase easing = new CircleEase(); // or whatever easing class you want + CircleEase easing = new CircleEase(); easing.EasingMode = EasingMode.EaseInOut; - var da = new DoubleAnimation + + var WindowOpacity = new DoubleAnimation { From = 0, To = 1, @@ -371,33 +381,76 @@ namespace Flow.Launcher FillBehavior = FillBehavior.Stop }; - var da2 = new DoubleAnimation + var WindowMotion = new DoubleAnimation { From = Top + 10, To = Top, Duration = TimeSpan.FromSeconds(0.25), FillBehavior = FillBehavior.Stop }; - var da3 = new DoubleAnimation - { + var IconMotion = new DoubleAnimation + { From = 12, To = 0, EasingFunction = easing, Duration = TimeSpan.FromSeconds(0.36), FillBehavior = FillBehavior.Stop - }; - Storyboard.SetTarget(da, this); - Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty)); - Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty)); - Storyboard.SetTargetProperty(da3, new PropertyPath(TopProperty)); - sb.Children.Add(da); - sb.Children.Add(da2); - iconsb.Children.Add(da3); - sb.Completed += (_, _) => _animating = false; + }; + + var ClockOpacity = new DoubleAnimation + { + From = 0, + To = 1, + EasingFunction = easing, + Duration = TimeSpan.FromSeconds(0.36), + FillBehavior = FillBehavior.Stop + }; + double TargetIconOpacity = SearchIcon.Opacity; // Animation Target Opacity from Style + var IconOpacity = new DoubleAnimation + { + From = 0, + To = TargetIconOpacity, + EasingFunction = easing, + Duration = TimeSpan.FromSeconds(0.36), + FillBehavior = FillBehavior.Stop + }; + + double right = ClockPanel.Margin.Right; + var thicknessAnimation = new ThicknessAnimation + { + From = new Thickness(0, 12, right, 0), + To = new Thickness(0, 0, right, 0), + EasingFunction = easing, + Duration = TimeSpan.FromSeconds(0.36), + FillBehavior = FillBehavior.Stop + }; + + Storyboard.SetTargetProperty(ClockOpacity, new PropertyPath(OpacityProperty)); + Storyboard.SetTargetName(thicknessAnimation, "ClockPanel"); + Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath(MarginProperty)); + Storyboard.SetTarget(WindowOpacity, this); + Storyboard.SetTargetProperty(WindowOpacity, new PropertyPath(Window.OpacityProperty)); + Storyboard.SetTargetProperty(WindowMotion, new PropertyPath(Window.TopProperty)); + Storyboard.SetTargetProperty(IconMotion, new PropertyPath(TopProperty)); + Storyboard.SetTargetProperty(IconOpacity, new PropertyPath(OpacityProperty)); + + clocksb.Children.Add(thicknessAnimation); + clocksb.Children.Add(ClockOpacity); + windowsb.Children.Add(WindowOpacity); + windowsb.Children.Add(WindowMotion); + iconsb.Children.Add(IconMotion); + iconsb.Children.Add(IconOpacity); + + windowsb.Completed += (_, _) => _animating = false; _settings.WindowLeft = Left; _settings.WindowTop = Top; + + if (QueryTextBox.Text.Length == 0) + { + clocksb.Begin(ClockPanel); + } iconsb.Begin(SearchIcon); - sb.Begin(FlowMainWindow); + windowsb.Begin(FlowMainWindow); } private void OnMouseDown(object sender, MouseButtonEventArgs e) diff --git a/Flow.Launcher/Themes/Base.xaml b/Flow.Launcher/Themes/Base.xaml index 23c5a5e86..cb0921b80 100644 --- a/Flow.Launcher/Themes/Base.xaml +++ b/Flow.Launcher/Themes/Base.xaml @@ -79,18 +79,18 @@ - @@ -379,6 +367,12 @@ +