Skip to content
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

feat: AnimatedVisualPlayer #19298

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5553,6 +5553,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\AnimatedIconTests\AnimatedIconPage.xaml.cs">
<DependentUpon>AnimatedIconPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\AnimatedVisualPlayer\Checkmark.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\BreadcrumbTests\BreadcrumbBarPage.xaml.cs">
<DependentUpon>BreadcrumbBarPage.xaml</DependentUpon>
</Compile>
Expand Down
34 changes: 25 additions & 9 deletions src/Uno.UI.Composition/Composition/Compositor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,41 @@ public Compositor()
// See https://github.com/dotnet/runtime/blob/c52fd37cc835a13bcfa9a64fdfe7520809a75345/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Stopwatch.cs#L157
public long TimestampInTicks => unchecked((long)(Stopwatch.GetTimestamp() * s_tickFrequency));

/// <summary>
/// Creates an instance of AnimationController.
/// </summary>
/// <returns>The created AnimationController object.</returns>
public AnimationController CreateAnimationController() => new(this);

/// <summary>
/// Creates an instance of CompositionColorBrush.
/// </summary>
/// <returns>Returns the created CompositionColorBrush object.</returns>
public CompositionColorBrush CreateColorBrush() => new(this);

/// <summary>
/// Creates an instance of CompositionColorBrush using the specified color.
/// </summary>
/// <param name="color">The color for the brush to use.</param>
/// <returns>Returns the created CompositionColorBrush object.</returns>
public CompositionColorBrush CreateColorBrush(Color color) => new(this)
{
Color = color
};

internal static Compositor GetSharedCompositor() => _sharedCompositorLazy.Value;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static CompositionEasingFunction GetDefaultEasingFunction() => _defaultEasingFunction.Value;

public ContainerVisual CreateContainerVisual()
=> new ContainerVisual(this);

public ContainerVisual CreateContainerVisual() => new(this);

public SpriteVisual CreateSpriteVisual()
=> new SpriteVisual(this);

public CompositionColorBrush CreateColorBrush()
=> new CompositionColorBrush(this);

public CompositionColorBrush CreateColorBrush(Color color)
=> new CompositionColorBrush(this)
{
Color = color
};


public ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation()
=> new ScalarKeyFrameAnimation(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static float MinGlobalPlaybackRate
#endif
// Skipping already declared method Microsoft.UI.Composition.Compositor.CreateRadialGradientBrush()
// Skipping already declared method Microsoft.UI.Composition.Compositor.CreateVisualSurface()
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Composition.AnimationController CreateAnimationController()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Automation.Peers
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class AnimatedVisualPlayerAutomationPeer : global::Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public AnimatedVisualPlayerAutomationPeer(global::Microsoft.UI.Xaml.Controls.AnimatedVisualPlayer owner) : base(owner)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class AnimatedVisualPlayer : global::Microsoft.UI.Xaml.FrameworkE
// Skipping already declared property PlaybackRate
// Skipping already declared property FallbackContent
// Skipping already declared property AutoPlay
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public object Diagnostics
{
Expand All @@ -26,7 +26,7 @@ public object Diagnostics
// Skipping already declared property Duration
// Skipping already declared property IsAnimatedVisualLoaded
// Skipping already declared property IsPlaying
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Composition.CompositionObject ProgressObject
{
Expand All @@ -36,7 +36,7 @@ public object Diagnostics
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Xaml.Controls.PlayerAnimationOptimization AnimationOptimization
{
Expand All @@ -51,7 +51,7 @@ public object Diagnostics
}
#endif
// Skipping already declared property AutoPlayProperty
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty DiagnosticsProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
Expand All @@ -66,7 +66,7 @@ public object Diagnostics
// Skipping already declared property PlaybackRateProperty
// Skipping already declared property SourceProperty
// Skipping already declared property StretchProperty
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty AnimationOptimizationProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial interface IAnimatedVisual2 : global::Microsoft.UI.Xaml.Controls.IAnimatedVisual, global::System.IDisposable
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
void CreateAnimations();
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
void DestroyAnimations();
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.UI.Xaml.Controls
#endif
public partial interface IAnimatedVisualSource
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
global::Microsoft.UI.Xaml.Controls.IAnimatedVisual TryCreateAnimatedVisual(global::Microsoft.UI.Composition.Compositor compositor, out object diagnostics);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial interface IAnimatedVisualSource3
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
global::Microsoft.UI.Xaml.Controls.IAnimatedVisual2 TryCreateAnimatedVisual(global::Microsoft.UI.Composition.Compositor compositor, out object diagnostics, bool createAnimations);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
public enum PlayerAnimationOptimization
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
Latency = 0,
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
Resources = 1,
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference src\controls\dev\Generated\AnimatedVisualPlayer.properties.cpp, tag winui3/release/1.6.3, commit 66d24dfff

using System;
using Microsoft.UI.Xaml.Media;

namespace Microsoft/* UWP don't rename */.UI.Xaml.Controls;

partial class AnimatedVisualPlayer
{
/// <summary>
/// Gets or sets a value that specifies how animations are cached when the AnimatedVisualPlayer is idle (when PlayAsync is not active).
/// </summary>
public PlayerAnimationOptimization AnimationOptimization
{
get => (PlayerAnimationOptimization)GetValue(AnimationOptimizationProperty);
set => SetValue(AnimationOptimizationProperty, value);
}

/// <summary>
/// Identifies the AnimationOptimization dependency property.
/// </summary>
public static DependencyProperty AnimationOptimizationProperty { get; } =
DependencyProperty.Register(
nameof(AnimationOptimization),
typeof(PlayerAnimationOptimization),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
PlayerAnimationOptimization.Latency,
(sender, args) => ((AnimatedVisualPlayer)sender).OnAnimationOptimizationPropertyChanged(args));

/// <summary>
/// Gets or sets a value that indicates whether an animated visual plays immediately when it is loaded.
/// </summary>
public bool AutoPlay
{
get => (bool)GetValue(AutoPlayProperty);
set => SetValue(AutoPlayProperty, value);
}

/// <summary>
/// Identifies the AutoPlay dependency property.
/// </summary>
public static DependencyProperty AutoPlayProperty { get; } =
DependencyProperty.Register(
nameof(AutoPlay),
typeof(bool),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
true,
(sender, args) => ((AnimatedVisualPlayer)sender).OnAutoPlayPropertyChanged(args)));

/// <summary>
/// Gets optional diagnostics information about the last attempt to load an animated visual.
/// </summary>
public object Diagnostics
{
get => GetValue(DiagnosticsProperty);
private set => SetValue(DiagnosticsProperty, value);
}

/// <summary>
/// Identifies the Diagnostics dependency property.
/// </summary>
public static DependencyProperty DiagnosticsProperty { get; } =
DependencyProperty.Register(
nameof(Diagnostics),
typeof(object),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(null));

/// <summary>
/// Gets the duration of the the currently loaded animated visual, or TimeSpan.Zero if no animated visual is loaded.
/// </summary>
public TimeSpan Duration
{
get => (TimeSpan)GetValue(DurationProperty);
private set => SetValue(DurationProperty, value);
}

/// <summary>
/// Identifies the Duration dependency property.
/// </summary>
public static DependencyProperty DurationProperty { get; } =
DependencyProperty.Register(
nameof(Duration),
typeof(TimeSpan),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(default(TimeSpan)));

/// <summary>
/// Gets or sets content to display if an animated visual fails to load.
/// </summary>
public DataTemplate FallbackContent
{
get => (DataTemplate)GetValue(FallbackContentProperty);
set => SetValue(FallbackContentProperty, value);
}

/// <summary>
/// Identifies the FallbackContent dependency property.
/// </summary>
public static DependencyProperty FallbackContentProperty { get; } =
DependencyProperty.Register(
nameof(FallbackContent),
typeof(DataTemplate),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
null,
(sender, args) => ((AnimatedVisualPlayer)sender).OnFallbackContentPropertyChanged(args)));

/// <summary>
/// Gets a value that indicates whether an animated visual is loaded.
/// </summary>
public bool IsAnimatedVisualLoaded
{
get => (bool)GetValue(IsAnimatedVisualLoadedProperty);
private set => SetValue(IsAnimatedVisualLoadedProperty, value);
}

/// <summary>
/// Identifies the IsAnimatedVisualLoaded dependency property.
/// </summary>
public static DependencyProperty IsAnimatedVisualLoadedProperty { get; } =
DependencyProperty.Register(nameof(IsAnimatedVisualLoaded), typeof(bool), typeof(AnimatedVisualPlayer), new FrameworkPropertyMetadata(false));

/// <summary>
/// Gets a value that indicates whether an animated visual is loaded and a play is underway.
/// </summary>
public bool IsPlaying => (bool)GetValue(IsPlayingProperty);

/// <summary>
/// Identifies the IsPlaying dependency property.
/// </summary>
public static DependencyProperty IsPlayingProperty { get; } =
DependencyProperty.Register(
nameof(IsPlaying),
typeof(bool),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(false));

/// <summary>
/// Gets or sets the rate at which the animation plays.
/// </summary>
public double PlaybackRate
{
get => (double)GetValue(PlaybackRateProperty);
set => SetValue(PlaybackRateProperty, value);
}

/// <summary>
/// Identifies the PlaybackRate dependency property.
/// </summary>
public static DependencyProperty PlaybackRateProperty { get; } =
DependencyProperty.Register(
nameof(PlaybackRate),
typeof(double),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
1.0,
(sender, args) => ((AnimatedVisualPlayer)sender).OnPlaybackRatePropertyChanged(args)));

/// <summary>
/// Gets or sets the provider of the animated visual for the player.
/// </summary>
public IAnimatedVisualSource Source
{
get => (IAnimatedVisualSource)GetValue(SourceProperty);
set => SetValue(SourceProperty, value);
}

/// <summary>
/// Identifies the Source dependency property.
/// </summary>
public static DependencyProperty SourceProperty { get; } =
DependencyProperty.Register(
nameof(Source),
typeof(IAnimatedVisualSource),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
null,
(sender, args) => ((AnimatedVisualPlayer)sender).OnSourcePropertyChanged(args)));

/// <summary>
/// Gets or sets a value that describes how an animated visual should be stretched to fill the destination rectangle.
/// </summary>
public Stretch Stretch
{
get => (Stretch)GetValue(StretchProperty);
set => SetValue(StretchProperty, value);
}

/// <summary>
/// Identifies the Stretch dependency property.
/// </summary>
public static DependencyProperty StretchProperty { get; } =
DependencyProperty.Register(
nameof(Stretch),
typeof(Stretch),
typeof(AnimatedVisualPlayer),
new FrameworkPropertyMetadata(
Stretch.Uniform,
(sender, args) => ((AnimatedVisualPlayer)sender).OnStretchPropertyChanged(args)));
}
Loading
Loading