mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2199 from AlexDavies8/dev
Added Animation Length slider
This commit is contained in:
commit
06e9149995
5 changed files with 127 additions and 18 deletions
|
|
@ -254,6 +254,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
[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();
|
||||
|
|
@ -290,4 +294,12 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
RightTop,
|
||||
Custom
|
||||
}
|
||||
|
||||
public enum AnimationSpeeds
|
||||
{
|
||||
Slow,
|
||||
Medium,
|
||||
Fast,
|
||||
Custom
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ using System.Windows.Data;
|
|||
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 @@ namespace Flow.Launcher
|
|||
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
|
||||
};
|
||||
|
||||
|
|
@ -391,7 +400,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
From = Top + 10,
|
||||
To = Top,
|
||||
Duration = TimeSpan.FromSeconds(0.25),
|
||||
Duration = TimeSpan.FromMilliseconds(animationLength * 2 / 3),
|
||||
FillBehavior = FillBehavior.Stop
|
||||
};
|
||||
var IconMotion = new DoubleAnimation
|
||||
|
|
@ -399,7 +408,7 @@ namespace Flow.Launcher
|
|||
From = 12,
|
||||
To = 0,
|
||||
EasingFunction = easing,
|
||||
Duration = TimeSpan.FromSeconds(0.36),
|
||||
Duration = TimeSpan.FromMilliseconds(animationLength),
|
||||
FillBehavior = FillBehavior.Stop
|
||||
};
|
||||
|
||||
|
|
@ -408,7 +417,7 @@ namespace Flow.Launcher
|
|||
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
|
||||
|
|
@ -417,7 +426,7 @@ namespace Flow.Launcher
|
|||
From = 0,
|
||||
To = TargetIconOpacity,
|
||||
EasingFunction = easing,
|
||||
Duration = TimeSpan.FromSeconds(0.36),
|
||||
Duration = TimeSpan.FromMilliseconds(animationLength),
|
||||
FillBehavior = FillBehavior.Stop
|
||||
};
|
||||
|
||||
|
|
@ -427,7 +436,7 @@ namespace Flow.Launcher
|
|||
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
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
@ -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}">
|
||||

|
||||
</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}">
|
||||

|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
|
||||
<Border Margin="0,12,0,12" Style="{DynamicResource SettingGroupBox}">
|
||||
|
|
|
|||
|
|
@ -598,6 +598,33 @@ namespace Flow.Launcher.ViewModel
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue