Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
23bde30
Initial Commit of ContentSizer
michael-hawker Jul 30, 2020
78574fb
Remove backing page from ContentSizer samples
michael-hawker Jun 15, 2021
8af0680
init commit
XAML-Knight Dec 30, 2021
935df69
split common code out to new base class
XAML-Knight Jan 5, 2022
612d1b1
Implement appropriate cursor shape
XAML-Knight Jan 5, 2022
696aa7c
stage automation peer class
XAML-Knight Jan 6, 2022
df03fad
add unit test for AutomationPeer
XAML-Knight Jan 6, 2022
49d64b0
changes for test
XAML-Knight Jan 6, 2022
0c2d100
InvertDragDirection
XAML-Knight Jan 12, 2022
a69493c
Remove GripperHoverWrapper
XAML-Knight Jan 13, 2022
5f9e58a
Further refactoring
XAML-Knight Jan 14, 2022
ce0a1ac
Pass unit test
XAML-Knight Jan 15, 2022
765a983
Gripper cursor refactor
XAML-Knight Jan 21, 2022
cfcfc02
Remove local enum
XAML-Knight Jan 20, 2022
d02b539
Removed XAML comment
XAML-Knight Jan 21, 2022
b5dc2e6
Addressing PR concerns
XAML-Knight Jan 26, 2022
a09d597
Updated UI changes
XAML-Knight Jan 31, 2022
ace8309
Address unit test reqs
XAML-Knight Jan 31, 2022
354a501
Refactor keyboard event into base class
XAML-Knight Feb 1, 2022
d5e5baa
Comment for event
XAML-Knight Feb 1, 2022
b85926b
Applying PR changes
XAML-Knight Feb 5, 2022
30689d2
Addressing PR comments
XAML-Knight Feb 8, 2022
30a1aea
Make HorizontalMove and VerticalMove in SplitBase abstract and separa…
michael-hawker Feb 26, 2022
7d74e08
Clean-up ContentSizer example to place ContentSizer outside of Expander.
michael-hawker Feb 26, 2022
96fcfe6
Fix Stylecop spacing for TODO comments
michael-hawker Feb 26, 2022
75889af
Split out TargetControl property to ContentSizer control from SplitBase
michael-hawker Mar 1, 2022
2f8379a
Add note for automation peer for ContentSizer to be generalized later
michael-hawker Mar 1, 2022
b7ff319
Move Sizer based controls under a central folder in the Layout project
michael-hawker Mar 1, 2022
06872ca
Refactor and move more logic for Sizers into SizerBase to share betwe…
michael-hawker Mar 2, 2022
9c4eec2
Centralize an OnLoaded virtual event for Sizer
michael-hawker Mar 2, 2022
2cd1051
Fix keyboard behavior for GridSplitter/ContentSizer for RTL languages
michael-hawker Mar 2, 2022
69e237f
Refactor out some properties and helper methods of SizerBase to their…
michael-hawker Mar 2, 2022
c034c27
Fixes #3949 - SizerBase, GridSplitter, and ContentSizer all use Cumul…
michael-hawker Mar 3, 2022
283d6a1
Add WPF properties `DragIncrement` and `KeyboardIncrement` to our Siz…
michael-hawker Mar 3, 2022
ffd0f29
Rename internal events for SizerBase from GridSplitter
michael-hawker Mar 3, 2022
de44a6a
Add support for IsEnabled in the VSM of SizerBase
michael-hawker Mar 3, 2022
048d2f9
Created OrientationToObjectConverter for SizerBar/GripperBarBase
michael-hawker Mar 4, 2022
893ea02
Change GripperCursor to Cursor on SizerBase/GripperBarBase
michael-hawker Mar 4, 2022
63de628
Clean-up Sizer based samples and move to central directory, remove un…
michael-hawker Mar 4, 2022
449e01d
Add PropertySizer with NavigationView sample
michael-hawker Mar 4, 2022
fdd4d12
Add Minimum and Maximum constraint properties to the PropertySizer co…
michael-hawker Mar 5, 2022
968f1e6
Make Pane open by default of NavigationView in PropertySizer example.
michael-hawker Mar 5, 2022
0ac40ef
Update AutomationPeer naming and types to be generalized (untested st…
michael-hawker Mar 5, 2022
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
Prev Previous commit
Next Next commit
Refactor out some properties and helper methods of SizerBase to their…
… own files in the partial class.

Move IsDragInverted to ContentSizer as it is specific to that class for now.
  • Loading branch information
michael-hawker committed Mar 7, 2022
commit 69e237f540a05956382850ff39f0e2d7015c4d8c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// </summary>
public partial class ContentSizer
{
/// <summary>
/// Gets or sets a value indicating whether the <see cref="ContentSizer"/> control is resizing in the opposite direction.
/// </summary>
public bool IsDragInverted
{
get { return (bool)GetValue(IsDragInvertedProperty); }
set { SetValue(IsDragInvertedProperty, value); }
}

/// <summary>
/// Identifies the <see cref="IsDragInverted"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsDragInvertedProperty =
DependencyProperty.Register(nameof(IsDragInverted), typeof(bool), typeof(ContentSizer), new PropertyMetadata(false));

/// <summary>
/// Gets or sets the control that the <see cref="ContentSizer"/> is resizing. Be default, this will be the visual ancestor of the <see cref="ContentSizer"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Events for <see cref="SizerBase"/>.
/// Event implementations for <see cref="SizerBase"/>.
/// </summary>
public partial class SizerBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Markup;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Protected helper methods for <see cref="SizerBase"/> and subclasses.
/// </summary>
public partial class SizerBase : Control
{
/// <summary>
/// Check for new requested vertical size is valid or not
/// </summary>
/// <param name="target">Target control being resized</param>
/// <param name="verticalChange">The requested vertical change</param>
/// <param name="parentActualHeight">The parent control's ActualHeight</param>
/// <returns>Bool result if requested vertical change is valid or not</returns>
protected static bool IsValidHeight(FrameworkElement target, double verticalChange, double parentActualHeight)
{
var newHeight = target.ActualHeight + verticalChange;

var minHeight = target.MinHeight;
if (newHeight < 0 || (!double.IsNaN(minHeight) && newHeight < minHeight))
{
return false;
}

var maxHeight = target.MaxHeight;
if (!double.IsNaN(maxHeight) && newHeight > maxHeight)
{
return false;
}

if (newHeight <= parentActualHeight)
{
return false;
}

return true;
}

/// <summary>
/// Check for new requested horizontal size is valid or not
/// </summary>
/// <param name="target">Target control being resized</param>
/// <param name="horizontalChange">The requested horizontal change</param>
/// <param name="parentActualWidth">The parent control's ActualWidth</param>
/// <returns>Bool result if requested horizontal change is valid or not</returns>
protected static bool IsValidWidth(FrameworkElement target, double horizontalChange, double parentActualWidth)
{
var newWidth = target.ActualWidth + horizontalChange;

var minWidth = target.MinWidth;
if (newWidth < 0 || (!double.IsNaN(minWidth) && newWidth < minWidth))
{
return false;
}

var maxWidth = target.MaxWidth;
if (!double.IsNaN(maxWidth) && newWidth > maxWidth)
{
return false;
}

if (newWidth <= parentActualWidth)
{
return false;
}

return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Markup;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Properties for <see cref="SizerBase"/>
/// </summary>
public partial class SizerBase : Control
{
/// <summary>
/// Vertical symbol for GripperBar in Segoe MDL2 Font asset.
/// </summary>
protected const string GripperBarVertical = "\xE784";

/// <summary>
/// Horizontal symbol for GripperBar in Segoe MDL2 Font asset.
/// </summary>
protected const string GripperBarHorizontal = "\xE76F";

/// <summary>
/// Distance (horizontal or vertical) to move, in response to keyboard activity.
/// </summary>
protected const double GripperKeyboardChange = 8.0d;

/// <summary>
/// Gets or sets the content of the splitter control.
/// </summary>
public object Content
{
get { return (object)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Content"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(nameof(Content), typeof(object), typeof(SizerBase), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the content template for the <see cref="Content"/>.
/// </summary>
public DataTemplate ContentTemplate
{
get { return (DataTemplate)GetValue(ContentTemplateProperty); }
set { SetValue(ContentTemplateProperty, value); }
}

/// <summary>
/// Identifies the <see cref="ContentTemplate"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentTemplateProperty =
DependencyProperty.Register(nameof(ContentTemplate), typeof(DataTemplate), typeof(SizerBase), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the cursor to use when hovering over the sizer.
/// </summary>
public CoreCursorType GripperCursor
{
get { return (CoreCursorType)GetValue(GripperCursorProperty); }
set { SetValue(GripperCursorProperty, value); }
}

/// <summary>
/// Identifies the <see cref="GripperCursor"/> dependency property.
/// </summary>
public static readonly DependencyProperty GripperCursorProperty =
DependencyProperty.Register(nameof(GripperCursor), typeof(CoreCursorType), typeof(SizerBase), new PropertyMetadata(CoreCursorType.SizeWestEast));

/// <summary>
/// Gets or sets the orientation the sizer will be and how it will interact with other elements. Defaults to <see cref="Orientation.Vertical"/>.
/// </summary>
/// <remarks>
/// Note if using <see cref="GridSplitter"/>, use the <see cref="GridSplitter.ResizeDirection"/> property instead.
/// </remarks>
public Orientation Orientation
{
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Orientation"/> dependency property.
/// </summary>
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register(nameof(Orientation), typeof(Orientation), typeof(SizerBase), new PropertyMetadata(Orientation.Vertical));
}
}
159 changes: 1 addition & 158 deletions Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,168 +11,11 @@
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Base class for splitting/resizing controls
/// Base class for splitting/resizing type controls like <see cref="GridSplitter"/> and <see cref="ContentSizer"/>. Acts similar to an enlarged <see cref="Windows.UI.Xaml.Controls.Primitives.Thumb"/> type control, but with keyboard support. Subclasses should override the various abstract methods here to implement their behavior.
/// </summary>
[ContentProperty(Name = nameof(Content))]
public abstract partial class SizerBase : Control
{
/// <summary>
/// Check for new requested vertical size is valid or not
/// </summary>
/// <param name="target">Target control being resized</param>
/// <param name="verticalChange">The requested vertical change</param>
/// <param name="parentActualHeight">The parent control's ActualHeight</param>
/// <returns>Bool result if requested vertical change is valid or not</returns>
protected static bool IsValidHeight(FrameworkElement target, double verticalChange, double parentActualHeight)
{
var newHeight = target.ActualHeight + verticalChange;

var minHeight = target.MinHeight;
if (newHeight < 0 || (!double.IsNaN(minHeight) && newHeight < minHeight))
{
return false;
}

var maxHeight = target.MaxHeight;
if (!double.IsNaN(maxHeight) && newHeight > maxHeight)
{
return false;
}

if (newHeight <= parentActualHeight)
{
return false;
}

return true;
}

/// <summary>
/// Check for new requested horizontal size is valid or not
/// </summary>
/// <param name="target">Target control being resized</param>
/// <param name="horizontalChange">The requested horizontal change</param>
/// <param name="parentActualWidth">The parent control's ActualWidth</param>
/// <returns>Bool result if requested horizontal change is valid or not</returns>
protected static bool IsValidWidth(FrameworkElement target, double horizontalChange, double parentActualWidth)
{
var newWidth = target.ActualWidth + horizontalChange;

var minWidth = target.MinWidth;
if (newWidth < 0 || (!double.IsNaN(minWidth) && newWidth < minWidth))
{
return false;
}

var maxWidth = target.MaxWidth;
if (!double.IsNaN(maxWidth) && newWidth > maxWidth)
{
return false;
}

if (newWidth <= parentActualWidth)
{
return false;
}

return true;
}

/// <summary>
/// Vertical symbol for GripperBar in Segoe MDL2 Font asset.
/// </summary>
protected const string GripperBarVertical = "\xE784";

/// <summary>
/// Horizontal symbol for GripperBar in Segoe MDL2 Font asset.
/// </summary>
protected const string GripperBarHorizontal = "\xE76F";

/// <summary>
/// Distance (horizontal or vertical) to move, in response to keyboard activity.
/// </summary>
protected const double GripperKeyboardChange = 8.0d;

/// <summary>
/// Gets or sets the content of the splitter control.
/// </summary>
public object Content
{
get { return (object)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Content"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(nameof(Content), typeof(object), typeof(SizerBase), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the content template for the <see cref="Content"/>.
/// </summary>
public DataTemplate ContentTemplate
{
get { return (DataTemplate)GetValue(ContentTemplateProperty); }
set { SetValue(ContentTemplateProperty, value); }
}

/// <summary>
/// Identifies the <see cref="ContentTemplate"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentTemplateProperty =
DependencyProperty.Register(nameof(ContentTemplate), typeof(DataTemplate), typeof(SizerBase), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the cursor to use when hovering over the sizer.
/// </summary>
public CoreCursorType GripperCursor
{
get { return (CoreCursorType)GetValue(GripperCursorProperty); }
set { SetValue(GripperCursorProperty, value); }
}

/// <summary>
/// Identifies the <see cref="GripperCursor"/> dependency property.
/// </summary>
public static readonly DependencyProperty GripperCursorProperty =
DependencyProperty.Register(nameof(GripperCursor), typeof(CoreCursorType), typeof(SizerBase), new PropertyMetadata(CoreCursorType.SizeWestEast));

/// <summary>
/// Gets or sets the orientation the sizer will be and how it will interact with other elements. Defaults to <see cref="Orientation.Vertical"/>.
/// </summary>
/// <remarks>
/// Note if using <see cref="GridSplitter"/>, use the <see cref="GridSplitter.ResizeDirection"/> property instead.
/// </remarks>
public Orientation Orientation
{
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Orientation"/> dependency property.
/// </summary>
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register(nameof(Orientation), typeof(Orientation), typeof(SizerBase), new PropertyMetadata(Orientation.Vertical));

//// TODO: Check if this is ContentSizer only property

/// <summary>
/// Gets or sets a value indicating whether the <see cref="SizerBase"/> control is resizing in the opposite direction.
/// </summary>
public bool IsDragInverted
{
get { return (bool)GetValue(IsDragInvertedProperty); }
set { SetValue(IsDragInvertedProperty, value); }
}

/// <summary>
/// Identifies the <see cref="IsDragInverted"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsDragInvertedProperty =
DependencyProperty.Register(nameof(IsDragInverted), typeof(bool), typeof(SizerBase), new PropertyMetadata(false));

/// <summary>
/// Method to process the requested horizontal resizing.
/// </summary>
Expand Down