-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Attached Shadows (Composition and Win2D + Animations) #4179
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
Merged
25 commits merged into
CommunityToolkit:main
from
michael-hawker:ryken100/feature-AttachedShadows
Aug 27, 2021
Merged
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ab486ec
Initial attached shadow code
chris-blackman 795c57e
Documentation update
chris-blackman 5d1c7bf
Fixed member access
chris-blackman bb9dc4b
Move DropShadowPanel sample into shared folder and remove backing pag…
michael-hawker 863e75c
Clean-up out-dated min version warnings on samples as the Toolkit min…
michael-hawker e3c6fe2
Move common Shadow base helpers to a folder in Uwp.UI
michael-hawker f2a8254
Move AttachedShadow to root namespace for Uwp.UI.Media
michael-hawker 72d524c
Add Vector3 support for Sample Bindings
michael-hawker ed42e41
Add AttachedShadow Sample
michael-hawker f48df97
Clean-up some documentation and info about min version to sample app
michael-hawker 75e53c9
Rename Shadows.Attached to Effects.Shadow
michael-hawker 4a651dd
Add more samples (though one doesn't work for some reason with raw Bo…
michael-hawker 2096e5d
Fix Border based Example
michael-hawker 0459a89
Add initial Composition based AttachedDropShadow support
michael-hawker 8647919
Add initial basic animation support for Shadows
michael-hawker ca6f772
Clean-up and simplify Shadow Animations, add support for animating al…
michael-hawker 08ffdcf
Fix issues with XML documentation for new shadows feature
michael-hawker 164eefd
Clean-up ShadowAnimation type and add rest of animatable properties
michael-hawker b34f441
Deprecate DropShadowPanel
michael-hawker c932579
Update String to Vector Unit Tests to address new scenarios added in …
michael-hawker 5ab106e
Merge branch 'main' into ryken100/feature-AttachedShadows
michael-hawker f3b0e5c
Update Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Shadows/AttachedSh…
michael-hawker 01c9fa3
Update Microsoft.Toolkit.Uwp.SampleApp/Common/Vector3Converter.cs
michael-hawker 2404be9
Make field initialization static
michael-hawker e418928
Clean-up Shadow internal part usage based on @Sergio0694 PR comments
michael-hawker 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
57 changes: 57 additions & 0 deletions
57
Microsoft.Toolkit.Uwp.SampleApp/Common/Vector3Converter.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,57 @@ | ||
// 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 System; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Data; | ||
|
||
namespace Microsoft.Toolkit.Uwp.SampleApp.Common | ||
{ | ||
public class Vector3Converter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
if (value is string) | ||
{ | ||
return value; | ||
} | ||
|
||
var thickness = (Vector3)value; | ||
|
||
return thickness.ToString().TrimStart('<').Replace(" ", string.Empty).TrimEnd('>'); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
{ | ||
if (value is string vectorString) | ||
{ | ||
var vectorTokens = vectorString.Split(',') | ||
.Where(tkn => !string.IsNullOrWhiteSpace(tkn)) | ||
.ToArray(); | ||
switch (vectorTokens.Length) | ||
{ | ||
case 1: | ||
var vectorValue = float.Parse(vectorString); | ||
return new Vector3(vectorValue, vectorValue, vectorValue); | ||
case 2: | ||
var xValue = float.Parse(vectorTokens[0]); | ||
var yValue = float.Parse(vectorTokens[1]); | ||
|
||
return new Vector3(xValue, yValue, 0); | ||
case 3: | ||
return new Vector3( | ||
float.Parse(vectorTokens[0]), | ||
float.Parse(vectorTokens[1]), | ||
float.Parse(vectorTokens[2])); | ||
default: | ||
return default(Vector3); | ||
} | ||
} | ||
|
||
return value.ToString(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ public enum PropertyKind | |
Bool, | ||
Brush, | ||
TimeSpan, | ||
Thickness | ||
Thickness, | ||
Vector3, | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/ThicknessPropertyOptions.cs
This file was deleted.
Oops, something went wrong.
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
75 changes: 75 additions & 0 deletions
75
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Animations/Shadows/AnimatedCardShadowXaml.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,75 @@ | ||
<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:ui="using:Microsoft.Toolkit.Uwp.UI" | ||
xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media" | ||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" | ||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core" | ||
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations" | ||
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<media:AttachedCardShadow x:Key="CommonShadow" Offset="4" CornerRadius="0"/> | ||
|
||
<ani:AnimationSet x:Key="ShadowEnterAnimation"> | ||
<ani:OffsetDropShadowAnimation To="12"/> | ||
</ani:AnimationSet> | ||
|
||
<ani:AnimationSet x:Key="ShadowExitAnimation"> | ||
<ani:OffsetDropShadowAnimation To="4"/> | ||
</ani:AnimationSet> | ||
|
||
<ani:AnimationSet x:Key="ShadowPopAnimation" IsSequential="True"> | ||
<ani:TranslationAnimation To="-8" Duration="0:0:1"/> | ||
<ani:OffsetDropShadowAnimation To="16" Duration="0:0:2" Target="{StaticResource CommonShadow}"/> | ||
<ani:OffsetDropShadowAnimation To="4" Delay="0:0:0.5" Duration="0:0:2" Target="{StaticResource CommonShadow}"/> | ||
<ani:TranslationAnimation To="0" Duration="0:0:1"/> | ||
</ani:AnimationSet> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
</Grid.ColumnDefinitions> | ||
<Image ui:Effects.Shadow="{StaticResource CommonShadow}" | ||
Height="100" Width="100" | ||
Source="ms-appx:///Assets/Photos/Owl.jpg"> | ||
<interactivity:Interaction.Behaviors> | ||
<interactions:EventTriggerBehavior EventName="PointerEntered"> | ||
<behaviors:StartAnimationAction Animation="{StaticResource ShadowEnterAnimation}"/> | ||
</interactions:EventTriggerBehavior> | ||
<interactions:EventTriggerBehavior EventName="PointerExited"> | ||
<behaviors:StartAnimationAction Animation="{StaticResource ShadowExitAnimation}"/> | ||
</interactions:EventTriggerBehavior> | ||
</interactivity:Interaction.Behaviors> | ||
</Image> | ||
<Image ui:Effects.Shadow="{StaticResource CommonShadow}" | ||
Height="100" Width="100" | ||
Grid.Column="1" | ||
Source="ms-appx:///Assets/Photos/Owl.jpg"> | ||
<interactivity:Interaction.Behaviors> | ||
<interactions:EventTriggerBehavior EventName="PointerEntered"> | ||
<behaviors:StartAnimationAction Animation="{StaticResource ShadowEnterAnimation}"/> | ||
</interactions:EventTriggerBehavior> | ||
<interactions:EventTriggerBehavior EventName="PointerExited"> | ||
<behaviors:StartAnimationAction Animation="{StaticResource ShadowExitAnimation}"/> | ||
</interactions:EventTriggerBehavior> | ||
</interactivity:Interaction.Behaviors> | ||
</Image> | ||
<Button Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Click Me"> | ||
<interactivity:Interaction.Behaviors> | ||
<interactions:EventTriggerBehavior EventName="Click"> | ||
<behaviors:StartAnimationAction Animation="{StaticResource ShadowPopAnimation}"/> | ||
</interactions:EventTriggerBehavior> | ||
</interactivity:Interaction.Behaviors> | ||
</Button> | ||
</Grid> | ||
</Page> |
26 changes: 0 additions & 26 deletions
26
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DropShadowPanel/DropShadowPanelPage.xaml
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DropShadowPanel/DropShadowPanelPage.xaml.cs
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Shadows/AttachedDropShadowPage.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,9 @@ | ||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.AttachedDropShadowPage" | ||
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" | ||
mc:Ignorable="d"> | ||
|
||
<!-- Shallow Copy in XamlOnlyPage --> | ||
</Page> |
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.
Uh oh!
There was an error while loading. Please reload this page.