diff --git a/src/Files.App.Controls/GridSplitter/GridSplitter.Data.cs b/src/Files.App.Controls/GridSplitter/GridSplitter.Data.cs index 595329fbe3b7..af8123f70a33 100644 --- a/src/Files.App.Controls/GridSplitter/GridSplitter.Data.cs +++ b/src/Files.App.Controls/GridSplitter/GridSplitter.Data.cs @@ -4,153 +4,147 @@ namespace Files.App.Controls { /// - /// Represents the control that redistributes space between columns or rows of a Grid control. + /// Enum to indicate whether GridSplitter resizes Columns or Rows /// - public partial class GridSplitter + public enum GridResizeDirection { /// - /// Enum to indicate whether GridSplitter resizes Columns or Rows - /// - public enum GridResizeDirection - { - /// - /// Determines whether to resize rows or columns based on its Alignment and - /// width compared to height - /// - Auto, - - /// - /// Resize columns when dragging Splitter. - /// - Columns, - - /// - /// Resize rows when dragging Splitter. - /// - Rows - } - - /// - /// Enum to indicate what Columns or Rows the GridSplitter resizes - /// - public enum GridResizeBehavior - { - /// - /// Determine which columns or rows to resize based on its Alignment. - /// - BasedOnAlignment, - - /// - /// Resize the current and next Columns or Rows. - /// - CurrentAndNext, - - /// - /// Resize the previous and current Columns or Rows. - /// - PreviousAndCurrent, - - /// - /// Resize the previous and next Columns or Rows. - /// - PreviousAndNext - } - - /// - /// Enum to indicate the supported gripper cursor types. - /// - public enum GripperCursorType - { - /// - /// Change the cursor based on the splitter direction - /// - Default = -1, - - /// - /// Standard Arrow cursor - /// - Arrow, - - /// - /// Standard Cross cursor - /// - Cross, - - /// - /// Standard Custom cursor - /// - Custom, - - /// - /// Standard Hand cursor - /// - Hand, - - /// - /// Standard Help cursor - /// - Help, - - /// - /// Standard IBeam cursor - /// - IBeam, - - /// - /// Standard SizeAll cursor - /// - SizeAll, - - /// - /// Standard SizeNortheastSouthwest cursor - /// - SizeNortheastSouthwest, - - /// - /// Standard SizeNorthSouth cursor - /// - SizeNorthSouth, - - /// - /// Standard SizeNorthwestSoutheast cursor - /// - SizeNorthwestSoutheast, - - /// - /// Standard SizeWestEast cursor - /// - SizeWestEast, - - /// - /// Standard UniversalNo cursor - /// - UniversalNo, - - /// - /// Standard UpArrow cursor - /// - UpArrow, - - /// - /// Standard Wait cursor - /// - Wait - } - - /// - /// Enum to indicate the behavior of window cursor on grid splitter hover - /// - public enum SplitterCursorBehavior - { - /// - /// Update window cursor on Grid Splitter hover - /// - ChangeOnSplitterHover, - - /// - /// Update window cursor on Grid Splitter Gripper hover - /// - ChangeOnGripperHover - } + /// Determines whether to resize rows or columns based on its Alignment and + /// width compared to height + /// + Auto, + + /// + /// Resize columns when dragging Splitter. + /// + Columns, + + /// + /// Resize rows when dragging Splitter. + /// + Rows + } + + /// + /// Enum to indicate what Columns or Rows the GridSplitter resizes + /// + public enum GridResizeBehavior + { + /// + /// Determine which columns or rows to resize based on its Alignment. + /// + BasedOnAlignment, + + /// + /// Resize the current and next Columns or Rows. + /// + CurrentAndNext, + + /// + /// Resize the previous and current Columns or Rows. + /// + PreviousAndCurrent, + + /// + /// Resize the previous and next Columns or Rows. + /// + PreviousAndNext + } + + /// + /// Enum to indicate the supported gripper cursor types. + /// + public enum GripperCursorType + { + /// + /// Change the cursor based on the splitter direction + /// + Default = -1, + + /// + /// Standard Arrow cursor + /// + Arrow, + + /// + /// Standard Cross cursor + /// + Cross, + + /// + /// Standard Custom cursor + /// + Custom, + + /// + /// Standard Hand cursor + /// + Hand, + + /// + /// Standard Help cursor + /// + Help, + + /// + /// Standard IBeam cursor + /// + IBeam, + + /// + /// Standard SizeAll cursor + /// + SizeAll, + + /// + /// Standard SizeNortheastSouthwest cursor + /// + SizeNortheastSouthwest, + + /// + /// Standard SizeNorthSouth cursor + /// + SizeNorthSouth, + + /// + /// Standard SizeNorthwestSoutheast cursor + /// + SizeNorthwestSoutheast, + + /// + /// Standard SizeWestEast cursor + /// + SizeWestEast, + + /// + /// Standard UniversalNo cursor + /// + UniversalNo, + + /// + /// Standard UpArrow cursor + /// + UpArrow, + + /// + /// Standard Wait cursor + /// + Wait + } + + /// + /// Enum to indicate the behavior of window cursor on grid splitter hover + /// + public enum SplitterCursorBehavior + { + /// + /// Update window cursor on Grid Splitter hover + /// + ChangeOnSplitterHover, + + /// + /// Update window cursor on Grid Splitter Gripper hover + /// + ChangeOnGripperHover } } diff --git a/src/Files.App.Controls/GridSplitter/GridSplitter.Options.cs b/src/Files.App.Controls/GridSplitter/GridSplitter.Options.cs index c3f5bbab84f2..3035b90c44e1 100644 --- a/src/Files.App.Controls/GridSplitter/GridSplitter.Options.cs +++ b/src/Files.App.Controls/GridSplitter/GridSplitter.Options.cs @@ -67,7 +67,7 @@ public static readonly DependencyProperty ParentLevelProperty public static readonly DependencyProperty GripperCursorProperty = DependencyProperty.RegisterAttached( nameof(GripperCursor), - typeof(InputSystemCursorShape?), + typeof(GripperCursorType), typeof(GridSplitter), new PropertyMetadata(GripperCursorType.Default, OnGripperCursorPropertyChanged)); diff --git a/src/Files.App.Controls/GridSplitter/GripperHoverWrapper.cs b/src/Files.App.Controls/GridSplitter/GripperHoverWrapper.cs index 99e8579595e9..69f02cd5a440 100644 --- a/src/Files.App.Controls/GridSplitter/GripperHoverWrapper.cs +++ b/src/Files.App.Controls/GridSplitter/GripperHoverWrapper.cs @@ -8,16 +8,16 @@ namespace Files.App.Controls { internal class GripperHoverWrapper { - private readonly GridSplitter.GridResizeDirection _gridSplitterDirection; + private readonly GridResizeDirection _gridSplitterDirection; private InputCursor _splitterPreviousPointer; private InputCursor _previousCursor; - private GridSplitter.GripperCursorType _gripperCursor; + private GripperCursorType _gripperCursor; private int _gripperCustomCursorResource; private bool _isDragging; private UIElement _element; - internal GridSplitter.GripperCursorType GripperCursor + internal GripperCursorType GripperCursor { get { @@ -50,7 +50,7 @@ internal int GripperCustomCursorResource /// GridSplitter resize direction /// GridSplitter gripper on hover cursor type /// GridSplitter gripper custom cursor resource number - internal GripperHoverWrapper(UIElement element, GridSplitter.GridResizeDirection gridSplitterDirection, GridSplitter.GripperCursorType gripperCursor, int gripperCustomCursorResource) + internal GripperHoverWrapper(UIElement element, GridResizeDirection gridSplitterDirection, GripperCursorType gripperCursor, int gripperCustomCursorResource) { _gridSplitterDirection = gridSplitterDirection; _gripperCursor = gripperCursor; @@ -113,13 +113,13 @@ private void UpdateDisplayCursor() return; } - if (_gripperCursor == GridSplitter.GripperCursorType.Default) + if (_gripperCursor == GripperCursorType.Default) { - if (_gridSplitterDirection == GridSplitter.GridResizeDirection.Columns) + if (_gridSplitterDirection == GridResizeDirection.Columns) { // Window.Current.CoreWindow.PointerCursor = GridSplitter.ColumnsSplitterCursor; } - else if (_gridSplitterDirection == GridSplitter.GridResizeDirection.Rows) + else if (_gridSplitterDirection == GridResizeDirection.Rows) { // Window.Current.CoreWindow.PointerCursor = GridSplitter.RowSplitterCursor; } @@ -127,7 +127,7 @@ private void UpdateDisplayCursor() else { var inputSystemCursorShape = (InputSystemCursorShape)((int)_gripperCursor); - if (_gripperCursor == GridSplitter.GripperCursorType.Custom) + if (_gripperCursor == GripperCursorType.Custom) { if (_gripperCustomCursorResource > GridSplitter.GripperCustomCursorDefaultResource) { diff --git a/src/Files.App/Views/MainPage.xaml b/src/Files.App/Views/MainPage.xaml index 73587546e8e5..8661673c530d 100644 --- a/src/Files.App/Views/MainPage.xaml +++ b/src/Files.App/Views/MainPage.xaml @@ -198,7 +198,7 @@ Height="*" MinHeight="100" /> - + @@ -207,7 +207,7 @@ Width="*" MinWidth="208" /> - + @@ -232,9 +232,9 @@ HorizontalContentAlignment="Stretch" Content="{x:Bind ViewModel.SelectedTabItem.ContentFrame, Mode=OneWay}" /> - + - + @@ -448,6 +448,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/Views/MainPage.xaml.cs b/src/Files.App/Views/MainPage.xaml.cs index 6f694cad775e..41d4b1151354 100644 --- a/src/Files.App/Views/MainPage.xaml.cs +++ b/src/Files.App/Views/MainPage.xaml.cs @@ -322,20 +322,11 @@ private void SidebarControl_Loaded(object sender, RoutedEventArgs e) private void RootGrid_SizeChanged(object sender, SizeChangedEventArgs e) => LoadPaneChanged(); - /// - /// Call this function to update the positioning of the preview pane. - /// This is a workaround as the VisualStateManager causes problems. - /// private void UpdatePositioning() { if (InfoPane is null || !ViewModel.ShouldPreviewPaneBeActive) { - PaneRow.MinHeight = 0; - PaneRow.MaxHeight = double.MaxValue; - PaneRow.Height = new GridLength(0); - PaneColumn.MinWidth = 0; - PaneColumn.MaxWidth = double.MaxValue; - PaneColumn.Width = new GridLength(0); + VisualStateManager.GoToState(this, "InfoPanePositionNone", true); } else { @@ -343,42 +334,15 @@ private void UpdatePositioning() switch (InfoPane.Position) { case PreviewPanePositions.None: - PaneRow.MinHeight = 0; - PaneRow.Height = new GridLength(0); - PaneColumn.MinWidth = 0; - PaneColumn.Width = new GridLength(0); + VisualStateManager.GoToState(this, "InfoPanePositionNone", true); break; case PreviewPanePositions.Right: - InfoPane.SetValue(Grid.RowProperty, 1); - InfoPane.SetValue(Grid.ColumnProperty, 2); - PaneSplitter.SetValue(Grid.RowProperty, 1); - PaneSplitter.SetValue(Grid.ColumnProperty, 1); - PaneSplitter.Width = 2; - PaneSplitter.Height = RootGrid.ActualHeight; - PaneSplitter.GripperCursor = GridSplitter.GripperCursorType.SizeWestEast; - PaneSplitter.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast)); - PaneColumn.MinWidth = InfoPane.MinWidth; - PaneColumn.MaxWidth = InfoPane.MaxWidth; - PaneColumn.Width = new GridLength(UserSettingsService.InfoPaneSettingsService.VerticalSizePx, GridUnitType.Pixel); - PaneRow.MinHeight = 0; - PaneRow.MaxHeight = double.MaxValue; - PaneRow.Height = new GridLength(0); + InfoPaneSizer.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast)); + VisualStateManager.GoToState(this, "InfoPanePositionRight", true); break; case PreviewPanePositions.Bottom: - InfoPane.SetValue(Grid.RowProperty, 3); - InfoPane.SetValue(Grid.ColumnProperty, 0); - PaneSplitter.SetValue(Grid.RowProperty, 2); - PaneSplitter.SetValue(Grid.ColumnProperty, 0); - 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); - PaneRow.MinHeight = InfoPane.MinHeight; - PaneRow.MaxHeight = InfoPane.MaxHeight; - PaneRow.Height = new GridLength(UserSettingsService.InfoPaneSettingsService.HorizontalSizePx, GridUnitType.Pixel); + InfoPaneSizer.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeNorthSouth)); + VisualStateManager.GoToState(this, "InfoPanePositionBottom", true); break; } }