Skip to content

Commit 06389fe

Browse files
committed
Merge branch 'fix-theme-issues' of https://github.com/Flow-Launcher/Flow.Launcher into fix-theme-issues
2 parents 64a50d8 + 68b9169 commit 06389fe

10 files changed

Lines changed: 235 additions & 129 deletions

File tree

Flow.Launcher.Test/Flow.Launcher.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
</ItemGroup>
4040

4141
<ItemGroup>
42+
<ProjectReference Include="..\Flow.Launcher\Flow.Launcher.csproj" />
4243
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Calculator\Flow.Launcher.Plugin.Calculator.csproj" />
4344
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Explorer\Flow.Launcher.Plugin.Explorer.csproj" />
4445
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Program\Flow.Launcher.Plugin.Program.csproj" />
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Windows;
4+
using System.Windows.Input;
5+
using System.Windows.Interop;
6+
using Flow.Launcher.Resources.Controls;
7+
using NUnit.Framework;
8+
9+
namespace Flow.Launcher.Test;
10+
11+
[TestFixture]
12+
public class MouseWheelTest
13+
{
14+
[Test]
15+
[RequiresThread(System.Threading.ApartmentState.STA)]
16+
public void Test_Scroll_MouseWheel()
17+
{
18+
var scrollView = new CustomScrollViewerEx();
19+
20+
var mouseDevice = Mouse.PrimaryDevice;
21+
var e = new MouseWheelEventArgs(mouseDevice, Environment.TickCount, 120)
22+
{
23+
RoutedEvent = UIElement.MouseWheelEvent
24+
};
25+
26+
var onMouseWheelMethod = typeof(CustomScrollViewerEx).GetMethod(
27+
"OnMouseWheel",
28+
BindingFlags.NonPublic | BindingFlags.Instance
29+
);
30+
31+
Assert.DoesNotThrow(() =>
32+
{
33+
onMouseWheelMethod.Invoke(scrollView, new object[] { e });
34+
});
35+
}
36+
}

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
</Border>
338338
<Line
339339
x:Name="ProgressBar"
340+
Style="{DynamicResource PendingLineStyle}"
340341
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
341342
Height="2"
342343
Margin="12 0 12 0"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public partial class MainWindow : IDisposable
7575
// Window Animation
7676
private const double DefaultRightMargin = 66; //* this value from base.xaml
7777
private bool _isClockPanelAnimating = false;
78+
private Storyboard _progressBarStoryboard;
7879

7980
// IDisposable
8081
private bool _disposed = false;
@@ -1120,49 +1121,58 @@ private double VerticalTop(MonitorInfo screen)
11201121

11211122
private void InitProgressbarAnimation()
11221123
{
1123-
var progressBarStoryBoard = new Storyboard();
1124+
_progressBarStoryboard = new Storyboard();
11241125

1125-
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100,
1126-
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
1127-
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 0,
1128-
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
1129-
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
1130-
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
1131-
progressBarStoryBoard.Children.Add(da);
1132-
progressBarStoryBoard.Children.Add(da1);
1133-
progressBarStoryBoard.RepeatBehavior = RepeatBehavior.Forever;
1126+
var animationDuration = new Duration(TimeSpan.FromMilliseconds(1600));
1127+
var progressBarLength = ProgressBar.X2 - ProgressBar.X1;
11341128

1135-
da.Freeze();
1136-
da1.Freeze();
1137-
1138-
const string progressBarAnimationName = "ProgressBarAnimation";
1139-
var beginStoryboard = new BeginStoryboard
1129+
var lineEndAnimation = new DoubleAnimation
11401130
{
1141-
Name = progressBarAnimationName, Storyboard = progressBarStoryBoard
1131+
From = ProgressBar.X2,
1132+
To = ProgressBar.ActualWidth + progressBarLength,
1133+
Duration = animationDuration
11421134
};
1143-
1144-
var stopStoryboard = new StopStoryboard()
1135+
var lineStartAnimation = new DoubleAnimation
11451136
{
1146-
BeginStoryboardName = progressBarAnimationName
1137+
From = ProgressBar.X1,
1138+
To = ProgressBar.ActualWidth,
1139+
Duration = animationDuration
11471140
};
1141+
1142+
Storyboard.SetTarget(lineEndAnimation, ProgressBar);
1143+
Storyboard.SetTargetProperty(lineEndAnimation, new PropertyPath("(Line.X2)"));
1144+
1145+
Storyboard.SetTarget(lineStartAnimation, ProgressBar);
1146+
Storyboard.SetTargetProperty(lineStartAnimation, new PropertyPath("(Line.X1)"));
1147+
1148+
_progressBarStoryboard.Children.Add(lineEndAnimation);
1149+
_progressBarStoryboard.Children.Add(lineStartAnimation);
1150+
_progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
1151+
1152+
lineEndAnimation.Freeze();
1153+
lineStartAnimation.Freeze();
1154+
1155+
ProgressBar.IsVisibleChanged -= ProgressBar_IsVisibleChanged;
1156+
ProgressBar.IsVisibleChanged += ProgressBar_IsVisibleChanged;
11481157

1149-
var trigger = new Trigger
1150-
{
1151-
Property = VisibilityProperty, Value = Visibility.Visible
1152-
};
1153-
trigger.EnterActions.Add(beginStoryboard);
1154-
trigger.ExitActions.Add(stopStoryboard);
1158+
_viewModel.ProgressBarVisibility = Visibility.Hidden;
1159+
}
11551160

1156-
var progressStyle = new Style(typeof(Line))
1161+
private void ProgressBar_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
1162+
{
1163+
if (_progressBarStoryboard == null)
11571164
{
1158-
BasedOn = FindResource("PendingLineStyle") as Style
1159-
};
1160-
progressStyle.RegisterName(progressBarAnimationName, beginStoryboard);
1161-
progressStyle.Triggers.Add(trigger);
1162-
1163-
ProgressBar.Style = progressStyle;
1165+
return;
1166+
}
11641167

1165-
_viewModel.ProgressBarVisibility = Visibility.Hidden;
1168+
if (ProgressBar.IsVisible)
1169+
{
1170+
_progressBarStoryboard.Begin(ProgressBar, true);
1171+
}
1172+
else
1173+
{
1174+
_progressBarStoryboard.Stop(ProgressBar);
1175+
}
11661176
}
11671177

11681178
private void WindowAnimation()

Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public Orientation Orientation
4444
#region AutoHideScrollBars
4545

4646
public static readonly DependencyProperty AutoHideScrollBarsProperty =
47-
ScrollViewerHelper.AutoHideScrollBarsProperty
48-
.AddOwner(
47+
ScrollViewerHelper.AutoHideScrollBarsProperty.AddOwner(
4948
typeof(CustomScrollViewerEx),
5049
new PropertyMetadata(true, OnAutoHideScrollBarsChanged));
5150

@@ -86,6 +85,9 @@ protected override void OnInitialized(EventArgs e)
8685
/// <inheritdoc/>
8786
protected override void OnMouseWheel(MouseWheelEventArgs e)
8887
{
88+
if (ActualHeight <= 0)
89+
return;
90+
8991
var Direction = GetDirection();
9092
ScrollViewerBehavior.SetIsAnimating(this, true);
9193

Plugins/Flow.Launcher.Plugin.Program/NativeMethods.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ SLR_FLAGS
1010
IShellItem
1111
SHCreateItemFromParsingName
1212
IShellLinkW
13-
CoTaskMemFree
13+
ShellLink
14+
CoTaskMemFree
15+
IPropertyStore
16+
PROPERTYKEY
17+
PROPVARIANT
18+
PKEY_Link_Arguments
19+
PropVariantClear
20+
VARENUM
21+
INFOTIPSIZE
22+
MAX_PATH

Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Flow.Launcher.Plugin.Program.Programs
2+
{
3+
public readonly record struct ShellLinkReadResult(string TargetPath, string Description, string Arguments);
4+
}

0 commit comments

Comments
 (0)