-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add sample page for LayoutTransformControl #1917
Changes from 1 commit
967be92
516ae95
505f92d
a46a25d
44dc31e
e660de8
1572aba
9b4e59f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Page | ||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.LayoutTransformControlPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<controls:LayoutTransformControl Background="{StaticResource Brush-Grey-01}" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
RenderTransformOrigin="0.5,0.5"> | ||
<controls:LayoutTransformControl.Transform> | ||
<TransformGroup> | ||
<RotateTransform Angle="{Binding Path=Angle.Value, Mode=TwoWay}" /> | ||
<ScaleTransform ScaleX="{Binding Path=ScaleX.Value, Mode=TwoWay}" | ||
ScaleY="{Binding Path=ScaleY.Value, Mode=TwoWay}" /> | ||
<SkewTransform AngleX="{Binding Path=SkewX.Value, Mode=TwoWay}" | ||
AngleY="{Binding Path=SkewY.Value, Mode=TwoWay}" /> | ||
</TransformGroup> | ||
</controls:LayoutTransformControl.Transform> | ||
|
||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10"> | ||
<TextBlock Foreground="White" Text="This is a test message." /> | ||
</Grid> | ||
</controls:LayoutTransformControl> | ||
</Grid> | ||
</Page> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
{ | ||
/// <summary> | ||
/// A page that shows how to use the LayoutTransformControl control. | ||
/// </summary> | ||
public sealed partial class LayoutTransformControlPage : Page | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="LayoutTransformControlPage"/> class. | ||
/// </summary> | ||
public LayoutTransformControlPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Page | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<controls:LayoutTransformControl Background="{StaticResource Brush-Grey-01}" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
RenderTransformOrigin="0.5,0.5"> | ||
<controls:LayoutTransformControl.Transform> | ||
<TransformGroup> | ||
<RotateTransform Angle="@[Angle:DoubleSlider:0:-180.0-180.0]" /> | ||
<ScaleTransform ScaleX="@[ScaleX:DoubleSlider:1:0.0-5.0]" | ||
ScaleY="@[ScaleY:DoubleSlider:1:0.0-5.0]" /> | ||
<SkewTransform AngleX="@[SkewX:DoubleSlider:0:-180.0-180.0]" | ||
AngleY="@[SkewY:DoubleSlider:0:-180.0-180.0]" /> | ||
</TransformGroup> | ||
</controls:LayoutTransformControl.Transform> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with @skendrot, could be useful to show more of what it's doing compared to a RenderTransformOrigin. I did notice that with similar values in Skew though that at some point the layout transform seems to start behaving differently...
Compared to when there are less large values: Would this be a bug somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well. Your example is much more complicated than the code you gave. One thing I can notice is that in your large example, the first rendered grid is correct but not the second one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Odonno both images are the same example, only difference is the change in Skew Angles (-20, 20) for the bottom and (-120, 180) for the top. The top rectangle in each image is the Layout Transform and the bottom rectangle is the Render Transform. I just added it into the example as another row of the main grid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have achieved to replicate the second render and here is the configuration I set:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michael-hawker Oh, I see. It is not the same method you used. I suppose that's maybe because the Matrix is not altered in the same order as it is with the default RenderTransform. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure but changing the +/- values should not be that hard. @xyzzer may have an idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not time to look into it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a quick look later and see. Seems like a bug we should fix for 3.0. It'll be a separate issue, so we don't necessarily have to hold up this PR over it. I'll pull the update later and take a look at the new sample. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michael-hawker Should we create an issue for this and/or have you found out the bug? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample looks good, I created issue #2006 for the bug about the layout. Think we should port some of the Matrix helper functions and then use those to perform the operation. |
||
|
||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10"> | ||
<TextBlock Foreground="White" Text="This is a test message." /> | ||
</Grid> | ||
</controls:LayoutTransformControl> | ||
</Grid> | ||
</Page> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,6 +273,14 @@ | |
"XamlCodeFile": "StaggeredPanel.bind", | ||
"Icon": "/SamplePages/StaggeredPanel/StaggeredPanel.png", | ||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/StaggeredPanel.md" | ||
}, | ||
{ | ||
"Name": "LayoutTransformControl", | ||
"Type": "LayoutTransformControlPage", | ||
"About": "Control that implements support for transformations as if applied by LayoutTransform.", | ||
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/LayoutTransformControl", | ||
"XamlCodeFile": "LayoutTransformControlXaml.bind", | ||
"Icon": "/SamplePages/LayoutTransformControl/LayoutTransformControl.png" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Icon missing from PR? |
||
} | ||
] | ||
}, | ||
|
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.
Use an actual color here instead of a resource so it can be easily copy/pasted. Should this background go on the Border below? Do we need to set the HorizontalAlignment and VerticalAlignment on both the LayoutTraformControl and the Border?