Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,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();
Expand Down Expand Up @@ -290,4 +294,12 @@ public enum SearchWindowAligns
RightTop,
Custom
}

public enum AnimationSpeeds
{
Slow,
Medium,
Fast,
Custom
}
}
6 changes: 6 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@
<system:String x:Key="SoundEffectTip">Play a small sound when the search window opens</system:String>
<system:String x:Key="Animation">Animation</system:String>
<system:String x:Key="AnimationTip">Use Animation in UI</system:String>
<system:String x:Key="AnimationSpeed">Animation Speed</system:String>
<system:String x:Key="AnimationSpeedTip">The speed of the UI animation</system:String>
<system:String x:Key="AnimationSpeedSlow">Slow</system:String>
<system:String x:Key="AnimationSpeedMedium">Medium</system:String>
<system:String x:Key="AnimationSpeedFast">Fast</system:String>
<system:String x:Key="AnimationSpeedCustom">Custom</system:String>
<system:String x:Key="Clock">Clock</system:String>
<system:String x:Key="Date">Date</system:String>

Expand Down
21 changes: 15 additions & 6 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -379,27 +380,35 @@ 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.FromSeconds(0.25),
Duration = TimeSpan.FromMilliseconds(animationLength * 2 / 3),
FillBehavior = FillBehavior.Stop
};

var WindowMotion = new DoubleAnimation
{
From = Top + 10,
To = Top,
Duration = TimeSpan.FromSeconds(0.25),
Duration = TimeSpan.FromMilliseconds(animationLength * 2 / 3),
FillBehavior = FillBehavior.Stop
};
var IconMotion = new DoubleAnimation
{
From = 12,
To = 0,
EasingFunction = easing,
Duration = TimeSpan.FromSeconds(0.36),
Duration = TimeSpan.FromMilliseconds(animationLength),
FillBehavior = FillBehavior.Stop
};

Expand All @@ -408,7 +417,7 @@ public void WindowAnimator()
From = 0,
To = 1,
EasingFunction = easing,
Duration = TimeSpan.FromSeconds(0.36),
Duration = TimeSpan.FromMilliseconds(animationLength),
FillBehavior = FillBehavior.Stop
};
double TargetIconOpacity = SearchIcon.Opacity; // Animation Target Opacity from Style
Expand All @@ -417,7 +426,7 @@ public void WindowAnimator()
From = 0,
To = TargetIconOpacity,
EasingFunction = easing,
Duration = TimeSpan.FromSeconds(0.36),
Duration = TimeSpan.FromMilliseconds(animationLength),
FillBehavior = FillBehavior.Stop
};

Expand All @@ -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.FromSeconds(0.36),
Duration = TimeSpan.FromMilliseconds(animationLength),
FillBehavior = FillBehavior.Stop
};

Expand Down
79 changes: 67 additions & 12 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,7 @@
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AnimationTip}" />
</StackPanel>
<ui:ToggleSwitch
x:Name="Animation"
Grid.Row="0"
Grid.Column="2"
IsOn="{Binding UseAnimation, Mode=TwoWay}"
Expand All @@ -2418,28 +2419,82 @@
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<Border Margin="0" BorderThickness="0">
<Border.Style>
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Animation, Path=IsOn}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>

<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource AnimationSpeed}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AnimationSpeedTip}" />
</StackPanel>
<ui:ToggleSwitch
<StackPanel Grid.Column="2" Orientation="Horizontal">
<ComboBox
x:Name="AnimationSpeed"
MinWidth="160"
Margin="0,0,18,0"
VerticalAlignment="Center"
DisplayMemberPath="Display"
FontSize="14"
ItemsSource="{Binding AnimationSpeeds}"
SelectedValue="{Binding Settings.AnimationSpeed}"
SelectedValuePath="Value">
</ComboBox>
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=AnimationSpeed, Path=SelectedValue}" Value="{x:Static userSettings:AnimationSpeeds.Custom}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBox
Height="35"
MinWidth="80"
Text="{Binding Settings.CustomAnimationLength}"
TextWrapping="NoWrap" />
</StackPanel>
</StackPanel>
<TextBlock Style="{StaticResource Glyph}">
&#xe916;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
</Border>


<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Row="0"
Grid.Column="2"
IsOn="{Binding UseSound, Mode=TwoWay}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
Style="{DynamicResource SideToggleSwitch}" />
<TextBlock Style="{StaticResource Glyph}">
<TextBlock Style="{StaticResource Glyph}">
&#xe994;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
</TextBlock>
</ItemsControl>
</Border>

<Border Margin="0,12,0,12" Style="{DynamicResource SettingGroupBox}">
Expand Down
27 changes: 27 additions & 0 deletions Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,33 @@ public bool UseAnimation
set => Settings.UseAnimation = value;
}

public class AnimationSpeed
{
public string Display { get; set; }
public AnimationSpeeds Value { get; set; }
}

public List<AnimationSpeed> AnimationSpeeds
{
get
{
List<AnimationSpeed> speeds = new List<AnimationSpeed>();
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
{
get => Settings.UseSound;
Expand Down