forked from CommunityToolkit/WindowsCommunityToolkit
-
Notifications
You must be signed in to change notification settings - Fork 2
GridSplitter changes, rebased on top of OG GridSplitter PR #3
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
Open
XAML-Knight
wants to merge
22
commits into
michael-hawker:user/mhawker/gridsplitter
Choose a base branch
from
XAML-Knight:dev/GridSplitterJr
base: user/mhawker/gridsplitter
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
76c947d
Initial Commit of ContentSizer
michael-hawker cfc2c57
Remove backing page from ContentSizer samples
michael-hawker 4f18bc9
init commit
XAML-Knight 9f2c162
split common code out to new base class
XAML-Knight 22b9c75
Implement appropriate cursor shape
XAML-Knight 3f3f447
stage automation peer class
XAML-Knight 71de3f9
add unit test for AutomationPeer
XAML-Knight 2e0dceb
changes for test
XAML-Knight a4c1ff3
InvertDragDirection
XAML-Knight 41b7ec3
Remove GripperHoverWrapper
XAML-Knight e79bcbc
Further refactoring
XAML-Knight 6cc6213
Pass unit test
XAML-Knight da1cb5f
Gripper cursor refactor
XAML-Knight e805581
Remove local enum
XAML-Knight ed9e770
Removed XAML comment
XAML-Knight 5cde5d4
Addressing PR concerns
XAML-Knight 5d09eb1
Updated UI changes
XAML-Knight 0121441
Address unit test reqs
XAML-Knight 55d24b8
Refactor keyboard event into base class
XAML-Knight e5072bc
Comment for event
XAML-Knight 7c6f2c1
Applying PR changes
XAML-Knight 4962681
Addressing PR comments
XAML-Knight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ContentSizer/ContentSizer.bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <Page | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <Grid x:Name="RootGrid"> | ||
| <!-- Just to separate our two examples --> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="Auto"/> | ||
| <ColumnDefinition/> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <!-- Left-side 'Shelf' --> | ||
| <StackPanel Orientation="Horizontal"> | ||
| <Border x:Name="SideContent" | ||
| Background="DarkGreen" | ||
| MinWidth="200" | ||
| MaxWidth="600"> | ||
| <TextBlock HorizontalAlignment="Center" | ||
| VerticalAlignment="Center"> | ||
| Side Content | ||
| </TextBlock> | ||
| </Border> | ||
| <controls:ContentSizer TargetControl="{Binding ElementName=SideContent}"/> | ||
| </StackPanel> | ||
|
|
||
| <!-- Bottom 'Shelf' --> | ||
| <controls:Expander x:Name="TopExpander" | ||
| VerticalAlignment="Top" | ||
| ExpandDirection="Up" | ||
| Header="This is some Shelf" | ||
| HorizontalContentAlignment="Stretch" | ||
| IsExpanded="True" | ||
| Grid.Column="1"> | ||
| <Grid Height="256"> | ||
| <TextBlock HorizontalAlignment="Center" | ||
| TextWrapping="Wrap" | ||
| Text="This is the expanded content" | ||
| VerticalAlignment="Center"/> | ||
| <controls:ContentSizer ResizeDirection="Horizontal" Height="16" | ||
| VerticalAlignment="Bottom"/> | ||
| </Grid> | ||
| </controls:Expander> | ||
| </Grid> | ||
| </Page> |
Binary file added
BIN
+850 Bytes
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ContentSizer/ContentSizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Microsoft.Toolkit.Uwp.UI.Controls.Layout/ContentSizer/ContentResizeDirection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // 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. | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// Enum to indicate whether <see cref="ContentSizer"/> resizes Vertically or Horizontally. | ||
| /// </summary> | ||
| public enum ContentResizeDirection | ||
| { | ||
| /// <summary> | ||
| /// Determines whether to resize rows or columns based on its Alignment and | ||
| /// width compared to height | ||
| /// </summary> | ||
| Auto, // TODO: Detect? | ||
|
|
||
| /// <summary> | ||
| /// Resize columns when dragging Splitter. | ||
| /// </summary> | ||
| Vertical, | ||
|
|
||
| /// <summary> | ||
| /// Resize rows when dragging Splitter. | ||
| /// </summary> | ||
| Horizontal | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
Microsoft.Toolkit.Uwp.UI.Controls.Layout/ContentSizer/ContentSizer.Events.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // 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 Microsoft.Toolkit.Uwp.UI; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
| using Windows.UI.Xaml.Input; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// Events for <see cref="ContentSizer"/>. | ||
| /// </summary> | ||
| public partial class ContentSizer | ||
| { | ||
| // If no values specified, setup our default behaviors. | ||
| private void ContentSizer_Loaded(object sender, RoutedEventArgs e) | ||
| { | ||
| // Adding Grip to Grid Splitter | ||
| if (Content == null) | ||
| { | ||
| // TODO: Make Converter to put in XAML? | ||
| Content = | ||
| ResizeDirection == ContentResizeDirection.Vertical ? GripperBarVertical : GripperBarHorizontal; | ||
| } | ||
|
|
||
| if (TargetControl == null) | ||
| { | ||
| TargetControl = this.FindAscendant<FrameworkElement>(); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) | ||
| { | ||
| var horizontalChange = e.Delta.Translation.X; | ||
| var verticalChange = e.Delta.Translation.Y; | ||
|
|
||
| if (ResizeDirection == ContentResizeDirection.Vertical) | ||
| { | ||
| if (HorizontalMove(horizontalChange)) | ||
| { | ||
| return; | ||
| } | ||
| } | ||
| else if (ResizeDirection == ContentResizeDirection.Horizontal) | ||
| { | ||
| if (VerticalMove(verticalChange)) | ||
| { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| base.OnManipulationDelta(e); | ||
| } | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
Microsoft.Toolkit.Uwp.UI.Controls.Layout/ContentSizer/ContentSizer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // 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 Microsoft.Toolkit.Uwp.UI.Automation.Peers; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Automation.Peers; | ||
| using Windows.UI.Xaml.Controls; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// The <see cref="ContentSizer"/> is a control which can be used to resize any element, usually its parent. If you are using a <see cref="Grid"/>, use <see cref="GridSplitter"/> instead. | ||
| /// </summary> | ||
| public partial class ContentSizer : SplitBase | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="ContentSizer"/> class. | ||
| /// </summary> | ||
| public ContentSizer() | ||
| { | ||
| this.DefaultStyleKey = typeof(ContentSizer); | ||
|
|
||
| KeyUp += SplitBase_KeyUp; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override void OnApplyTemplate() | ||
| { | ||
| base.OnApplyTemplate(); | ||
|
|
||
| // Note, we re-register for the proper timing to check for default property values. If we just set Loaded once in our constructor this doesn't work... Not sure why... 🤷 | ||
|
|
||
| // Unhook registered events | ||
| Loaded -= ContentSizer_Loaded; | ||
|
|
||
| // Register Events | ||
| Loaded += ContentSizer_Loaded; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>) | ||
| /// </summary> | ||
| /// <returns>An automation peer for this <see cref="ContentSizer"/>.</returns> | ||
| protected override AutomationPeer OnCreateAutomationPeer() | ||
| { | ||
| return new ContentSizerAutomationPeer(this); | ||
| } | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
Microsoft.Toolkit.Uwp.UI.Controls.Layout/ContentSizer/ContentSizer.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
| xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"> | ||
| <Style TargetType="local:ContentSizer"> | ||
| <Setter Property="IsTabStop" Value="True" /> | ||
| <Setter Property="UseSystemFocusVisuals" Value="True" /> | ||
| <Setter Property="IsFocusEngagementEnabled" Value="True" /> | ||
| <Setter Property="MinWidth" Value="16" /> | ||
| <Setter Property="MinHeight" Value="16" /> | ||
| <Setter Property="Background" Value="{ThemeResource SystemControlHighlightChromeHighBrush}" /> | ||
| <Setter Property="HorizontalContentAlignment" Value="Center" /> | ||
| <Setter Property="VerticalContentAlignment" Value="Center" /> | ||
| <Setter Property="AutomationProperties.Name" Value="ms-resource://Microsoft.Toolkit.Uwp.UI.Controls.Layout/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Resources/WCT_ContentSizer_AutomationName" /> | ||
| <Setter Property="ManipulationMode" Value="TranslateX,TranslateY"/> | ||
| <Setter Property="ContentTemplate"> | ||
| <Setter.Value> | ||
| <DataTemplate> | ||
| <TextBlock AutomationProperties.AccessibilityView="Raw" | ||
| FontFamily="{ThemeResource SymbolThemeFontFamily}" | ||
| Foreground="{ThemeResource SystemControlForegroundAltHighBrush}" | ||
| Text="{Binding}" /> | ||
| </DataTemplate> | ||
| </Setter.Value> | ||
| </Setter> | ||
| <Setter Property="Template"> | ||
| <Setter.Value> | ||
| <ControlTemplate TargetType="local:ContentSizer"> | ||
| <Grid ui:FrameworkElementExtensions.Cursor="{TemplateBinding GripperCursor}" | ||
| Background="{TemplateBinding Background}"> | ||
| <ContentPresenter HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" | ||
| VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" | ||
| Content="{TemplateBinding Content}" | ||
| ContentTemplate="{TemplateBinding ContentTemplate}" /> | ||
| </Grid> | ||
| </ControlTemplate> | ||
| </Setter.Value> | ||
| </Setter> | ||
| </Style> | ||
| </ResourceDictionary> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BREAKING CHANGE: When removing the reliance upon the now-defunct
GripperHoverWrapperclass, this then allowed further refactoring, to where thisElementproperty behaved more or less just like the frameworkContentproperty, so I refactored theElementproperty out.GridSplittersettings, and would not introduce any breaking changes.GridSplitter, this could break the customization after we remove thisElementproperty.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we can just use the default
Contentpattern, then that's going to be fine to remove the customElementthing. :)