From 28701380206aedd46180825cd5b9368522da3f99 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 13:34:18 +0100 Subject: [PATCH 1/6] Initial pipeline brush APIs added --- .../Xaml/Effects/Abstract/ImageEffectBase.cs | 26 +++++++ .../Xaml/Effects/Abstract/ValueEffectBase.cs | 13 ++++ .../Behaviours/Xaml/Effects/BackdropEffect.cs | 15 +++++ .../Behaviours/Xaml/Effects/BlendEffect.cs | 29 ++++++++ .../Behaviours/Xaml/Effects/BlurEffect.cs | 9 +++ .../Behaviours/Xaml/Effects/ImageEffect.cs | 9 +++ .../Xaml/Effects/LuminanceEffect.cs | 7 ++ .../Behaviours/Xaml/Effects/OpacityEffect.cs | 9 +++ .../Xaml/Effects/SaturationEffect.cs | 9 +++ .../Xaml/Effects/SolidColorEffect.cs | 15 +++++ .../Behaviours/Xaml/Effects/TileEffect.cs | 9 +++ .../Behaviours/Xaml/Effects/TintEffect.cs | 20 ++++++ .../Behaviours/Xaml/IPipelineEffect.cs | 7 ++ .../Behaviours/Xaml/PipelineBrush.cs | 67 +++++++++++++++++++ .../UICompositionAnimations.csproj | 14 ++++ 15 files changed, 258 insertions(+) create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ImageEffectBase.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/BackdropEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/BlurEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/ImageEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/LuminanceEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/OpacityEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/SaturationEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/SolidColorEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/TileEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/IPipelineEffect.cs create mode 100644 UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ImageEffectBase.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ImageEffectBase.cs new file mode 100644 index 0000000..381ada6 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ImageEffectBase.cs @@ -0,0 +1,26 @@ +using System; +using UICompositionAnimations.Enums; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects.Abstract +{ + /// + /// An image based effect that loads an image at the specified location + /// + public abstract class ImageEffectBase : IPipelineEffect + { + /// + /// Gets or sets the for the image to load + /// + public Uri Uri { get; set; } + + /// + /// Gets or sets the DPI mode used to render the image (the default is ) + /// + public BitmapDPIMode DPIMode { get; set; } = BitmapDPIMode.CopyDisplayDPISettingsWith96AsLowerBound; + + /// + /// Gets or sets the cache mode to use when loading the image (the default is ) + /// + public BitmapCacheMode CacheMode { get; set; } = BitmapCacheMode.Default; + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs new file mode 100644 index 0000000..13a2fa6 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs @@ -0,0 +1,13 @@ +namespace UICompositionAnimations.Behaviours.Xaml.Effects.Abstract +{ + /// + /// A base for an effect that exposes a single parameter + /// + public abstract class ValueEffectBase : IPipelineEffect + { + /// + /// Gets or sets the value of the parameter for the current effect + /// + public float Value { get; set; } + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BackdropEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BackdropEffect.cs new file mode 100644 index 0000000..f614801 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BackdropEffect.cs @@ -0,0 +1,15 @@ +using Windows.UI.Xaml.Media; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A backdrop effect that can sample from a specified source + /// + public sealed class BackdropEffect : IPipelineEffect + { + /// + /// Gets or sets the backdrop source to use to render the effect + /// + public AcrylicBackgroundSource Source { get; set; } + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs new file mode 100644 index 0000000..7affe36 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using JetBrains.Annotations; +using Microsoft.Graphics.Canvas.Effects; +using UICompositionAnimations.Enums; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A blend effect that merges the current pipeline with an input one + /// + public sealed class BlendEffect : IPipelineEffect + { + /// + /// Gets or sets the input pipeline to merge with the current instance + /// + [ItemNotNull] + public IList Input { get; set; } + + /// + /// Gets or sets the blending mode to use (the default mode is ) + /// + public BlendEffectMode Mode { get; set; } + + /// + /// Gets or sets the placement of the input pipeline with respect to the current one (the default is ) + /// + public EffectPlacement Placement { get; set; } = EffectPlacement.Foreground; + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BlurEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BlurEffect.cs new file mode 100644 index 0000000..5d25528 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BlurEffect.cs @@ -0,0 +1,9 @@ +using UICompositionAnimations.Behaviours.Xaml.Effects.Abstract; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A gaussian blur effect + /// + public sealed class BlurEffect : ValueEffectBase { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/ImageEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/ImageEffect.cs new file mode 100644 index 0000000..5f159f3 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/ImageEffect.cs @@ -0,0 +1,9 @@ +using UICompositionAnimations.Behaviours.Xaml.Effects.Abstract; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// An image effect, which displays an image loaded as a Win2D surface + /// + public sealed class ImageEffect : ImageEffectBase { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/LuminanceEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/LuminanceEffect.cs new file mode 100644 index 0000000..f98cce9 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/LuminanceEffect.cs @@ -0,0 +1,7 @@ +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A luminance effect which directly replicates + /// + public sealed class LuminanceEffect : IPipelineEffect { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/OpacityEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/OpacityEffect.cs new file mode 100644 index 0000000..04f49f9 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/OpacityEffect.cs @@ -0,0 +1,9 @@ +using UICompositionAnimations.Behaviours.Xaml.Effects.Abstract; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A simple opacity effect + /// + public sealed class OpacityEffect : ValueEffectBase { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/SaturationEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/SaturationEffect.cs new file mode 100644 index 0000000..78a7efc --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/SaturationEffect.cs @@ -0,0 +1,9 @@ +using UICompositionAnimations.Behaviours.Xaml.Effects.Abstract; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A saturation effect + /// + public sealed class SaturationEffect : ValueEffectBase { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/SolidColorEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/SolidColorEffect.cs new file mode 100644 index 0000000..05a1003 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/SolidColorEffect.cs @@ -0,0 +1,15 @@ +using Windows.UI; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A simple effect that renders a solid color on the available surface + /// + public sealed class SolidColorEffect : IPipelineEffect + { + /// + /// Gets or sets the color to display + /// + public Color Color { get; set; } + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/TileEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/TileEffect.cs new file mode 100644 index 0000000..ca9d942 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/TileEffect.cs @@ -0,0 +1,9 @@ +using UICompositionAnimations.Behaviours.Xaml.Effects.Abstract; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// An effect that loads an image and replicates it to cover all the available surface area + /// + public sealed class TileEffect : ImageEffectBase { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs new file mode 100644 index 0000000..3a80f4b --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs @@ -0,0 +1,20 @@ +using Windows.UI; + +namespace UICompositionAnimations.Behaviours.Xaml.Effects +{ + /// + /// A tint effect with a customizable opacity + /// + public sealed class TintEffect : IPipelineEffect + { + /// + /// Gets or sets the tint color to use + /// + public Color Color { get; set; } + + /// + /// Gets or sets the opacity of the tint effect + /// + public float Opacity { get; set; } + } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/IPipelineEffect.cs b/UICompositionAnimations/Behaviours/Xaml/IPipelineEffect.cs new file mode 100644 index 0000000..6f8c954 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/IPipelineEffect.cs @@ -0,0 +1,7 @@ +namespace UICompositionAnimations.Behaviours.Xaml +{ + /// + /// The base for all the pipeline effects to be used in a + /// + public interface IPipelineEffect { } +} diff --git a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs new file mode 100644 index 0000000..e8a2a64 --- /dev/null +++ b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Windows.UI.Xaml.Media; +using JetBrains.Annotations; +using UICompositionAnimations.Behaviours.Xaml.Effects; +using UICompositionAnimations.Brushes.Base; +using LuminanceToAlphaEffect = Microsoft.Graphics.Canvas.Effects.LuminanceToAlphaEffect; + +namespace UICompositionAnimations.Behaviours.Xaml +{ + /// + /// A that renders a customizable Composition/Win2D effects pipeline + /// + public sealed class PipelineBrush : XamlCompositionEffectBrushBase + { + /// + protected override CompositionBrushBuilder OnBrushRequested() + { + // Starts a new composition pipeline from the given effect + CompositionBrushBuilder Start(IPipelineEffect effect) + { + switch (effect) + { + case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.Backdrop: + return CompositionBrushBuilder.FromBackdropBrush(); + case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.HostBackdrop: + return CompositionBrushBuilder.FromHostBackdropBrush(); + case SolidColorEffect color: return CompositionBrushBuilder.FromColor(color.Color); + case ImageEffect image: return CompositionBrushBuilder.FromImage(image.Uri); + case TileEffect tile: return CompositionBrushBuilder.FromTiles(tile.Uri); + default: throw new ArgumentException($"Invalid initial pipeline effect: {effect.GetType()}"); + } + } + + // Appends an effect to an existing composition pipeline + CompositionBrushBuilder Append(IPipelineEffect effect, CompositionBrushBuilder builder) + { + switch (effect) + { + case OpacityEffect opacity: return builder.Opacity(opacity.Value); + case LuminanceEffect _: return builder.Effect(source => new LuminanceToAlphaEffect { Source = source }); + case TintEffect tint: return builder.Tint(tint.Color, tint.Opacity); + case BlurEffect blur: return builder.Blur(blur.Value); + case SaturationEffect saturation: return builder.Saturation(saturation.Value); + case BlendEffect blend: return builder.Blend(Build(blend.Input), blend.Mode, blend.Placement); + default: throw new ArgumentException($"Invalid pipeline effect: {effect.GetType()}"); + } + } + + // Builds a new effects pipeline from the input effects sequence + CompositionBrushBuilder Build(IList effects) + { + if (effects.Count == 0) throw new ArgumentException("An effects pipeline can't be empty"); + return effects.Skip(1).Aggregate(Start(effects[0]), (b, e) => Append(e, b)); + } + + return Build(Effects); + } + + /// + /// Gets or sets the collection of effects to use in the current pipeline + /// + [ItemNotNull] + public IList Effects { get; set; } + } +} diff --git a/UICompositionAnimations/UICompositionAnimations.csproj b/UICompositionAnimations/UICompositionAnimations.csproj index ae2433a..8ba5c6c 100644 --- a/UICompositionAnimations/UICompositionAnimations.csproj +++ b/UICompositionAnimations/UICompositionAnimations.csproj @@ -123,6 +123,20 @@ + + + + + + + + + + + + + + From 204df2218033034e2367fa040d89eb3ec2a22f6e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 14:38:43 +0100 Subject: [PATCH 2/6] Bug fixes --- .../Xaml/Effects/Abstract/ValueEffectBase.cs | 2 +- .../Behaviours/Xaml/Effects/BlendEffect.cs | 2 +- .../Behaviours/Xaml/Effects/TintEffect.cs | 2 +- .../Behaviours/Xaml/PipelineBrush.cs | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs index 13a2fa6..63bfba1 100644 --- a/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/Abstract/ValueEffectBase.cs @@ -8,6 +8,6 @@ public abstract class ValueEffectBase : IPipelineEffect /// /// Gets or sets the value of the parameter for the current effect /// - public float Value { get; set; } + public double Value { get; set; } } } diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs index 7affe36..55c9ea6 100644 --- a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs @@ -14,7 +14,7 @@ public sealed class BlendEffect : IPipelineEffect /// Gets or sets the input pipeline to merge with the current instance /// [ItemNotNull] - public IList Input { get; set; } + public List Input { get; set; } = new List(); /// /// Gets or sets the blending mode to use (the default mode is ) diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs index 3a80f4b..404c465 100644 --- a/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/TintEffect.cs @@ -15,6 +15,6 @@ public sealed class TintEffect : IPipelineEffect /// /// Gets or sets the opacity of the tint effect /// - public float Opacity { get; set; } + public double Opacity { get; set; } } } diff --git a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs index e8a2a64..859346e 100644 --- a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs +++ b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs @@ -27,8 +27,8 @@ CompositionBrushBuilder Start(IPipelineEffect effect) case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.HostBackdrop: return CompositionBrushBuilder.FromHostBackdropBrush(); case SolidColorEffect color: return CompositionBrushBuilder.FromColor(color.Color); - case ImageEffect image: return CompositionBrushBuilder.FromImage(image.Uri); - case TileEffect tile: return CompositionBrushBuilder.FromTiles(tile.Uri); + case ImageEffect image: return CompositionBrushBuilder.FromImage(image.Uri, image.DPIMode, image.CacheMode); + case TileEffect tile: return CompositionBrushBuilder.FromTiles(tile.Uri, tile.DPIMode, tile.CacheMode); default: throw new ArgumentException($"Invalid initial pipeline effect: {effect.GetType()}"); } } @@ -38,11 +38,11 @@ CompositionBrushBuilder Append(IPipelineEffect effect, CompositionBrushBuilder b { switch (effect) { - case OpacityEffect opacity: return builder.Opacity(opacity.Value); + case OpacityEffect opacity: return builder.Opacity((float)opacity.Value); case LuminanceEffect _: return builder.Effect(source => new LuminanceToAlphaEffect { Source = source }); - case TintEffect tint: return builder.Tint(tint.Color, tint.Opacity); - case BlurEffect blur: return builder.Blur(blur.Value); - case SaturationEffect saturation: return builder.Saturation(saturation.Value); + case TintEffect tint: return builder.Tint(tint.Color, (float)tint.Opacity); + case BlurEffect blur: return builder.Blur((float)blur.Value); + case SaturationEffect saturation: return builder.Saturation((float)saturation.Value); case BlendEffect blend: return builder.Blend(Build(blend.Input), blend.Mode, blend.Placement); default: throw new ArgumentException($"Invalid pipeline effect: {effect.GetType()}"); } @@ -62,6 +62,6 @@ CompositionBrushBuilder Build(IList effects) /// Gets or sets the collection of effects to use in the current pipeline /// [ItemNotNull] - public IList Effects { get; set; } + public List Effects { get; set; } = new List(); } } From 64234f67ff0cbcfe70dd7aa152d3bcda30027499 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 14:49:05 +0100 Subject: [PATCH 3/6] Minor tweaks --- UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs | 2 +- UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs index 55c9ea6..abf802d 100644 --- a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs @@ -14,7 +14,7 @@ public sealed class BlendEffect : IPipelineEffect /// Gets or sets the input pipeline to merge with the current instance /// [ItemNotNull] - public List Input { get; set; } = new List(); + public IList Input { get; set; } = new List(); /// /// Gets or sets the blending mode to use (the default mode is ) diff --git a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs index 859346e..5fb7bf9 100644 --- a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs +++ b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs @@ -62,6 +62,6 @@ CompositionBrushBuilder Build(IList effects) /// Gets or sets the collection of effects to use in the current pipeline /// [ItemNotNull] - public List Effects { get; set; } = new List(); + public IList Effects { get; set; } = new List(); } } From 510177793dcab7415ad7e83b85876129e11f8065 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 14:50:41 +0100 Subject: [PATCH 4/6] Fixed annotations --- .../Behaviours/Xaml/Effects/BlendEffect.cs | 2 +- UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs | 2 +- UICompositionAnimations/Brushes/CustomAcrylicBrush.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs index abf802d..aafaf9c 100644 --- a/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs +++ b/UICompositionAnimations/Behaviours/Xaml/Effects/BlendEffect.cs @@ -13,7 +13,7 @@ public sealed class BlendEffect : IPipelineEffect /// /// Gets or sets the input pipeline to merge with the current instance /// - [ItemNotNull] + [NotNull, ItemNotNull] public IList Input { get; set; } = new List(); /// diff --git a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs index 5fb7bf9..8bed0eb 100644 --- a/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs +++ b/UICompositionAnimations/Behaviours/Xaml/PipelineBrush.cs @@ -61,7 +61,7 @@ CompositionBrushBuilder Build(IList effects) /// /// Gets or sets the collection of effects to use in the current pipeline /// - [ItemNotNull] + [NotNull, ItemNotNull] public IList Effects { get; set; } = new List(); } } diff --git a/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs b/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs index 4589b85..df67cc5 100644 --- a/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs +++ b/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs @@ -8,19 +8,18 @@ using Windows.UI.Composition; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; -using JetBrains.Annotations; using UICompositionAnimations.Behaviours; using UICompositionAnimations.Brushes.Cache; using UICompositionAnimations.Enums; using UICompositionAnimations.Helpers; using Windows.ApplicationModel; +using JetBrains.Annotations; namespace UICompositionAnimations.Brushes { /// /// A custom XAML brush that includes an acrylic effect that blurs the in-app content /// - [PublicAPI] public sealed class CustomAcrylicBrush : XamlCompositionBrushBase { #region Constants @@ -304,6 +303,7 @@ protected override async void OnDisconnected() /// /// Clears the internal cache of instances /// + [PublicAPI] public static async Task ClearCacheAsync(AcrylicEffectMode targets) { // In-app backdrop brush From ded04a4e630c297f98d0d705883364dbbd6c8b73 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 14:57:41 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index d0bcf46..6c3808f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ The package exposes synchronous and asynchronous APIs (from the `CompositionExte The library also has APIs to automatically combine different kinds of animations, like Fade + Slide or Fade + Scale, and various helper methods to change UI-related parameters of a target object. Here are some animation exaples: #### Synchronous fade animation + ```C# MyControl.StartCompositionFadeAnimation( null, // Using null will make the fade animation start from the current value @@ -57,6 +58,7 @@ MyControl.StartCompositionFadeAnimation( ``` #### Asynchronous fade and scale animation + ```C# await MyControl.StartCompositionFadeScaleAnimationAsync( null, // Initial opacity (use current value) @@ -95,11 +97,13 @@ The library provides several ways to use `UI.Composition` effects. There are rea **Note**: the `NoiseTextureUri` parameter must be set to a .png image with a noise texture. It is up to the developer to create his own noise texture and to import it into the app. An easy plugin to create one is [NoiseChoice](https://forums.getpaint.net/topic/22500-red-ochre-plug-in-pack-v9-updated-30th-july-2014/) for [Paint.NET](https://www.getpaint.net/). #### Create and assign an acrylic brush in C# + ```C# control.Background = CompositionBrushBuilder.FromHostBackdropAcrylic(Colors.DarkOrange, 0.6f, new Uri("ms-appx:///Assets/noise.png")).AsBrush(); ``` #### Build an acrylic effect pipeline from scratch: + ```C# Brush brush = CompositionBrushBuilder.FromHostBackdropBrush() .Effect(source => new LuminanceToAlphaEffect { Source = source }) @@ -113,6 +117,7 @@ Brush brush = CompositionBrushBuilder.FromHostBackdropBrush() The `CompositionBrushBuilder` class can also be used to quickly implement custom XAML brushes with an arbitrary effects pipeline. To do so, just inherit from `XamlCompositionEffectBrushBase` and setup your own effects pipeline in the `OnBrushRequested` method. #### Get a custom effect that can be animated: + ```C# // Build the effects pipeline XamlCompositionBrush acrylic = CompositionBrushBuilder.FromHostBackdropAcrylic(Colors.Orange, 0.6f, new Uri("ms-appx:///Assets/noise.png")) @@ -124,6 +129,34 @@ acrylic.Bind(animation, out XamlEffectAnimation saturation); // Bind the effect saturation(0.2f, 250); // Animate the opacity to 0.2 in 250ms ``` +#### Create custom effects in XAML: + +Using the APIs in `UICompositionAnimations.Behaviours.Xaml` it is also possible to build complex Composition/Win2D pipelines directly from XAML, in a declarative way. This is how to define a custom host backdrop acrylic brush: + +```xml +xmlns:xaml="using:UICompositionAnimations.Behaviours.Xaml" +xmlns:effects="using:UICompositionAnimations.Behaviours.Xaml.Effects" + + + + + + + + + + + + + + + + + + + +``` + ## Reveal highlight effect Part of the Fluent Design System introduced with Windows 10 Fall Creators Update, this effect can actually already be used with Windows 10 Creators Update (build 15063.x). The library exposes APIs to easily use the effect in an application. @@ -145,6 +178,7 @@ LightsSourceHelper.SetIsLightsContainer(Window.Current.Content, true); // Assign ``` #### Setup the target brushes for the lights + ````XAML ```` + ```C# // Since the second light has a special ID, it is necessary to manually set its target brush LightingBrush brush = Application.Current.Resources["BorderWideLightBrush"] as LightingBrush; From 6e0b1d638dd3085ebe0d10fd3d010ef059009a6b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Mar 2019 15:09:22 +0100 Subject: [PATCH 6/6] Updated NuGet info --- UICompositionAnimations/Properties/AssemblyInfo.cs | 8 ++++---- UICompositionAnimations/UICompositionAnimations.csproj | 2 +- UICompositionAnimations/UICompositionAnimations.nuspec | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/UICompositionAnimations/Properties/AssemblyInfo.cs b/UICompositionAnimations/Properties/AssemblyInfo.cs index e5a55dc..9e38cf0 100644 --- a/UICompositionAnimations/Properties/AssemblyInfo.cs +++ b/UICompositionAnimations/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sergio Pedri")] [assembly: AssemblyProduct("UICompositionAnimations")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -23,8 +23,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.1.0")] -[assembly: AssemblyFileVersion("3.0.1.0")] -[assembly: AssemblyInformationalVersion("3.0.1")] +[assembly: AssemblyVersion("3.1.0.0")] +[assembly: AssemblyFileVersion("3.1.0.0")] +[assembly: AssemblyInformationalVersion("3.1.0")] [assembly: ComVisible(false)] diff --git a/UICompositionAnimations/UICompositionAnimations.csproj b/UICompositionAnimations/UICompositionAnimations.csproj index 8ba5c6c..7b44c92 100644 --- a/UICompositionAnimations/UICompositionAnimations.csproj +++ b/UICompositionAnimations/UICompositionAnimations.csproj @@ -178,7 +178,7 @@ - 2018.2.1 + 2018.3.0 6.1.9 diff --git a/UICompositionAnimations/UICompositionAnimations.nuspec b/UICompositionAnimations/UICompositionAnimations.nuspec index 5ab12da..9c3aed5 100644 --- a/UICompositionAnimations/UICompositionAnimations.nuspec +++ b/UICompositionAnimations/UICompositionAnimations.nuspec @@ -2,19 +2,19 @@ UICompositionAnimations - 3.0.1 + 3.1.0 UICompositionAnimations A wrapper UWP PCL to work with Windows.UI.Composition and XAML animations, and Win2D effects Sergio Pedri Sergio Pedri https://github.com/Sergio0694/UICompositionAnimations - https://github.com/Sergio0694/UICompositionAnimations/blob/master/LICENSE.md + GPL-3.0-only false - Added new pointer events handling APIs - Copyright © 2018 + New PipelineBrush and composition effect APIs + Copyright © 2010 uwp composition animations xaml csharp windows winrt universal app ui win2d graphics - +