Skip to content

Commit

Permalink
Fix: Fixed grip splitter cursor behavior for preview pane and seconda…
Browse files Browse the repository at this point in the history
…ry pane (#12047)
  • Loading branch information
gave92 authored Apr 14, 2023
1 parent 40c7285 commit 4d60f41
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 49 deletions.
18 changes: 9 additions & 9 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}" />

Expand All @@ -390,7 +390,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.TagColumn.Visibility, Mode=OneWay}" />
Expand All @@ -410,7 +410,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.OriginalPathColumn.Visibility, Mode=OneWay}" />
Expand All @@ -430,7 +430,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.DateDeletedColumn.Visibility, Mode=OneWay}" />
Expand All @@ -450,7 +450,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.DateModifiedColumn.Visibility, Mode=OneWay}" />
Expand All @@ -470,7 +470,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.DateCreatedColumn.Visibility, Mode=OneWay}" />
Expand All @@ -490,7 +490,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.ItemTypeColumn.Visibility, Mode=OneWay}" />
Expand All @@ -510,7 +510,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.SizeColumn.Visibility, Mode=OneWay}" />
Expand All @@ -532,7 +532,7 @@
Loaded="GridSplitter_Loaded"
ManipulationCompleted="GridSplitter_ManipulationCompleted"
ManipulationDelta="GridSplitter_ManipulationDelta"
ManipulationStarting="GridSplitter_ManipulationStarting"
ManipulationStarted="GridSplitter_ManipulationStarted"
PreviewKeyUp="GridSplitter_PreviewKeyUp"
Style="{StaticResource HeaderGridSplitterStyle}"
Visibility="{x:Bind ColumnsViewModel.StatusColumn.Visibility, Mode=OneWay}" />
Expand Down
13 changes: 4 additions & 9 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public sealed partial class DetailsLayoutBrowser : StandardViewBase

private uint currentIconSize;

private InputCursor arrowCursor = InputCursor.CreateFromCoreCursor(new CoreCursor(CoreCursorType.Arrow, 0));

private InputCursor resizeCursor = InputCursor.CreateFromCoreCursor(new CoreCursor(CoreCursorType.SizeWestEast, 1));

private ListedItem? _nextItemToSelect;

protected override uint IconSize => currentIconSize;
Expand Down Expand Up @@ -511,20 +507,20 @@ private void RootGrid_SizeChanged(object? sender, SizeChangedEventArgs? e)
MaxWidthForRenameTextbox = Math.Max(0, RootGrid.ActualWidth - 80);
}

private void GridSplitter_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
private void GridSplitter_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
this.ChangeCursor(resizeCursor);
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
}

private void GridSplitter_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
FolderSettings.ColumnsViewModel = ColumnsViewModel;
this.ChangeCursor(arrowCursor);
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
}

private void GridSplitter_Loaded(object sender, RoutedEventArgs e)
{
(sender as UIElement).ChangeCursor(resizeCursor);
(sender as UIElement)?.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
}

private void ToggleMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
Expand All @@ -537,7 +533,6 @@ private void GridSplitter_DoubleTapped(object sender, DoubleTappedRoutedEventArg
var columnToResize = Grid.GetColumn(sender as CommunityToolkit.WinUI.UI.Controls.GridSplitter) / 2 + 1;
ResizeColumnToFit(columnToResize);

this.ChangeCursor(arrowCursor);
e.Handled = true;
}

Expand Down
3 changes: 0 additions & 3 deletions src/Files.App/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@
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
35 changes: 9 additions & 26 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public sealed partial class MainPage : Page, INotifyPropertyChanged
public static AppModel AppModel
=> App.AppModel;

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

private bool keyReleased = true;

public MainPage()
Expand Down Expand Up @@ -451,6 +446,7 @@ private void UpdatePositioning()
PaneSplitter.Width = 2;
PaneSplitter.Height = RootGrid.ActualHeight;
PaneSplitter.GripperCursor = GridSplitter.GripperCursorType.SizeWestEast;
PaneSplitter.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
PaneColumn.MinWidth = PreviewPane.MinWidth;
PaneColumn.MaxWidth = PreviewPane.MaxWidth;
PaneColumn.Width = new GridLength(UserSettingsService.PreviewPaneSettingsService.VerticalSizePx, GridUnitType.Pixel);
Expand All @@ -466,6 +462,7 @@ private void UpdatePositioning()
PaneSplitter.Height = 2;
PaneSplitter.Width = RootGrid.ActualWidth;
PaneSplitter.GripperCursor = GridSplitter.GripperCursorType.SizeNorthSouth;
PaneSplitter.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeNorthSouth));
PaneColumn.MinWidth = 0;
PaneColumn.MaxWidth = double.MaxValue;
PaneColumn.Width = new GridLength(0);
Expand All @@ -477,11 +474,6 @@ 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 @@ -494,22 +486,7 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
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));
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
}

public bool ShouldPreviewPaneBeActive => UserSettingsService.PreviewPaneSettingsService.IsEnabled && ShouldPreviewPaneBeDisplayed;
Expand Down Expand Up @@ -563,5 +540,11 @@ private void RootGrid_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
}

private void NavToolbar_Loaded(object sender, RoutedEventArgs e) => UpdateNavToolbarProperties();

private void PaneSplitter_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
this.ChangeCursor(InputSystemCursor.Create(PaneSplitter.GripperCursor == GridSplitter.GripperCursorType.SizeWestEast ?
InputSystemCursorShape.SizeWestEast : InputSystemCursorShape.SizeNorthSouth));
}
}
}
4 changes: 2 additions & 2 deletions src/Files.App/Views/PaneHolderPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
HorizontalAlignment="Left"
Background="Transparent"
Canvas.ZIndex="150"
CursorBehavior="ChangeOnSplitterHover"
DoubleTapped="PaneResizer_OnDoubleTapped"
Foreground="Transparent"
GripperCursor="Default"
GripperForeground="Transparent"
IsTabStop="False"
Loaded="PaneResizer_Loaded"
ManipulationCompleted="PaneResizer_ManipulationCompleted"
ManipulationStarted="PaneResizer_ManipulationStarted"
ResizeBehavior="BasedOnAlignment"
ResizeDirection="Auto"
Style="{StaticResource DefaultGridSplitterStyle}">
Expand Down
14 changes: 14 additions & 0 deletions src/Files.App/Views/PaneHolderPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Files.App.UserControls.MultitaskingControl;
using Files.App.Views.LayoutModes;
using Files.Backend.Services.Settings;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
Expand All @@ -11,6 +12,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using UWPToWinAppSDKUpgradeHelpers;
using Windows.System;

namespace Files.App.Views
Expand Down Expand Up @@ -248,6 +250,8 @@ private void PaneResizer_ManipulationCompleted(object sender, ManipulationComple
{
if (PaneRight is not null && PaneRight.ActualWidth <= 300)
IsRightPaneVisible = false;

this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
}

private void Pane_ContentChanged(object sender, TabItemArguments e)
Expand Down Expand Up @@ -338,6 +342,16 @@ private void PaneResizer_OnDoubleTapped(object sender, DoubleTappedRoutedEventAr
LeftColumn.Width = new GridLength(1, GridUnitType.Star);
RightColumn.Width = new GridLength(1, GridUnitType.Star);
}

private void PaneResizer_Loaded(object sender, RoutedEventArgs e)
{
PaneResizer.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
}

private void PaneResizer_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
}
}

public class PaneNavigationArguments
Expand Down

0 comments on commit 4d60f41

Please sign in to comment.