Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where the preview pane had the wrong cursor when resizing #11388

Merged
merged 2 commits into from
Feb 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="IsFocusEngagementEnabled" Value="True" />
<Setter Property="MinWidth" Value="2" />
<Setter Property="MinWidth" Value="4" />
<Setter Property="MinHeight" Value="2" />
<Setter Property="BorderBrush" Value="{ThemeResource SplitterBorderBrush}" />
<Setter Property="Background" Value="Transparent" />
Expand Down
4 changes: 4 additions & 0 deletions src/Files.App/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@
Grid.Column="1"
x:Load="{x:Bind ShouldPreviewPaneBeActive, Mode=OneWay}"
ManipulationCompleted="PaneSplitter_ManipulationCompleted"
ManipulationStarted="PaneSplitter_ManipulationStarted"
PointerCanceled="PaneSplitter_PointerExited"
PointerEntered="PaneSplitter_PointerEntered"
PointerExited="PaneSplitter_PointerExited"
ResizeBehavior="BasedOnAlignment"
Style="{StaticResource DefaultGridSplitterStyle}" />

Expand Down
32 changes: 31 additions & 1 deletion src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Files.Backend.Extensions;
using Files.Backend.Services.Settings;
using Files.Shared.EventArguments;
using Microsoft.UI.Input;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -25,6 +26,7 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Input;
using UWPToWinAppSDKUpgradeHelpers;
using Windows.ApplicationModel;
using Windows.Graphics;
using Windows.Services.Store;
Expand All @@ -48,6 +50,12 @@ public MainPageViewModel ViewModel
set => DataContext = value;
}


/// <summary>
/// True if the user is currently resizing the preview pane
/// </summary>
private bool draggingPreviewPane;

public SidebarViewModel SidebarAdaptiveViewModel = new SidebarViewModel();

public OngoingTasksViewModel OngoingTasksViewModel => App.OngoingTasksViewModel;
Expand Down Expand Up @@ -321,7 +329,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
return;

var totalLaunchCount = SystemInformation.Instance.TotalLaunchCount;
if(totalLaunchCount is 10 or 20 or 30 or 40 or 50)
if (totalLaunchCount is 10 or 20 or 30 or 40 or 50)
{
// Prompt user to review app in the Store
DispatcherQueue.TryEnqueue(async () => await PromptForReview());
Expand Down Expand Up @@ -416,6 +424,11 @@ private void UpdatePositioning()
}
}

private void PaneSplitter_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
draggingPreviewPane = true;
}

private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
switch (PreviewPane?.Position)
Expand All @@ -427,6 +440,23 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
UserSettingsService.PreviewPaneSettingsService.HorizontalSizePx = PreviewPane.ActualHeight;
break;
}

draggingPreviewPane = false;
}

private void PaneSplitter_PointerExited(object sender, PointerRoutedEventArgs e)
{
if (draggingPreviewPane)
return;

var paneSplitter = (GridSplitter)sender;
paneSplitter.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
}

private void PaneSplitter_PointerEntered(object sender, PointerRoutedEventArgs e)
{
var paneSplitter = (GridSplitter)sender;
paneSplitter.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
}

public bool ShouldPreviewPaneBeActive => UserSettingsService.PreviewPaneSettingsService.IsEnabled && ShouldPreviewPaneBeDisplayed;
Expand Down