Родитель
e245373a8a
Коммит
b04e5a0a05
|
@ -143,6 +143,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompMetadata", "source\Comp
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompMetadata.dll", "dlls\CompMetadata\CompMetadata.dll.csproj", "{A262757C-9F1A-4F6E-9188-849F4B709D67}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "NullablesAttributes", "source\NullablesAttributes\NullablesAttributes.shproj", "{E32587A8-94E8-4B68-91AD-F3612A48A62B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
source\LottieToWinComp\LottieToWinComp.projitems*{0340244a-683c-405e-838b-f93872779532}*SharedItemsImports = 13
|
||||
|
@ -161,17 +163,21 @@ Global
|
|||
source\LottieReader\LottieReader.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\LottieToWinComp\LottieToWinComp.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\Lottie\Lottie.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\UIData\UIData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\WinCompData\WinCompData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\WinStorageStreamsData\WinStorageStreamsData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\YamlData\YamlData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
|
||||
source\GenericData\GenericData.projitems*{6221591a-e8f4-4a5e-8f0c-2651c24ad495}*SharedItemsImports = 5
|
||||
source\LottieData\LottieData.projitems*{6221591a-e8f4-4a5e-8f0c-2651c24ad495}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{6221591a-e8f4-4a5e-8f0c-2651c24ad495}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{68317393-f5a5-4b2c-918a-688db2c10f54}*SharedItemsImports = 5
|
||||
source\WinCompData\WinCompData.projitems*{68317393-f5a5-4b2c-918a-688db2c10f54}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{6ab50ed0-6273-4919-9ade-50195664ef15}*SharedItemsImports = 4
|
||||
source\UIData\UIData.projitems*{74601e6c-2dfe-4842-b170-047941abff2c}*SharedItemsImports = 13
|
||||
source\GenericData\GenericData.projitems*{77bcd724-8555-463b-985f-f8e8110164c4}*SharedItemsImports = 13
|
||||
source\Lottie\Lottie.projitems*{8ef7bd77-28e9-4998-8dbb-8036f988fe65}*SharedItemsImports = 13
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{9a99e690-71d2-4e26-9000-0e0920394dfe}*SharedItemsImports = 5
|
||||
source\UIData\UIData.projitems*{9a99e690-71d2-4e26-9000-0e0920394dfe}*SharedItemsImports = 5
|
||||
source\UIDataCodeGen\UIDataCodeGen.projitems*{9b6c0b7f-0d0f-4086-9746-0d34d7667db5}*SharedItemsImports = 5
|
||||
source\CompMetadata\CompMetadata.projitems*{a262757c-9f1a-4f6e-9188-849f4b709d67}*SharedItemsImports = 5
|
||||
|
@ -179,8 +185,8 @@ Global
|
|||
source\CompMetadata\CompMetadata.projitems*{b0197c19-bdf5-473e-a022-e21f6122eee5}*SharedItemsImports = 13
|
||||
source\LottieData\LottieData.projitems*{b3db16ee-a821-4474-a188-e64926529bbd}*SharedItemsImports = 13
|
||||
source\LottieReader\LottieReader.projitems*{bb081e5a-cf3c-490f-8f8e-450a79f6ca33}*SharedItemsImports = 5
|
||||
source\LottieMetadata\LottieMetadata.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
|
||||
source\LottieToWinComp\LottieToWinComp.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
|
||||
source\CompMetadata\CompMetadata.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
source\GenericData\GenericData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
source\LottieData\LottieData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
|
@ -193,9 +199,11 @@ Global
|
|||
source\WinStorageStreamsData\WinStorageStreamsData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
source\YamlData\YamlData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{cb587630-3cfd-4bb3-867c-3f5b1ffbc738}*SharedItemsImports = 5
|
||||
source\YamlData\YamlData.projitems*{cb587630-3cfd-4bb3-867c-3f5b1ffbc738}*SharedItemsImports = 5
|
||||
source\WinCompData\WinCompData.projitems*{d02870de-7ded-4916-85d4-3175ceedef74}*SharedItemsImports = 13
|
||||
source\UIDataCodeGen\UIDataCodeGen.projitems*{d02be6c8-14db-4b4f-8600-f3c9b69c104d}*SharedItemsImports = 13
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{e32587a8-94e8-4b68-91ad-f3612a48a62b}*SharedItemsImports = 13
|
||||
source\CompMetadata\CompMetadata.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\GenericData\GenericData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\LottieData\LottieData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
|
@ -203,6 +211,7 @@ Global
|
|||
source\LottieReader\LottieReader.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\LottieToWinComp\LottieToWinComp.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\Lottie\Lottie.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\NullablesAttributes\NullablesAttributes.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\UIData\UIData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\WinCompData\WinCompData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
source\WinStorageStreamsData\WinStorageStreamsData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
|
||||
|
@ -475,6 +484,7 @@ Global
|
|||
{25CEB8B8-90E0-4D23-9978-0CD83889D4AC} = {C75BD686-21A6-4EB3-8D4B-D5A01C019C52}
|
||||
{B0197C19-BDF5-473E-A022-E21F6122EEE5} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
|
||||
{A262757C-9F1A-4F6E-9188-849F4B709D67} = {C75BD686-21A6-4EB3-8D4B-D5A01C019C52}
|
||||
{E32587A8-94E8-4B68-91AD-F3612A48A62B} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {51B9BB4C-5196-41CF-950C-12B04AD8A61C}
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<Import Project="..\source\LottieMetadata\LottieMetadata.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieReader\LottieReader.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
|
||||
<Import Project="..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="..\source\UIData\UIData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\WinCompData\WinCompData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\WinStorageStreamsData\WinStorageStreamsData.projitems" Label="Shared" />
|
||||
|
|
|
@ -411,7 +411,7 @@ sealed class LottieFileProcessor
|
|||
// NOTE: this only writes the latest version of a multi-version translation.
|
||||
var result = TryWriteTextFile(
|
||||
outputFilePath,
|
||||
CompositionObjectDgmlSerializer.ToXml(_translationResults[0].RootVisual).ToString());
|
||||
CompositionObjectDgmlSerializer.ToXml(_translationResults[0].RootVisual!).ToString());
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
@ -663,7 +663,7 @@ sealed class LottieFileProcessor
|
|||
? "Microsoft.UI.Xaml.Controls.IAnimatedVisual"
|
||||
: _options.Interface,
|
||||
objectGraphs: _translationResults.Select(
|
||||
tr => ((CompositionObject)tr.RootVisual, tr.MinimumRequiredUapVersion)).ToArray(),
|
||||
tr => ((CompositionObject?)tr.RootVisual!, tr.MinimumRequiredUapVersion)).ToArray(),
|
||||
nameSpace: string.IsNullOrWhiteSpace(_options.Namespace)
|
||||
? "AnimatedVisuals"
|
||||
: NormalizeNamespace(_options.Namespace),
|
||||
|
@ -829,7 +829,7 @@ sealed class LottieFileProcessor
|
|||
// Optimize the code unless told not to.
|
||||
if (!_options.DisableTranslationOptimizer)
|
||||
{
|
||||
_translationResults = _translationResults.Select(tr => tr.WithDifferentRoot(Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools.Optimizer.Optimize(tr.RootVisual, ignoreCommentProperties: true))).ToArray();
|
||||
_translationResults = _translationResults.Select(tr => tr.WithDifferentRoot(Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools.Optimizer.Optimize(tr.RootVisual!, ignoreCommentProperties: true))).ToArray();
|
||||
_profiler.OnOptimizationFinished();
|
||||
|
||||
// NOTE: this is only reporting on the latest version in a multi-version translation.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -42,11 +42,11 @@ namespace LottieViewer
|
|||
protected override async void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
#pragma warning restore VSTHRD100
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
var rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
if (rootFrame is null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System.ComponentModel;
|
||||
using Windows.UI;
|
||||
|
@ -22,7 +22,7 @@ namespace LottieViewer
|
|||
Name = name;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// If true, changing the Color will also change the InitialColor to keep it the
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
<Nullable>enable</Nullable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<SuppressXamlWarnings>1501</SuppressXamlWarnings>
|
||||
</PropertyGroup>
|
||||
|
@ -252,18 +253,19 @@
|
|||
<Version>1.25.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\source\CompMetadata\CompMetadata.projitems" Label="Shared" />
|
||||
<Import Project="..\source\GenericData\GenericData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\Lottie\Lottie.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieData\LottieData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieMetadata\LottieMetadata.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieReader\LottieReader.projitems" Label="Shared" />
|
||||
<Import Project="..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
|
||||
<Import Project="..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="..\source\UIData\UIData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\WinCompData\WinCompData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\WinStorageStreamsData\WinStorageStreamsData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\WinUIXamlMediaData\WinUIXamlMediaData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\YamlData\YamlData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\GenericData\GenericData.projitems" Label="Shared" />
|
||||
<Import Project="..\source\CompMetadata\CompMetadata.projitems" Label="Shared" />
|
||||
<Target Name="Pack">
|
||||
<!-- Dummy target to mute warnings about attempts to create a NuPkg -->
|
||||
</Target>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
//#define DebugDragDrop
|
||||
using System;
|
||||
|
@ -121,7 +121,7 @@ namespace LottieViewer
|
|||
};
|
||||
filePicker.FileTypeFilter.Add(".json");
|
||||
|
||||
StorageFile file = null;
|
||||
StorageFile? file = null;
|
||||
try
|
||||
{
|
||||
file = await filePicker.PickSingleFileAsync();
|
||||
|
@ -146,7 +146,7 @@ namespace LottieViewer
|
|||
_scrubber.Value = 0;
|
||||
|
||||
// If we were stopped in manual play control, turn it back to automatic.
|
||||
if (!_playStopButton.IsChecked.Value)
|
||||
if (_playStopButton.IsChecked != true)
|
||||
{
|
||||
_playStopButton.IsChecked = true;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ namespace LottieViewer
|
|||
DebugDragDrop("Dropping");
|
||||
var playVersion = ++_playVersion;
|
||||
|
||||
IStorageItem item = null;
|
||||
IStorageItem? item = null;
|
||||
try
|
||||
{
|
||||
item = (await e.DataView.GetStorageItemsAsync()).Single();
|
||||
|
@ -231,11 +231,17 @@ namespace LottieViewer
|
|||
return;
|
||||
}
|
||||
|
||||
if (item is null)
|
||||
{
|
||||
DebugDragDrop("Ignoring drop");
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the scrubber to the 0 position.
|
||||
_scrubber.Value = 0;
|
||||
|
||||
// If we were stopped in manual play control, turn it back to automatic.
|
||||
if (!_playStopButton.IsChecked.Value)
|
||||
if (_playStopButton.IsChecked != true)
|
||||
{
|
||||
_playStopButton.IsChecked = true;
|
||||
}
|
||||
|
@ -256,7 +262,7 @@ namespace LottieViewer
|
|||
|
||||
bool _ignoreScrubberValueChanges;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
void ProgressSliderChanged(object sender, ScrubberValueChangedEventArgs e)
|
||||
{
|
||||
|
@ -282,7 +288,7 @@ namespace LottieViewer
|
|||
|
||||
// Otherwise, if we toggled on, we're stopped in manual mode: set the progress.
|
||||
// If we toggled off, we're in auto mode, start playing.
|
||||
if (!_playStopButton.IsChecked.Value)
|
||||
if (_playStopButton.IsChecked != true)
|
||||
{
|
||||
_stage.Player.SetProgress(_scrubber.Value);
|
||||
}
|
||||
|
@ -418,13 +424,13 @@ namespace LottieViewer
|
|||
|
||||
public sealed class PropertiesTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate Normal { get; set; }
|
||||
public DataTemplate? Normal { get; set; }
|
||||
|
||||
public DataTemplate Marker { get; set; }
|
||||
public DataTemplate? Marker { get; set; }
|
||||
|
||||
public DataTemplate MarkerWithDuration { get; set; }
|
||||
public DataTemplate? MarkerWithDuration { get; set; }
|
||||
|
||||
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
|
||||
protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container)
|
||||
{
|
||||
if (item is PairOfStrings)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -24,7 +24,7 @@ namespace LottieViewer
|
|||
/// </summary>
|
||||
public sealed partial class PaletteColorPicker : UserControl
|
||||
{
|
||||
LottieVisualDiagnosticsViewModel _diagnosticsViewModel;
|
||||
LottieVisualDiagnosticsViewModel? _diagnosticsViewModel;
|
||||
|
||||
// Used to prevent infinite recursion when the color picker is updated.
|
||||
// Needed because we have 2-way binding between 2 color pickers and they
|
||||
|
@ -37,11 +37,16 @@ namespace LottieViewer
|
|||
PaletteEntries.CollectionChanged += PaletteEntries_CollectionChanged;
|
||||
}
|
||||
|
||||
internal LottieVisualDiagnosticsViewModel DiagnosticsViewModel
|
||||
internal LottieVisualDiagnosticsViewModel? DiagnosticsViewModel
|
||||
{
|
||||
get => _diagnosticsViewModel;
|
||||
set
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_diagnosticsViewModel != null)
|
||||
{
|
||||
// Unhook form the previous DiagnosticsViewModel.
|
||||
|
@ -101,7 +106,7 @@ namespace LottieViewer
|
|||
entry.PropertyChanged += (_, args) =>
|
||||
{
|
||||
var newColor = entry.Color;
|
||||
_diagnosticsViewModel.ThemingPropertySet.InsertVector4(item.BindingName, ColorAsVector4(entry.Color));
|
||||
_diagnosticsViewModel?.ThemingPropertySet?.InsertVector4(item.BindingName, ColorAsVector4(entry.Color));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +180,7 @@ namespace LottieViewer
|
|||
|
||||
// Search up the tree for an object with a data context, and returns
|
||||
// the data context.
|
||||
object GetDataContext(DependencyObject obj)
|
||||
object? GetDataContext(DependencyObject obj)
|
||||
{
|
||||
if (obj is FrameworkElement fe && fe.DataContext != null)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
|
@ -50,13 +50,13 @@ namespace LottieViewer
|
|||
readonly CompositionColorBrush _decreaseRectangleBrush;
|
||||
readonly SolidColorBrush _markerBrush;
|
||||
|
||||
LottieVisualDiagnosticsViewModel _diagnostics;
|
||||
LottieVisualDiagnosticsViewModel? _diagnostics;
|
||||
|
||||
string _currentVisualStateName;
|
||||
string _currentVisualStateName = string.Empty;
|
||||
|
||||
public event TypedEventHandler<Scrubber, ScrubberValueChangedEventArgs> ValueChanged;
|
||||
public event TypedEventHandler<Scrubber, ScrubberValueChangedEventArgs>? ValueChanged;
|
||||
|
||||
internal LottieVisualDiagnosticsViewModel DiagnosticsViewModel
|
||||
internal LottieVisualDiagnosticsViewModel? DiagnosticsViewModel
|
||||
{
|
||||
get => _diagnostics;
|
||||
set
|
||||
|
@ -67,7 +67,11 @@ namespace LottieViewer
|
|||
}
|
||||
|
||||
_diagnostics = value;
|
||||
_diagnostics.Markers.CollectionChanged += Markers_CollectionChanged;
|
||||
|
||||
if (_diagnostics != null)
|
||||
{
|
||||
_diagnostics.Markers.CollectionChanged += Markers_CollectionChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,13 +201,16 @@ namespace LottieViewer
|
|||
// Adjust the position of the markers.
|
||||
// Set the margin on each of the rectangles in the grid so that they match
|
||||
// the offsets of the markers in the view model.
|
||||
for (var i = 0; i < _diagnostics.Markers.Count; i++)
|
||||
if (_diagnostics != null)
|
||||
{
|
||||
var topRect = (Rectangle)_markersTop.Children[i];
|
||||
var bottomRect = (Rectangle)_markersBottom.Children[i];
|
||||
var offset = _diagnostics.Markers[i].ConstrainedProgress;
|
||||
topRect.Margin = new Thickness((offset * barWidth) + c_trackMargin, 0, 0, 0);
|
||||
bottomRect.Margin = new Thickness((offset * barWidth) + c_trackMargin, 0, 0, 0);
|
||||
for (var i = 0; i < _diagnostics.Markers.Count; i++)
|
||||
{
|
||||
var topRect = (Rectangle)_markersTop.Children[i];
|
||||
var bottomRect = (Rectangle)_markersBottom.Children[i];
|
||||
var offset = _diagnostics.Markers[i].ConstrainedProgress;
|
||||
topRect.Margin = new Thickness((offset * barWidth) + c_trackMargin, 0, 0, 0);
|
||||
bottomRect.Margin = new Thickness((offset * barWidth) + c_trackMargin, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -229,7 +236,7 @@ namespace LottieViewer
|
|||
{
|
||||
switch (_currentVisualStateName)
|
||||
{
|
||||
case null:
|
||||
case "":
|
||||
case "Normal":
|
||||
SetColors(
|
||||
markers: GetResourceBrushColor("LottieBasicBrush"),
|
||||
|
@ -327,7 +334,19 @@ namespace LottieViewer
|
|||
|
||||
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var duration = _owner._diagnostics.LottieVisualDiagnostics.Duration;
|
||||
var ownerDiagnostics = _owner._diagnostics;
|
||||
if (ownerDiagnostics is null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var lottieVisualDiagnostics = ownerDiagnostics.LottieVisualDiagnostics;
|
||||
if (lottieVisualDiagnostics is null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var duration = lottieVisualDiagnostics.Duration;
|
||||
return $" {_owner.Value:0.00}\r\n{_owner.Value * duration.TotalSeconds:0.00} secs";
|
||||
}
|
||||
|
||||
|
@ -344,7 +363,7 @@ namespace LottieViewer
|
|||
{
|
||||
// Keep track of the previous state so we don't notify the Scrubber of
|
||||
// the same state twice in succession.
|
||||
string _previousCommonState;
|
||||
string _previousCommonState = string.Empty;
|
||||
|
||||
protected override bool GoToStateCore(
|
||||
Control control,
|
||||
|
@ -362,7 +381,7 @@ namespace LottieViewer
|
|||
var newState = state?.Name;
|
||||
|
||||
// Check whether we have already reported this state.
|
||||
if (_previousCommonState != newState)
|
||||
if (newState != null && _previousCommonState != newState)
|
||||
{
|
||||
_previousCommonState = newState;
|
||||
scrubber.OnSliderVisualStateChange(newState);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -18,21 +18,21 @@ namespace LottieViewer.ViewModel
|
|||
/// </summary>
|
||||
sealed class LottieVisualDiagnosticsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public object DiagnosticsObject
|
||||
public object? DiagnosticsObject
|
||||
{
|
||||
get => LottieVisualDiagnostics;
|
||||
|
||||
set
|
||||
{
|
||||
LottieVisualDiagnostics = (LottieVisualDiagnostics)value;
|
||||
LottieVisualDiagnostics = (LottieVisualDiagnostics?)value;
|
||||
Issues.Clear();
|
||||
Markers.Clear();
|
||||
ThemePropertyBindings.Clear();
|
||||
ThemingPropertySet = null;
|
||||
|
||||
if (value != null)
|
||||
if (LottieVisualDiagnostics != null)
|
||||
{
|
||||
// Populate the issues list.
|
||||
foreach (var issue in LottieVisualDiagnostics.JsonParsingIssues.
|
||||
|
@ -58,28 +58,24 @@ namespace LottieViewer.ViewModel
|
|||
var progress = m.Frame / totalFrames;
|
||||
Marker marker;
|
||||
|
||||
var propertyName = isFirst ? $"Marker{(composition.Markers.Count > 1 ? "s" : string.Empty)}" : string.Empty;
|
||||
|
||||
if (m.DurationInFrames == 0)
|
||||
{
|
||||
marker = new Marker
|
||||
{
|
||||
ProgressText = $"{progress:0.000#}",
|
||||
};
|
||||
marker = new Marker(m.Name, propertyName, progress, $"{progress:0.000#}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var toProgress = progress + (m.DurationInFrames / totalFrames);
|
||||
marker = new MarkerWithDuration
|
||||
{
|
||||
ProgressText = $"{progress:0.000#}",
|
||||
ToProgress = toProgress,
|
||||
ToProgressText = $"{toProgress:0.000#}",
|
||||
};
|
||||
marker = new MarkerWithDuration(
|
||||
m.Name,
|
||||
propertyName, progress,
|
||||
$"{progress:0.000#}",
|
||||
toProgress,
|
||||
$"{toProgress:0.000#}");
|
||||
}
|
||||
|
||||
marker.PropertyName = isFirst ? $"Marker{(composition.Markers.Count > 1 ? "s" : string.Empty)}" : string.Empty;
|
||||
isFirst = false;
|
||||
marker.Name = m.Name;
|
||||
marker.Progress = progress;
|
||||
Markers.Add(marker);
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +105,7 @@ namespace LottieViewer.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
public LottieVisualDiagnostics LottieVisualDiagnostics { get; private set; }
|
||||
public LottieVisualDiagnostics? LottieVisualDiagnostics { get; private set; }
|
||||
|
||||
public string DurationText
|
||||
{
|
||||
|
@ -135,7 +131,7 @@ namespace LottieViewer.ViewModel
|
|||
|
||||
public ObservableCollection<PropertyBinding> ThemePropertyBindings { get; } = new ObservableCollection<PropertyBinding>();
|
||||
|
||||
public Windows.UI.Composition.CompositionPropertySet ThemingPropertySet { get; private set; }
|
||||
public Windows.UI.Composition.CompositionPropertySet? ThemingPropertySet { get; private set; }
|
||||
|
||||
public bool HasIssues => Issues.Count > 0;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -10,13 +10,21 @@ namespace LottieViewer.ViewModel
|
|||
{
|
||||
class Marker
|
||||
{
|
||||
public string PropertyName { get; set; }
|
||||
internal Marker(string name, string propertyName, double progress, string progressText)
|
||||
{
|
||||
Name = name;
|
||||
Progress = progress;
|
||||
ProgressText = progressText;
|
||||
PropertyName = propertyName;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string PropertyName { get; }
|
||||
|
||||
public double Progress { get; set; }
|
||||
public string Name { get; }
|
||||
|
||||
public string ProgressText { get; set; }
|
||||
public double Progress { get; }
|
||||
|
||||
public string ProgressText { get; }
|
||||
|
||||
public double ConstrainedProgress => Math.Max(0, Math.Min(1, Progress));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -11,9 +11,22 @@ namespace LottieViewer.ViewModel
|
|||
// A marker that has a non-0 duration.
|
||||
sealed class MarkerWithDuration : Marker
|
||||
{
|
||||
public double ToProgress { get; set; }
|
||||
internal MarkerWithDuration(
|
||||
string name,
|
||||
string propertyName,
|
||||
double progress,
|
||||
string progressText,
|
||||
double toProgress,
|
||||
string toProgressText)
|
||||
: base(name, propertyName, progress, progressText)
|
||||
{
|
||||
ToProgress = toProgress;
|
||||
ToProgressText = toProgressText;
|
||||
}
|
||||
|
||||
public string ToProgressText { get; set; }
|
||||
public double ToProgress { get; }
|
||||
|
||||
public string ToProgressText { get; }
|
||||
|
||||
public double ConstrainedToProgress => Math.Max(0, Math.Min(1, ToProgress));
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\source\LottieData\LottieData.projitems" Label="Shared" />
|
||||
|
||||
<Import Project="..\..\source\GenericData\GenericData.projitems" Label="Shared" />
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
|
@ -17,6 +16,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GenericData\GenericData.dll.csproj" />
|
||||
<ProjectReference Include="..\YamlData\YamlData.dll.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
|
||||
|
||||
<Import Project="..\..\source\LottieMetadata\LottieMetadata.projitems" Label="Shared" />
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CompMetadata\CompMetadata.dll.csproj" />
|
||||
<ProjectReference Include="..\LottieData\LottieData.dll.csproj" />
|
||||
<ProjectReference Include="..\LottieMetadata\LottieMetadata.dll.csproj" />
|
||||
<ProjectReference Include="..\WinCompData\WinCompData.dll.csproj" />
|
||||
<ProjectReference Include="..\WinStorageStreamsData\WinStorageStreamsData.dll.csproj" />
|
||||
<ProjectReference Include="..\WinUIXamlMediaData\WinUIXamlMediaData.dll.csproj" />
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<DefineConstants>PUBLIC_UIData</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="..\..\source\UIData\UIData.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<DefineConstants>PUBLIC_WinCompData</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="..\..\source\WinCompData\WinCompData.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<DefineConstants>PUBLIC_YamlData</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="..\..\source\YamlData\YamlData.projitems" Label="Shared" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using AnimatedVisuals;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
@ -40,11 +40,11 @@ namespace LottieSamples
|
|||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected async override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
Frame? rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
if (rootFrame is null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
|
|
@ -271,6 +271,7 @@
|
|||
<ItemGroup>
|
||||
<None Include="Assets\LottieLogo1_Modified.json" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\source\NullablesAttributes\NullablesAttributes.projitems" Label="Shared" />
|
||||
<Target Name="Pack">
|
||||
<!-- Dummy target to mute warnings about attempts to create a NuPkg -->
|
||||
</Target>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using LottieSamples.Scenarios;
|
||||
using System;
|
||||
|
@ -16,11 +16,13 @@ namespace LottieSamples
|
|||
{
|
||||
internal sealed class NavData
|
||||
{
|
||||
public string Tag;
|
||||
public Type Page;
|
||||
public string Tag { get; }
|
||||
public Type Page { get; }
|
||||
|
||||
public static implicit operator NavData((string tag, Type page)arg)
|
||||
=> new NavData { Tag = arg.tag, Page = arg.page};
|
||||
NavData(string tag, Type page) => (Tag, Page) = (tag, page);
|
||||
|
||||
public static implicit operator NavData((string tag, Type page) arg)
|
||||
=> new NavData(arg.tag, arg.page);
|
||||
}
|
||||
|
||||
public sealed partial class MainPage : Page
|
||||
|
@ -85,8 +87,11 @@ namespace LottieSamples
|
|||
.OfType<NavigationViewItem>()
|
||||
.First(n => n.Tag.Equals(item.Tag));
|
||||
|
||||
// Consequence of substituting NavigationViewItem's Icon + Content with a Stackpanel + 2 TextBlocks.
|
||||
NavView.Header = ((TextBlock)((StackPanel)((NavigationViewItem)NavView.SelectedItem)?.Content)?.Children[1]).Text.ToString();
|
||||
// Consequence of substituting NavigationViewItem's Icon + Content with a Stackpanel + 2 TextBlocks.
|
||||
var selectedItem = (NavigationViewItem?)NavView.SelectedItem;
|
||||
var selectedStackPanel = (StackPanel?)selectedItem?.Content;
|
||||
var selectedChild = (TextBlock?)selectedStackPanel?.Children[1];
|
||||
NavView.Header = selectedChild?.Text.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.MetaData;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.CompMetadata
|
||||
|
@ -16,20 +14,34 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.CompMetadata
|
|||
#endif
|
||||
sealed class PropertyBinding
|
||||
{
|
||||
public PropertyBinding(
|
||||
string bindingName,
|
||||
string displayName,
|
||||
PropertySetValueType actualType,
|
||||
PropertySetValueType exposedType,
|
||||
object defaultValue)
|
||||
{
|
||||
BindingName = bindingName;
|
||||
DisplayName = displayName;
|
||||
ActualType = actualType;
|
||||
ExposedType = exposedType;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name used to identify the value in the CompositionPropertySet.
|
||||
/// </summary>
|
||||
public string BindingName { get; set; }
|
||||
public string BindingName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A name for the binding for display in tools.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
public string DisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of data stored in the CompositionPropertySet under this name.
|
||||
/// </summary>
|
||||
public PropertySetValueType ActualType { get; set; }
|
||||
public PropertySetValueType ActualType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that should be used when making this binding available via an API.
|
||||
|
@ -37,11 +49,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.CompMetadata
|
|||
/// are not supported by animations expressions and must be stored using a different type,
|
||||
/// for example, colors are stored as Vector4.
|
||||
/// </summary>
|
||||
public PropertySetValueType ExposedType { get; set; }
|
||||
public PropertySetValueType ExposedType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The default value of the binding.
|
||||
/// </summary>
|
||||
public object DefaultValue { get; set; }
|
||||
public object DefaultValue { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -14,17 +14,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
#if PUBLIC_LottieData
|
||||
public
|
||||
#endif
|
||||
sealed class GenericDataList : GenericDataObject, IReadOnlyList<GenericDataObject>
|
||||
sealed class GenericDataList : GenericDataObject, IReadOnlyList<GenericDataObject?>
|
||||
{
|
||||
static GenericDataList s_empty;
|
||||
readonly IReadOnlyList<GenericDataObject> _items;
|
||||
readonly IReadOnlyList<GenericDataObject?> _items;
|
||||
|
||||
GenericDataList(IEnumerable<GenericDataObject> items)
|
||||
GenericDataList(IEnumerable<GenericDataObject?> items)
|
||||
{
|
||||
_items = items.ToArray();
|
||||
}
|
||||
|
||||
public static GenericDataList Create(IEnumerable<GenericDataObject> items)
|
||||
public static GenericDataList Create(IEnumerable<GenericDataObject?> items)
|
||||
{
|
||||
var result = new GenericDataList(items);
|
||||
return result._items.Count == 0
|
||||
|
@ -32,15 +31,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
: result;
|
||||
}
|
||||
|
||||
public static GenericDataList Empty => s_empty ??= new GenericDataList(Array.Empty<GenericDataObject>());
|
||||
public static GenericDataList Empty { get; } = new GenericDataList(Array.Empty<GenericDataObject?>());
|
||||
|
||||
public GenericDataObject this[int index] => _items[index];
|
||||
public GenericDataObject? this[int index] => _items[index];
|
||||
|
||||
public override GenericDataObjectType Type => GenericDataObjectType.List;
|
||||
|
||||
public int Count => _items.Count;
|
||||
|
||||
public IEnumerator<GenericDataObject> GetEnumerator() => _items.GetEnumerator();
|
||||
public IEnumerator<GenericDataObject?> GetEnumerator() => _items.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _items.GetEnumerator();
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
||||
|
@ -13,24 +14,23 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
#if PUBLIC_LottieData
|
||||
public
|
||||
#endif
|
||||
sealed class GenericDataMap : GenericDataObject, IReadOnlyDictionary<string, GenericDataObject>
|
||||
sealed class GenericDataMap : GenericDataObject, IReadOnlyDictionary<string, GenericDataObject?>
|
||||
{
|
||||
static GenericDataMap s_empty;
|
||||
readonly Dictionary<string, GenericDataObject> _items;
|
||||
readonly Dictionary<string, GenericDataObject?> _items;
|
||||
|
||||
GenericDataMap(IDictionary<string, GenericDataObject> items)
|
||||
GenericDataMap(IDictionary<string, GenericDataObject?> items)
|
||||
{
|
||||
_items = items.ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
|
||||
public static GenericDataMap Create(IDictionary<string, GenericDataObject> items)
|
||||
public static GenericDataMap Create(IDictionary<string, GenericDataObject?> items)
|
||||
=> items.Count == 0
|
||||
? Empty
|
||||
: new GenericDataMap(items);
|
||||
|
||||
public static GenericDataMap Empty => s_empty ??= new GenericDataMap(new Dictionary<string, GenericDataObject>(0));
|
||||
public static GenericDataMap Empty { get; } = new GenericDataMap(new Dictionary<string, GenericDataObject?>(0));
|
||||
|
||||
public GenericDataObject this[string key] => _items[key];
|
||||
public GenericDataObject? this[string key] => _items[key];
|
||||
|
||||
public override GenericDataObjectType Type => GenericDataObjectType.Map;
|
||||
|
||||
|
@ -42,17 +42,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
|
||||
public bool ContainsKey(string key) => _items.ContainsKey(key);
|
||||
|
||||
public IEnumerator<KeyValuePair<string, GenericDataObject>> GetEnumerator() => ((IReadOnlyDictionary<string, GenericDataObject>)_items).GetEnumerator();
|
||||
public IEnumerator<KeyValuePair<string, GenericDataObject?>> GetEnumerator() => ((IReadOnlyDictionary<string, GenericDataObject?>)_items).GetEnumerator();
|
||||
|
||||
public bool TryGetValue(string key, out GenericDataObject value) => _items.TryGetValue(key, out value);
|
||||
public bool TryGetValue(string key, out GenericDataObject? value) => _items.TryGetValue(key, out value);
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => ((IReadOnlyDictionary<string, GenericDataObject>)_items).GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => ((IReadOnlyDictionary<string, GenericDataObject?>)_items).GetEnumerator();
|
||||
|
||||
public override string ToString()
|
||||
=> _items.Count == 0
|
||||
? "{}"
|
||||
: $"{{{string.Join(", ", _items.Select(p => $"\"{p.Key}\":{ToString(p.Value)}"))}}}";
|
||||
|
||||
public static implicit operator GenericDataMap(Dictionary<string, GenericDataObject> value) => Create(value);
|
||||
public static implicit operator GenericDataMap(Dictionary<string, GenericDataObject?> value) => Create(value);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -17,7 +17,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
|
||||
public static implicit operator GenericDataObject(bool value) => GenericDataBool.Create(value);
|
||||
|
||||
public static implicit operator GenericDataObject(Dictionary<string, GenericDataObject> value) => GenericDataMap.Create(value);
|
||||
public static implicit operator GenericDataObject(Dictionary<string, GenericDataObject?> value) =>
|
||||
GenericDataMap.Create(value);
|
||||
|
||||
public static implicit operator GenericDataObject(double value) => GenericDataNumber.Create(value);
|
||||
|
||||
|
@ -25,7 +26,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
|
||||
// Converts an object to a string. This method exists to support
|
||||
// stringifying of objects that may be null.
|
||||
internal static string ToString(GenericDataObject obj)
|
||||
=> obj is null ? "null" : obj.ToString();
|
||||
internal static string ToString(GenericDataObject? obj)
|
||||
=> obj?.ToString() ?? "null";
|
||||
}
|
||||
}
|
|
@ -2,10 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.UIData.Tools;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
@ -21,15 +20,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
sealed class ContentFactory : IAnimatedVisualSource
|
||||
{
|
||||
internal static readonly ContentFactory FailedContent = new ContentFactory(null);
|
||||
readonly LottieVisualDiagnostics _diagnostics;
|
||||
WinCompData.Visual _wincompDataRootVisual;
|
||||
WinCompData.CompositionPropertySet _wincompDataThemingPropertySet;
|
||||
CompositionPropertySet _themingPropertySet;
|
||||
readonly LottieVisualDiagnostics? _diagnostics;
|
||||
WinCompData.Visual? _wincompDataRootVisual;
|
||||
WinCompData.CompositionPropertySet? _wincompDataThemingPropertySet;
|
||||
CompositionPropertySet? _themingPropertySet;
|
||||
double _width;
|
||||
double _height;
|
||||
TimeSpan _duration;
|
||||
|
||||
internal ContentFactory(LottieVisualDiagnostics diagnostics)
|
||||
internal ContentFactory(LottieVisualDiagnostics? diagnostics)
|
||||
{
|
||||
_diagnostics = diagnostics;
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
internal bool CanInstantiate => _wincompDataRootVisual != null;
|
||||
|
||||
public IAnimatedVisual TryCreateAnimatedVisual(Compositor compositor, out object diagnostics)
|
||||
public IAnimatedVisual? TryCreateAnimatedVisual(Compositor compositor, [MaybeNull] out object diagnostics)
|
||||
{
|
||||
// Clone the Diagnostics object so that the data from the translation is captured, then we
|
||||
// will update the clone with information about this particular instantiation.
|
||||
|
@ -73,9 +72,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
var instantiator = new Instantiator(compositor);
|
||||
|
||||
var result = new DisposableAnimatedVisual()
|
||||
// _wincompDataRootVisual != null is implied by CanInstantiate.
|
||||
var result = new DisposableAnimatedVisual((Visual)instantiator.GetInstance(_wincompDataRootVisual!))
|
||||
{
|
||||
RootVisual = (Visual)instantiator.GetInstance(_wincompDataRootVisual),
|
||||
Size = new System.Numerics.Vector2((float)_width, (float)_height),
|
||||
Duration = _duration,
|
||||
};
|
||||
|
@ -86,7 +85,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
{
|
||||
// Instantiate the theming property set. This is shared by all of the instantiations.
|
||||
_themingPropertySet = (CompositionPropertySet)instantiator.GetInstance(_wincompDataThemingPropertySet);
|
||||
diags.ThemingPropertySet = _diagnostics.ThemingPropertySet = _themingPropertySet;
|
||||
|
||||
// _diagnostics != null is implied by diags != null;
|
||||
diags.ThemingPropertySet = _diagnostics!.ThemingPropertySet = _themingPropertySet;
|
||||
}
|
||||
|
||||
diags.InstantiationTime = sw.Elapsed;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
@ -13,7 +13,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
{
|
||||
sealed class DisposableAnimatedVisual : IAnimatedVisual, IDisposable
|
||||
{
|
||||
public Visual RootVisual { get; set; }
|
||||
internal DisposableAnimatedVisual(Visual? rootVisual)
|
||||
{
|
||||
RootVisual = rootVisual;
|
||||
}
|
||||
|
||||
public Visual? RootVisual { get; }
|
||||
|
||||
public TimeSpan Duration { get; set; }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
{
|
||||
static class GenericDataToJson
|
||||
{
|
||||
internal static IJsonValue GenericDataObjectToJsonValue(GenericDataObject obj)
|
||||
internal static IJsonValue GenericDataObjectToJsonValue(GenericDataObject? obj)
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
#define ReuseExpressionAnimation
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
@ -47,7 +46,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
public Wc.CompositionObject GetInstance(Wd.CompositionObject obj) => GetCompositionObject(obj);
|
||||
|
||||
bool GetExisting<T>(object key, out T result)
|
||||
bool GetExisting<T>(object key, [MaybeNullWhen(false)] out T result)
|
||||
where T : class
|
||||
{
|
||||
if (_cache.TryGetValue(key, out object cached))
|
||||
{
|
||||
|
@ -272,6 +272,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
|
||||
T Cache<T>(object key, T obj)
|
||||
where T : class
|
||||
{
|
||||
_cache.Add(key, obj);
|
||||
return obj;
|
||||
|
@ -279,7 +280,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.ShapeVisual GetShapeVisual(Wd.ShapeVisual obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.ShapeVisual result))
|
||||
if (GetExisting<Wc.ShapeVisual>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -304,7 +305,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.SpriteVisual GetSpriteVisual(Wd.SpriteVisual obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.SpriteVisual result))
|
||||
if (GetExisting<Wc.SpriteVisual>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -323,7 +324,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.ContainerVisual GetContainerVisual(Wd.ContainerVisual obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.ContainerVisual result))
|
||||
if (GetExisting<Wc.ContainerVisual>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -388,7 +389,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.AnimationController GetAnimationController(Wd.AnimationController obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.AnimationController result))
|
||||
if (GetExisting<Wc.AnimationController>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -475,7 +476,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionPropertySet GetCompositionPropertySet(Wd.CompositionPropertySet obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionPropertySet result))
|
||||
if (GetExisting<Wc.CompositionPropertySet>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -500,35 +501,35 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
case Wd.MetaData.PropertySetValueType.Color:
|
||||
{
|
||||
obj.TryGetColor(name, out var value);
|
||||
result.InsertColor(name, Color(value));
|
||||
result.InsertColor(name, Color(value!.Value));
|
||||
break;
|
||||
}
|
||||
|
||||
case Wd.MetaData.PropertySetValueType.Scalar:
|
||||
{
|
||||
obj.TryGetScalar(name, out var value);
|
||||
result.InsertScalar(name, value);
|
||||
result.InsertScalar(name, value!.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Wd.MetaData.PropertySetValueType.Vector2:
|
||||
{
|
||||
obj.TryGetVector2(name, out var value);
|
||||
result.InsertVector2(name, value);
|
||||
result.InsertVector2(name, value!.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Wd.MetaData.PropertySetValueType.Vector3:
|
||||
{
|
||||
obj.TryGetVector3(name, out var value);
|
||||
result.InsertVector3(name, value);
|
||||
result.InsertVector3(name, value!.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Wd.MetaData.PropertySetValueType.Vector4:
|
||||
{
|
||||
obj.TryGetVector4(name, out var value);
|
||||
result.InsertVector4(name, value);
|
||||
result.InsertVector4(name, value!.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -616,7 +617,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.BooleanKeyFrameAnimation GetBooleanKeyFrameAnimation(Wd.BooleanKeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.BooleanKeyFrameAnimation result))
|
||||
if (GetExisting<Wc.BooleanKeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -646,7 +647,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.ColorKeyFrameAnimation GetColorKeyFrameAnimation(Wd.ColorKeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.ColorKeyFrameAnimation result))
|
||||
if (GetExisting<Wc.ColorKeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -681,7 +682,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.ScalarKeyFrameAnimation GetScalarKeyFrameAnimation(Wd.ScalarKeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.ScalarKeyFrameAnimation result))
|
||||
if (GetExisting<Wc.ScalarKeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -710,7 +711,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.Vector2KeyFrameAnimation GetVector2KeyFrameAnimation(Wd.Vector2KeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.Vector2KeyFrameAnimation result))
|
||||
if (GetExisting<Wc.Vector2KeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -739,7 +740,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.Vector3KeyFrameAnimation GetVector3KeyFrameAnimation(Wd.Vector3KeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.Vector3KeyFrameAnimation result))
|
||||
if (GetExisting<Wc.Vector3KeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -768,7 +769,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.Vector4KeyFrameAnimation GetVector4KeyFrameAnimation(Wd.Vector4KeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.Vector4KeyFrameAnimation result))
|
||||
if (GetExisting<Wc.Vector4KeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -797,7 +798,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.PathKeyFrameAnimation GetPathKeyFrameAnimation(Wd.PathKeyFrameAnimation obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.PathKeyFrameAnimation result))
|
||||
if (GetExisting<Wc.PathKeyFrameAnimation>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -812,8 +813,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
return result;
|
||||
}
|
||||
|
||||
Wc.CompositionEasingFunction GetCompositionEasingFunction(Wd.CompositionEasingFunction obj)
|
||||
Wc.CompositionEasingFunction? GetCompositionEasingFunction(Wd.CompositionEasingFunction? obj)
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (obj.Type)
|
||||
{
|
||||
case Wd.CompositionObjectType.LinearEasingFunction:
|
||||
|
@ -848,7 +854,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.InsetClip GetInsetClip(Wd.InsetClip obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.InsetClip result))
|
||||
if (GetExisting<Wc.InsetClip>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -858,33 +864,33 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
// CompositionClip properties
|
||||
if (!IsNullOrZero(obj.CenterPoint))
|
||||
{
|
||||
result.CenterPoint = obj.CenterPoint.Value;
|
||||
result.CenterPoint = obj.CenterPoint!.Value;
|
||||
}
|
||||
|
||||
if (!IsNullOrOne(obj.Scale))
|
||||
{
|
||||
result.Scale = obj.Scale.Value;
|
||||
result.Scale = obj.Scale!.Value;
|
||||
}
|
||||
|
||||
// InsetClip properties
|
||||
if (!IsNullOrZero(obj.LeftInset))
|
||||
{
|
||||
result.LeftInset = obj.LeftInset.Value;
|
||||
result.LeftInset = obj.LeftInset!.Value;
|
||||
}
|
||||
|
||||
if (!IsNullOrZero(obj.RightInset))
|
||||
{
|
||||
result.RightInset = obj.RightInset.Value;
|
||||
result.RightInset = obj.RightInset!.Value;
|
||||
}
|
||||
|
||||
if (!IsNullOrZero(obj.TopInset))
|
||||
{
|
||||
result.TopInset = obj.TopInset.Value;
|
||||
result.TopInset = obj.TopInset!.Value;
|
||||
}
|
||||
|
||||
if (!IsNullOrZero(obj.BottomInset))
|
||||
{
|
||||
result.BottomInset = obj.BottomInset.Value;
|
||||
result.BottomInset = obj.BottomInset!.Value;
|
||||
}
|
||||
|
||||
StartAnimations(obj, result);
|
||||
|
@ -893,7 +899,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionGeometricClip GetCompositionGeometricClip(Wd.CompositionGeometricClip obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionGeometricClip result))
|
||||
if (GetExisting<Wc.CompositionGeometricClip>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -905,7 +911,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.LinearEasingFunction GetLinearEasingFunction(Wd.LinearEasingFunction obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.LinearEasingFunction result))
|
||||
if (GetExisting<Wc.LinearEasingFunction>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -917,7 +923,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.StepEasingFunction GetStepEasingFunction(Wd.StepEasingFunction obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.StepEasingFunction result))
|
||||
if (GetExisting<Wc.StepEasingFunction>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -954,7 +960,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CubicBezierEasingFunction GetCubicBezierEasingFunction(Wd.CubicBezierEasingFunction obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CubicBezierEasingFunction result))
|
||||
if (GetExisting<Wc.CubicBezierEasingFunction>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -966,7 +972,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionViewBox GetCompositionViewBox(Wd.CompositionViewBox obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionViewBox result))
|
||||
if (GetExisting<Wc.CompositionViewBox>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -979,7 +985,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionVisualSurface GetCompositionVisualSurface(Wd.CompositionVisualSurface obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionVisualSurface result))
|
||||
if (GetExisting<Wc.CompositionVisualSurface>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1020,7 +1026,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionContainerShape GetCompositionContainerShape(Wd.CompositionContainerShape obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionContainerShape result))
|
||||
if (GetExisting<Wc.CompositionContainerShape>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1056,7 +1062,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionEffectBrush GetCompositionEffectBrush(Wd.CompositionEffectBrush obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionEffectBrush result))
|
||||
if (GetExisting<Wc.CompositionEffectBrush>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1097,7 +1103,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionSpriteShape GetCompositionSpriteShape(Wd.CompositionSpriteShape obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionSpriteShape result))
|
||||
if (GetExisting<Wc.CompositionSpriteShape>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1167,7 +1173,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionColorGradientStop GetCompositionColorGradientStop(Wd.CompositionColorGradientStop obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionColorGradientStop result))
|
||||
if (GetExisting<Wc.CompositionColorGradientStop>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1180,7 +1186,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionSurfaceBrush GetCompositionSurfaceBrush(Wd.CompositionSurfaceBrush obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionSurfaceBrush result))
|
||||
if (GetExisting<Wc.CompositionSurfaceBrush>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1196,8 +1202,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
return result;
|
||||
}
|
||||
|
||||
Wc.CompositionGeometry GetCompositionGeometry(Wd.CompositionGeometry obj)
|
||||
Wc.CompositionGeometry? GetCompositionGeometry(Wd.CompositionGeometry? obj)
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (obj.Type)
|
||||
{
|
||||
case Wd.CompositionObjectType.CompositionPathGeometry:
|
||||
|
@ -1219,7 +1230,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionEllipseGeometry GetCompositionEllipseGeometry(Wd.CompositionEllipseGeometry obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionEllipseGeometry result))
|
||||
if (GetExisting<Wc.CompositionEllipseGeometry>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1237,7 +1248,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionRectangleGeometry GetCompositionRectangleGeometry(Wd.CompositionRectangleGeometry obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionRectangleGeometry result))
|
||||
if (GetExisting<Wc.CompositionRectangleGeometry>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1259,7 +1270,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionRoundedRectangleGeometry GetCompositionRoundedRectangleGeometry(Wd.CompositionRoundedRectangleGeometry obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionRoundedRectangleGeometry result))
|
||||
if (GetExisting<Wc.CompositionRoundedRectangleGeometry>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1282,7 +1293,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionPathGeometry GetCompositionPathGeometry(Wd.CompositionPathGeometry obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionPathGeometry result))
|
||||
if (GetExisting<Wc.CompositionPathGeometry>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1294,7 +1305,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionPath GetCompositionPath(Wd.CompositionPath obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionPath result))
|
||||
if (GetExisting<Wc.CompositionPath>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1305,7 +1316,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
CanvasGeometry GetCanvasGeometry(Wd.Wg.IGeometrySource2D obj)
|
||||
{
|
||||
if (GetExisting(obj, out CanvasGeometry result))
|
||||
if (GetExisting<CanvasGeometry>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1409,7 +1420,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionColorBrush GetCompositionColorBrush(Wd.CompositionColorBrush obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionColorBrush result))
|
||||
if (GetExisting<Wc.CompositionColorBrush>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1439,7 +1450,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionLinearGradientBrush GetCompositionLinearGradientBrush(Wd.CompositionLinearGradientBrush obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionLinearGradientBrush result))
|
||||
if (GetExisting<Wc.CompositionLinearGradientBrush>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1462,7 +1473,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
Wc.CompositionRadialGradientBrush GetCompositionRadialGradientBrush(Wd.CompositionRadialGradientBrush obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wc.CompositionRadialGradientBrush result))
|
||||
if (GetExisting<Wc.CompositionRadialGradientBrush>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1488,7 +1499,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
return result;
|
||||
}
|
||||
|
||||
Wc.ICompositionSurface GetCompositionSurface(Wd.ICompositionSurface obj)
|
||||
Wc.ICompositionSurface? GetCompositionSurface(Wd.ICompositionSurface obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
|
@ -1501,9 +1512,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
}
|
||||
|
||||
Wm.LoadedImageSurface GetLoadedImageSurface(Wmd.LoadedImageSurface obj)
|
||||
Wm.LoadedImageSurface? GetLoadedImageSurface(Wmd.LoadedImageSurface obj)
|
||||
{
|
||||
if (GetExisting(obj, out Wm.LoadedImageSurface result))
|
||||
if (GetExisting<Wm.LoadedImageSurface>(obj, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -1522,7 +1533,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
Cache(obj, result);
|
||||
if (result != null)
|
||||
{
|
||||
Cache(obj, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
|
@ -11,15 +11,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// </summary>
|
||||
public sealed class Issue
|
||||
{
|
||||
internal Issue(string code, string description)
|
||||
{
|
||||
Code = code;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a code that identifies the issue.
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
public string Code { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a string that describes the issue.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a URL that may give more information about the issue.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
#if DEBUG
|
||||
// Uncomment this to slow down async awaits for testing.
|
||||
|
@ -40,12 +40,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
{
|
||||
}
|
||||
|
||||
private protected abstract Task<(string, Stream)> GetJsonStreamAsync();
|
||||
private protected abstract Task<(string?, Stream?)> GetJsonStreamAsync();
|
||||
|
||||
// Asynchronously loads WinCompData from a Lottie file.
|
||||
internal async Task<ContentFactory> LoadAsync(LottieVisualOptions options)
|
||||
{
|
||||
LottieVisualDiagnostics diagnostics = null;
|
||||
LottieVisualDiagnostics? diagnostics = null;
|
||||
var timeMeasurer = TimeMeasurer.Create();
|
||||
|
||||
if (options.HasFlag(LottieVisualOptions.IncludeDiagnostics))
|
||||
|
@ -60,7 +60,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
if (diagnostics != null)
|
||||
{
|
||||
diagnostics.FileName = fileName;
|
||||
diagnostics.FileName = fileName ?? string.Empty;
|
||||
diagnostics.ReadTime = timeMeasurer.GetElapsedAndRestart();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
// Parsing large Lottie files can take significant time. Do it on
|
||||
// another thread.
|
||||
LottieComposition lottieComposition = null;
|
||||
LottieComposition? lottieComposition = null;
|
||||
await CheckedAwaitAsync(Task.Run(() =>
|
||||
{
|
||||
lottieComposition =
|
||||
|
@ -115,7 +115,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
duration: lottieComposition.Duration);
|
||||
|
||||
// Translating large Lotties can take significant time. Do it on another thread.
|
||||
WinCompData.Visual wincompDataRootVisual = null;
|
||||
WinCompData.Visual? wincompDataRootVisual = null;
|
||||
uint requiredUapVersion = 0;
|
||||
var optimizationEnabled = options.HasFlag(LottieVisualOptions.Optimize);
|
||||
|
||||
|
@ -184,13 +184,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
}
|
||||
|
||||
static Issue[] ToIssues(IEnumerable<(string Code, string Description)> issues)
|
||||
=> issues.Select(issue => new Issue { Code = issue.Code, Description = issue.Description }).ToArray();
|
||||
static IReadOnlyList<Issue> ToIssues(IEnumerable<(string Code, string Description)> issues)
|
||||
=> issues.Select(issue => new Issue(code: issue.Code, description: issue.Description)).ToArray();
|
||||
|
||||
static Issue[] ToIssues(IEnumerable<TranslationIssue> issues)
|
||||
=> issues.Select(issue => new Issue { Code = issue.Code, Description = issue.Description }).ToArray();
|
||||
static IReadOnlyList<Issue> ToIssues(IEnumerable<TranslationIssue> issues)
|
||||
=> issues.Select(issue => new Issue(code: issue.Code, description: issue.Description)).ToArray();
|
||||
|
||||
static async Task<(string, Stream)> GetStorageFileStreamAsync(StorageFile storageFile)
|
||||
static async Task<(string?, Stream?)> GetStorageFileStreamAsync(StorageFile storageFile)
|
||||
{
|
||||
var randomAccessStream = await storageFile.OpenReadAsync();
|
||||
return (storageFile.Name, randomAccessStream.AsStreamForRead());
|
||||
|
@ -243,7 +243,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
// the method as async and return the value. This will cause C# to wrap the value in
|
||||
// a Task.
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
private protected override async Task<(string, Stream)> GetJsonStreamAsync()
|
||||
private protected override async Task<(string?, Stream?)> GetJsonStreamAsync()
|
||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
{
|
||||
return (string.Empty, _inputStream.AsStreamForRead());
|
||||
|
@ -261,7 +261,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
_storageFile = storageFile;
|
||||
}
|
||||
|
||||
private protected override Task<(string, Stream)> GetJsonStreamAsync() =>
|
||||
private protected override Task<(string?, Stream?)> GetJsonStreamAsync() =>
|
||||
GetStorageFileStreamAsync(_storageFile);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
_uri = uri;
|
||||
}
|
||||
|
||||
private protected override async Task<(string, Stream)> GetJsonStreamAsync()
|
||||
private protected override async Task<(string?, Stream?)> GetJsonStreamAsync()
|
||||
{
|
||||
var absoluteUri = Uris.GetAbsoluteUri(_uri);
|
||||
if (absoluteUri != null)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -35,11 +35,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
public TimeSpan InstantiationTime { get; internal set; }
|
||||
|
||||
public IEnumerable<Issue> JsonParsingIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
public IReadOnlyList<Issue> JsonParsingIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
|
||||
public IEnumerable<Issue> LottieValidationIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
public IReadOnlyList<Issue> LottieValidationIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
|
||||
public IEnumerable<Issue> TranslationIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
public IReadOnlyList<Issue> TranslationIssues { get; internal set; } = Array.Empty<Issue>();
|
||||
|
||||
public double LottieWidth => LottieComposition?.Width ?? 0;
|
||||
|
||||
|
@ -52,20 +52,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
public LottieVisualOptions Options { get; internal set; }
|
||||
|
||||
// Holds the parsed LottieComposition.
|
||||
internal LottieComposition LottieComposition { get; set; }
|
||||
internal LottieComposition? LottieComposition { get; set; }
|
||||
|
||||
// Holds the translated Visual. Only used if one of the codegen or XML options was selected.
|
||||
internal WinCompData.Visual RootVisual { get; set; }
|
||||
internal WinCompData.Visual? RootVisual { get; set; }
|
||||
|
||||
// The UAP version required by the translated code. Only used if one of the codegen or
|
||||
// XML options was selected.
|
||||
internal uint RequiredUapVersion { get; set; }
|
||||
|
||||
// CompostionPropertySet that holds the theming properties.
|
||||
internal CompositionPropertySet ThemingPropertySet { get; set; }
|
||||
internal CompositionPropertySet? ThemingPropertySet { get; set; }
|
||||
|
||||
// Describes the property bindings in the ThemingPropertySet.
|
||||
internal IReadOnlyList<PropertyBinding> ThemePropertyBindings { get; set; }
|
||||
internal IReadOnlyList<PropertyBinding>? ThemePropertyBindings { get; set; }
|
||||
|
||||
internal LottieVisualDiagnostics Clone() =>
|
||||
new LottieVisualDiagnostics
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
|
@ -23,10 +23,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// </summary>
|
||||
public sealed class LottieVisualSource : DependencyObject, IDynamicAnimatedVisualSource
|
||||
{
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource, object>> _compositionInvalidatedEventTokenTable;
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>? _compositionInvalidatedEventTokenTable;
|
||||
int _loadVersion;
|
||||
Uri _uriSource;
|
||||
ContentFactory _contentFactory;
|
||||
Uri? _uriSource;
|
||||
ContentFactory? _contentFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the options for the <see cref="LottieVisualSource"/>.
|
||||
|
@ -48,7 +48,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
static DependencyProperty RegisterDp<T>(string propertyName, T defaultValue) =>
|
||||
DependencyProperty.Register(propertyName, typeof(T), typeof(LottieVisualSource), new PropertyMetadata(defaultValue));
|
||||
|
||||
static DependencyProperty RegisterDp<T>(string propertyName, T defaultValue, Action<LottieVisualSource, T, T> callback) =>
|
||||
static DependencyProperty RegisterDp<T>(string propertyName, T? defaultValue, Action<LottieVisualSource, T, T> callback)
|
||||
where T : class
|
||||
=>
|
||||
DependencyProperty.Register(propertyName, typeof(T), typeof(LottieVisualSource),
|
||||
new PropertyMetadata(defaultValue, (d, e) => callback((LottieVisualSource)d, (T)e.OldValue, (T)e.NewValue)));
|
||||
|
||||
|
@ -81,7 +83,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// Called by XAML to convert a string to an <see cref="IAnimatedVisualSource"/>.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="LottieVisualSource"/> for the given url.</returns>
|
||||
public static LottieVisualSource CreateFromString(string uri)
|
||||
public static LottieVisualSource? CreateFromString(string uri)
|
||||
{
|
||||
var uriUri = Uris.StringToUri(uri);
|
||||
if (uriUri is null)
|
||||
|
@ -137,18 +139,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// Implements <see cref="IDynamicAnimatedVisualSource"/>.
|
||||
/// </summary>
|
||||
// TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now.
|
||||
public event TypedEventHandler<IDynamicAnimatedVisualSource, object> AnimatedVisualInvalidated
|
||||
public event TypedEventHandler<IDynamicAnimatedVisualSource?, object?> AnimatedVisualInvalidated
|
||||
{
|
||||
add
|
||||
{
|
||||
return EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource, object>>
|
||||
return EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
|
||||
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
|
||||
.AddEventHandler(value);
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource, object>>
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
|
||||
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
|
||||
.RemoveEventHandler(value);
|
||||
}
|
||||
|
@ -162,16 +164,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// <returns>An <see cref="IAnimatedVisual"/>.</returns>
|
||||
// TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now.
|
||||
//bool IAnimatedVisualSource.TryCreateAnimatedVisual(
|
||||
public IAnimatedVisual TryCreateAnimatedVisual(
|
||||
public IAnimatedVisual? TryCreateAnimatedVisual(
|
||||
Compositor compositor,
|
||||
out object diagnostics)
|
||||
out object? diagnostics)
|
||||
{
|
||||
if (_contentFactory is null)
|
||||
{
|
||||
// No content has been loaded yet.
|
||||
// Return an IAnimatedVisual that produces nothing.
|
||||
diagnostics = null;
|
||||
return new DisposableAnimatedVisual();
|
||||
return new DisposableAnimatedVisual(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -184,7 +186,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
void NotifyListenersThatCompositionChanged()
|
||||
{
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource, object>>
|
||||
EventRegistrationTokenTable<TypedEventHandler<IDynamicAnimatedVisualSource?, object?>>
|
||||
.GetOrCreateEventRegistrationTokenTable(ref _compositionInvalidatedEventTokenTable)
|
||||
.InvocationList?.Invoke(this, null);
|
||||
}
|
||||
|
@ -219,7 +221,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
|
||||
// Starts loading. Completes the returned task when the load completes or is replaced by another load.
|
||||
async Task LoadAsync(Loader loader)
|
||||
async Task LoadAsync(Loader? loader)
|
||||
{
|
||||
var loadVersion = ++_loadVersion;
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
|
@ -15,7 +16,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// Relative URIs are made relative to ms-appx:///.
|
||||
/// </summary>
|
||||
/// <returns>A Uri or null.</returns>
|
||||
public static Uri StringToUri(string uri)
|
||||
[return: NotNullIfNotNull("uri")]
|
||||
public static Uri? StringToUri(string uri)
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(uri, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
|
@ -29,7 +31,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
/// Returns an absolute URI. Relative URIs are made relative to ms-appx:///.
|
||||
/// </summary>
|
||||
/// <returns>A Uri or null.</returns>
|
||||
public static Uri GetAbsoluteUri(Uri uri)
|
||||
[return: NotNullIfNotNull("uri")]
|
||||
public static Uri? GetAbsoluteUri(Uri uri)
|
||||
{
|
||||
if (uri is null)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -137,7 +137,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() =>
|
||||
public override string? ToString() =>
|
||||
IsAnimated
|
||||
? string.Join(" -> ", KeyFrames.Select(kf => kf.Value.ToString()))
|
||||
: InitialValue.ToString();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -38,7 +38,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
/// Returns the <see cref="Asset"/> with the given id, or null if not found.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Asset"/> with the given id, or null if not found.</returns>
|
||||
public Asset GetAssetById(string id)
|
||||
public Asset? GetAssetById(string id)
|
||||
{
|
||||
if (id is null)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -34,7 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public Vector2 ControlPoint3 { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(BezierSegment other) => EqualityComparer.Equals(this, other);
|
||||
public bool Equals(BezierSegment? other) => !(other is null) && EqualityComparer.Equals(this, other);
|
||||
|
||||
internal static IEqualityComparer<BezierSegment> EqualityComparer { get; } = new Comparer();
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
sealed class Comparer : IEqualityComparer<BezierSegment>
|
||||
{
|
||||
public bool Equals(BezierSegment x, BezierSegment y)
|
||||
public bool Equals(BezierSegment? x, BezierSegment? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
sealed class Char
|
||||
{
|
||||
public Char(
|
||||
string characters,
|
||||
string fontFamily,
|
||||
string style,
|
||||
string? characters,
|
||||
string? fontFamily,
|
||||
string? style,
|
||||
double fontSize,
|
||||
double width,
|
||||
IEnumerable<ShapeLayerContent> shapes)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -49,10 +49,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public double B { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => Equals(obj as Color);
|
||||
public override bool Equals(object? obj) => Equals(obj as Color);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Color other) => other is Color && (A == other.A && R == other.R && G == other.G && B == other.B);
|
||||
public bool Equals(Color? other) => other is Color && (A == other.A && R == other.R && G == other.G && B == other.B);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => (A * R * G * B).GetHashCode();
|
||||
|
@ -63,12 +63,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
/// <summary>
|
||||
/// Return a color with the given opacity multiplied into the alpha channel of the given color.
|
||||
/// </summary>
|
||||
public static Color operator *(Color color, Opacity opacity) => color?.MultipliedByOpacity(opacity);
|
||||
public static Color operator *(Color color, Opacity opacity) => color.MultipliedByOpacity(opacity);
|
||||
|
||||
/// <summary>
|
||||
/// Return a color with the given opacity multiplied into the alpha channel of the given color.
|
||||
/// </summary>
|
||||
public static Color operator *(Opacity opacity, Color color) => color?.MultipliedByOpacity(opacity);
|
||||
public static Color operator *(Opacity opacity, Color color) => color.MultipliedByOpacity(opacity);
|
||||
|
||||
Color MultipliedByOpacity(Opacity opacity) => opacity.IsOpaque ? this : new Color(opacity.Value * A, R, G, B);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -35,10 +35,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
static string ToHex(double value) => ((byte)(value * 255)).ToString("X2");
|
||||
|
||||
public bool Equals(ColorGradientStop other)
|
||||
public bool Equals(ColorGradientStop? other)
|
||||
=> other != null && other.Offset == Offset && other.Color.Equals(Color);
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
=> Equals(obj as ColorGradientStop);
|
||||
|
||||
public override int GetHashCode() => Color.GetHashCode() ^ Offset.GetHashCode();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public bool IsLinear => ControlPoint1.X == ControlPoint1.Y && ControlPoint2.X == ControlPoint2.Y;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => obj is CubicBezier other && other == this;
|
||||
public override bool Equals(object? obj) => obj is CubicBezier other && other == this;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(CubicBezier other) =>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -29,10 +29,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public override EasingType Type => EasingType.CubicBezier;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => Equals(obj as CubicBezierEasing);
|
||||
public override bool Equals(object? obj) => Equals(obj as CubicBezierEasing);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(CubicBezierEasing other) =>
|
||||
public bool Equals(CubicBezierEasing? other) =>
|
||||
ReferenceEquals(this, other) ||
|
||||
(other is CubicBezierEasing &&
|
||||
Enumerable.SequenceEqual(Beziers, other.Beziers));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public abstract EasingType Type { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Easing other)
|
||||
public bool Equals(Easing? other)
|
||||
{
|
||||
if (ReferenceEquals(this, other))
|
||||
{
|
||||
|
@ -52,12 +52,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(Easing a, Easing b) => (a is Easing && a.Equals(b)) || (a is null && b is null);
|
||||
public static bool operator ==(Easing? a, Easing? b) => (a is Easing && a.Equals(b)) || (a is null && b is null);
|
||||
|
||||
public static bool operator !=(Easing a, Easing b) => !(a == b);
|
||||
public static bool operator !=(Easing? a, Easing? b) => !(a == b);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override abstract bool Equals(object obj);
|
||||
public override abstract bool Equals(object? obj);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override abstract int GetHashCode();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -76,7 +76,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
public T Current => _owner[_index];
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
object? IEnumerator.Current => Current;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -32,11 +32,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
/// <inheritdoc/>
|
||||
// All HoldEasings are equivalent.
|
||||
public override bool Equals(object obj) => obj is HoldEasing;
|
||||
public override bool Equals(object? obj) => obj is HoldEasing;
|
||||
|
||||
/// <inheritdoc/>
|
||||
// All HoldEasings are equivalent.
|
||||
public bool Equals(HoldEasing other) => other is HoldEasing;
|
||||
public bool Equals(HoldEasing? other) => other is HoldEasing;
|
||||
|
||||
public static bool operator ==(HoldEasing a, HoldEasing b) => (a is HoldEasing && b is HoldEasing) || (a is null && b is null);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public Easing Easing { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(KeyFrame<T> other)
|
||||
public bool Equals(KeyFrame<T>? other)
|
||||
{
|
||||
if (ReferenceEquals(this, other))
|
||||
{
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
public bool AutoOrient { get; set; }
|
||||
|
||||
public IEnumerable<Mask> Masks { get; set; }
|
||||
public IEnumerable<Mask>? Masks { get; set; }
|
||||
|
||||
public MatteType LayerMatteType { get; set; }
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -33,6 +34,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
_layers = layers.OrderByDescending(layer => layer.Index).ToArray();
|
||||
}
|
||||
|
||||
public static LayerCollection Empty { get; } = new LayerCollection(Array.Empty<Layer>());
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Layer"/>s in the <see cref="LayerCollection"/> in
|
||||
/// painting order.
|
||||
|
@ -45,7 +48,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
/// </summary>
|
||||
/// <returns>The corresponding <see cref="Layer"/> or null if <paramref name="id"/> does not match
|
||||
/// a single <see cref="Layer"/> in the collection.</returns>
|
||||
public Layer GetLayerById(int? id)
|
||||
public Layer? GetLayerById(int? id)
|
||||
{
|
||||
if (!id.HasValue)
|
||||
{
|
||||
|
@ -55,7 +58,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
return BinarySearch(id.Value);
|
||||
}
|
||||
|
||||
Layer BinarySearch(int targetIndex)
|
||||
Layer? BinarySearch(int targetIndex)
|
||||
{
|
||||
int min = 0;
|
||||
int max = _layers.Length - 1;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -31,11 +31,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
/// <inheritdoc/>
|
||||
// All LinearEasings are equivalent.
|
||||
public override bool Equals(object obj) => obj is LinearEasing;
|
||||
public override bool Equals(object? obj) => obj is LinearEasing;
|
||||
|
||||
/// <inheritdoc/>
|
||||
// All LinearEasings are equivalent.
|
||||
public bool Equals(LinearEasing other) => other is LinearEasing;
|
||||
public bool Equals(LinearEasing? other) => other is LinearEasing;
|
||||
|
||||
public static bool operator ==(LinearEasing a, LinearEasing b) => (a is LinearEasing && b is LinearEasing) || (a is null && b is null);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
void ValidateNoParentCycles(LayerCollection layers)
|
||||
{
|
||||
// Holds the layers that are known to not be in a cycle.
|
||||
var notInCycles = new HashSet<Layer>();
|
||||
var notInCycles = new HashSet<Layer?>();
|
||||
|
||||
// Holds the layers that have parents and have not yet been proven to
|
||||
// not be in a cycle.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
public bool Equals(Opacity other) => other.Value == Value;
|
||||
|
||||
public override bool Equals(object obj) => obj is Opacity other && Equals(other);
|
||||
public override bool Equals(object? obj) => obj is Opacity other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Value.GetHashCode();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -50,8 +50,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
// numbers of stops.
|
||||
var redundancies = input.Select(kf => FindRedundantColorStops(kf.Value.ToArray())).Aggregate((a, b) =>
|
||||
{
|
||||
Debug.Assert(a != null && b != null, "Invariant");
|
||||
|
||||
for (var i = 0; i < a.Length; i++)
|
||||
{
|
||||
// Set the entry in a iff it's set in both a and b.
|
||||
|
@ -90,10 +88,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
// If a color stop is at the same offset as an opacity stop, put the color stop first.
|
||||
var orderedStops = stops.OrderBy(s => s.Offset).ThenBy(s => s.Kind == GradientStop.GradientStopKind.Color ? 0 : 1).ToArray();
|
||||
|
||||
OpacityGradientStop previousOpacityStop = null;
|
||||
OpacityGradientStop nextOpacityStop = null;
|
||||
ColorGradientStop previousColorStop = null;
|
||||
ColorGradientStop nextColorStop = null;
|
||||
OpacityGradientStop? previousOpacityStop = null;
|
||||
OpacityGradientStop? nextOpacityStop = null;
|
||||
ColorGradientStop? previousColorStop = null;
|
||||
ColorGradientStop? nextColorStop = null;
|
||||
var foundLastColorStop = false;
|
||||
var foundLastOpacityStop = false;
|
||||
|
||||
|
@ -130,7 +128,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
// Find the next opacity stop, if there is one.
|
||||
if (nextOpacityStop is null && !foundLastOpacityStop)
|
||||
{
|
||||
nextOpacityStop = (OpacityGradientStop)FindNextStopOfKind(
|
||||
nextOpacityStop = (OpacityGradientStop?)FindNextStopOfKind(
|
||||
orderedStops,
|
||||
i + 1,
|
||||
GradientStop.GradientStopKind.Opacity);
|
||||
|
@ -180,7 +178,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
// Find the next color stop, if there is one.
|
||||
if (nextColorStop is null && !foundLastColorStop)
|
||||
{
|
||||
nextColorStop = (ColorGradientStop)FindNextStopOfKind(
|
||||
nextColorStop = (ColorGradientStop?)FindNextStopOfKind(
|
||||
orderedStops,
|
||||
i + 1,
|
||||
GradientStop.GradientStopKind.Color);
|
||||
|
@ -215,7 +213,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
|
||||
// Searches forward in the GradientStops array from startIndex and returns the first stop
|
||||
// of the given kind, or null if none found.
|
||||
static GradientStop FindNextStopOfKind(GradientStop[] stops, int startIndex, GradientStop.GradientStopKind kind)
|
||||
static GradientStop? FindNextStopOfKind(GradientStop[] stops, int startIndex, GradientStop.GradientStopKind kind)
|
||||
{
|
||||
for (var i = startIndex; i < stops.Length; i++)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
// Uncomment these for debugging
|
||||
//#define DisableKeyFrameTrimming
|
||||
|
@ -149,7 +149,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
static Animatable<T> GetOptimized<T>(Animatable<T> value, Dictionary<Animatable<T>, Animatable<T>> cache)
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
if (!cache.TryGetValue(value, out Animatable<T> result))
|
||||
if (!cache.TryGetValue(value, out Animatable<T>? result))
|
||||
{
|
||||
// Nothing in the cache yet.
|
||||
if (!value.IsAnimated)
|
||||
|
@ -200,7 +200,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
return keyFrames;
|
||||
}
|
||||
|
||||
KeyFrame<T>[] optimizedFrames = null;
|
||||
KeyFrame<T>[]? optimizedFrames = null;
|
||||
var optimizedCount = 0;
|
||||
|
||||
// There's at least 2 key frames.
|
||||
|
@ -430,7 +430,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
IEqualityComparer<Animatable<T>>
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
public bool Equals(KeyFrame<T> x, KeyFrame<T> y)
|
||||
public bool Equals(KeyFrame<T>? x, KeyFrame<T>? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
|
@ -445,7 +445,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
return x.Equals(y);
|
||||
}
|
||||
|
||||
public bool Equals(IEnumerable<KeyFrame<T>> x, IEnumerable<KeyFrame<T>> y)
|
||||
public bool Equals(IEnumerable<KeyFrame<T>>? x, IEnumerable<KeyFrame<T>>? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
|
@ -460,9 +460,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
return x.SequenceEqual(y);
|
||||
}
|
||||
|
||||
public bool Equals(Easing x, Easing y) => Equates(x, y);
|
||||
public bool Equals(Easing? x, Easing? y) => Equates(x, y);
|
||||
|
||||
public bool Equals(Animatable<T> x, Animatable<T> y)
|
||||
public bool Equals(Animatable<T>? x, Animatable<T>? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
|
@ -486,8 +486,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Optimization
|
|||
public int GetHashCode(Animatable<T> obj) => obj.GetHashCode();
|
||||
|
||||
// Compares 2 IEquatable<V> for equality.
|
||||
static bool Equates<TV>(TV x, TV y)
|
||||
where TV : class, IEquatable<TV> => x is null ? y is null : x.Equals(y);
|
||||
static bool Equates<TV>(TV? x, TV? y)
|
||||
where TV : class, IEquatable<TV> =>
|
||||
x is null
|
||||
? y is null
|
||||
: !(y is null) && x.Equals(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -39,10 +39,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
/// </summary>
|
||||
public static PathGeometry Empty { get; } = new PathGeometry(Sequence<BezierSegment>.Empty, false);
|
||||
|
||||
public bool Equals(PathGeometry other) =>
|
||||
public bool Equals(PathGeometry? other) =>
|
||||
other != null && other.IsClosed == IsClosed && other.BezierSegments.Equals(BezierSegments);
|
||||
|
||||
public override bool Equals(object obj) => Equals(obj as PathGeometry);
|
||||
public override bool Equals(object? obj) => Equals(obj as PathGeometry);
|
||||
|
||||
public override int GetHashCode() => BezierSegments.GetHashCode();
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
Animatable<double> points,
|
||||
IAnimatableVector3 position,
|
||||
Animatable<double> rotation,
|
||||
Animatable<double> innerRadius,
|
||||
Animatable<double>? innerRadius,
|
||||
Animatable<double> outerRadius,
|
||||
Animatable<double> innerRoundness,
|
||||
Animatable<double>? innerRoundness,
|
||||
Animatable<double> outerRoundness)
|
||||
: base(in args, drawingDirection)
|
||||
{
|
||||
|
@ -40,11 +40,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
internal Animatable<double> Rotation { get; }
|
||||
|
||||
internal Animatable<double> InnerRadius { get; }
|
||||
internal Animatable<double>? InnerRadius { get; }
|
||||
|
||||
internal Animatable<double> OuterRadius { get; }
|
||||
|
||||
internal Animatable<double> InnerRoundness { get; }
|
||||
internal Animatable<double>? InnerRoundness { get; }
|
||||
|
||||
internal Animatable<double> OuterRoundness { get; }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
public bool Equals(Rotation other) => other.Degrees == Degrees;
|
||||
|
||||
public override bool Equals(object obj) => obj is Rotation other && Equals(other);
|
||||
public override bool Equals(object? obj) => obj is Rotation other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Degrees.GetHashCode();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -69,12 +69,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public T this[int index] => ((IReadOnlyList<T>)_items)[index];
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Sequence<T> other) =>
|
||||
public bool Equals(Sequence<T>? other) =>
|
||||
other is Sequence<T> &&
|
||||
Enumerable.SequenceEqual(_items, other._items);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => Equals(obj as Sequence<T>);
|
||||
public override bool Equals(object? obj) => Equals(obj as Sequence<T>);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
|
@ -87,7 +87,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
// the first few items.
|
||||
for (var i = 0; i < 3 && i < _items.Length; i++)
|
||||
{
|
||||
_hashcode ^= _items[i].GetHashCode();
|
||||
_hashcode ^= _items[i]?.GetHashCode() ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -17,7 +17,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
#endif
|
||||
sealed class LottieCompositionYamlSerializer : YamlFactory
|
||||
{
|
||||
public static void WriteYaml(LottieComposition root, TextWriter writer, string comment = null)
|
||||
public static void WriteYaml(LottieComposition root, TextWriter writer, string? comment = null)
|
||||
{
|
||||
var serializer = new LottieCompositionYamlSerializer();
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -17,11 +15,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Tools
|
|||
#endif
|
||||
sealed class Stats
|
||||
{
|
||||
// Creates a string that describes the Lottie.
|
||||
// Initializes the Stats from a given LottieComposition.
|
||||
public Stats(LottieComposition lottieComposition)
|
||||
{
|
||||
if (lottieComposition is null) { return; }
|
||||
|
||||
Name = lottieComposition.Name;
|
||||
Version = lottieComposition.Version;
|
||||
Width = lottieComposition.Width;
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
||||
|
@ -31,7 +30,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
|
||||
public bool Equals(Trim other) => other.Value == Value;
|
||||
|
||||
public override bool Equals(object obj) => obj is Trim other && Equals(other);
|
||||
public override bool Equals(object? obj) => obj is Trim other && Equals(other);
|
||||
|
||||
public static bool operator ==(Trim a, Trim b) => a.Equals(b);
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
||||
|
@ -43,7 +41,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public static bool operator !=(Vector2 left, Vector2 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => obj is Vector2 other && Equals(other);
|
||||
public override bool Equals(object? obj) => obj is Vector2 other && Equals(other);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Vector2 other) => X == other.X && Y == other.Y;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
||||
|
@ -47,7 +45,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
|
|||
public static bool operator !=(Vector3 left, Vector3 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => obj is Vector3 other && Equals(other);
|
||||
public override bool Equals(object? obj) => obj is Vector3 other && Equals(other);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Vector3 other) => X == other.X && Y == other.Y && Z == other.Z;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieMetadata
|
||||
|
@ -70,7 +68,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieMetadata
|
|||
|
||||
public static bool operator !=(Duration a, Duration b) => !(a == b);
|
||||
|
||||
public override bool Equals(object obj) => obj is Duration other && this == other;
|
||||
public override bool Equals(object? obj) => obj is Duration other && this == other;
|
||||
|
||||
public override int GetHashCode() => Frames.GetHashCode();
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
|
@ -459,7 +458,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
obj.IgnorePropertyIntentionally("a");
|
||||
|
||||
keyFrames = Array.Empty<KeyFrame<T>>();
|
||||
initialValue = default(T);
|
||||
initialValue = default(T)!;
|
||||
|
||||
foreach (var property in obj)
|
||||
{
|
||||
|
@ -471,7 +470,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
if (k.Kind == JsonValueKind.Array)
|
||||
{
|
||||
var kArray = k.AsArray();
|
||||
if (HasKeyframes(kArray))
|
||||
if (kArray != null && HasKeyframes(kArray))
|
||||
{
|
||||
keyFrames = ReadKeyFrames(kArray.Value).ToArray();
|
||||
initialValue = keyFrames.First().Value;
|
||||
|
@ -591,7 +590,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
if (!lottieKeyFrameObj.TryGetProperty("s", out var finalStartValue))
|
||||
{
|
||||
// Old format.
|
||||
yield return new KeyFrame<T>(startFrame, endValue, spatialBezier, easing);
|
||||
if (endValue != null)
|
||||
{
|
||||
yield return new KeyFrame<T>(startFrame, endValue, spatialBezier, easing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
@ -14,17 +13,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
#pragma warning disable SA1601 // Partial elements should be documented
|
||||
sealed partial class LottieCompositionReader
|
||||
{
|
||||
Asset ParseAsset(ref Reader reader)
|
||||
Asset? ParseAsset(ref Reader reader)
|
||||
{
|
||||
reader.ExpectToken(JsonTokenType.StartObject);
|
||||
|
||||
int e = 0;
|
||||
string id = null;
|
||||
string? id = null;
|
||||
double width = 0.0;
|
||||
double height = 0.0;
|
||||
string imagePath = null;
|
||||
string fileName = null;
|
||||
Layer[] layers = null;
|
||||
string? imagePath = null;
|
||||
string? fileName = null;
|
||||
Layer[]? layers = null;
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
|
@ -17,12 +16,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
{
|
||||
reader.ExpectToken(JsonTokenType.StartObject);
|
||||
|
||||
string ch = null;
|
||||
string fFamily = null;
|
||||
string? ch = null;
|
||||
string? fFamily = null;
|
||||
double? size = null;
|
||||
string style = null;
|
||||
string? style = null;
|
||||
double? width = null;
|
||||
ShapeLayerContent[] shapes = null;
|
||||
ShapeLayerContent[] shapes = Array.Empty<ShapeLayerContent>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -29,27 +27,31 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
{
|
||||
IList<Font> list = EmptyList<Font>.Singleton;
|
||||
|
||||
foreach (var item in fontsObject.ArrayPropertyOrNull("list"))
|
||||
var listArray = fontsObject.ArrayPropertyOrNull("list");
|
||||
if (listArray.HasValue)
|
||||
{
|
||||
var element = item.AsObject();
|
||||
if (!element.HasValue)
|
||||
foreach (var item in listArray)
|
||||
{
|
||||
continue;
|
||||
var element = item.AsObject();
|
||||
if (!element.HasValue)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var obj = element.Value;
|
||||
var fName = obj.StringPropertyOrNull("fName") ?? string.Empty;
|
||||
var fFamily = obj.StringPropertyOrNull("fFamily") ?? string.Empty;
|
||||
var fStyle = obj.StringPropertyOrNull("fStyle") ?? string.Empty;
|
||||
var ascent = obj.DoublePropertyOrNull("ascent") ?? 0;
|
||||
obj.AssertAllPropertiesRead();
|
||||
|
||||
if (list == EmptyList<Font>.Singleton)
|
||||
{
|
||||
list = new List<Font>();
|
||||
}
|
||||
|
||||
list.Add(new Font(fName, fFamily, fStyle, ascent));
|
||||
}
|
||||
|
||||
var obj = element.Value;
|
||||
var fName = obj.StringPropertyOrNull("fName") ?? string.Empty;
|
||||
var fFamily = obj.StringPropertyOrNull("fFamily") ?? string.Empty;
|
||||
var fStyle = obj.StringPropertyOrNull("fStyle") ?? string.Empty;
|
||||
var ascent = obj.DoublePropertyOrNull("ascent") ?? 0;
|
||||
obj.AssertAllPropertiesRead();
|
||||
|
||||
if (list == EmptyList<Font>.Singleton)
|
||||
{
|
||||
list = new List<Font>();
|
||||
}
|
||||
|
||||
list.Add(new Font(fName, fFamily, fStyle, ascent));
|
||||
}
|
||||
|
||||
fontsObject.AssertAllPropertiesRead();
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization.Exceptions;
|
||||
|
@ -15,7 +13,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
sealed partial class LottieCompositionReader
|
||||
{
|
||||
// May return null if there was a problem reading the layer.
|
||||
Layer ParseLayer(ref Reader reader)
|
||||
Layer? ParseLayer(ref Reader reader)
|
||||
{
|
||||
using var subDocument = reader.ParseElement();
|
||||
|
||||
|
@ -27,7 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
}
|
||||
|
||||
// May return null if there was a problem reading the layer.
|
||||
Layer ReadLayer(in LottieJsonObjectElement obj)
|
||||
Layer? ReadLayer(in LottieJsonObjectElement obj)
|
||||
{
|
||||
// Not clear whether we need to read these properties.
|
||||
obj.IgnorePropertyThatIsNotYetSupported("bounds", "sy", "td");
|
||||
|
@ -150,8 +148,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
var refId = obj.StringPropertyOrNull("refId") ?? string.Empty;
|
||||
|
||||
// Text data.
|
||||
ReadTextData(obj.ObjectPropertyOrNull("t").Value);
|
||||
return new TextLayer(in layerArgs, refId);
|
||||
var t = obj.ObjectPropertyOrNull("t");
|
||||
if (t is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadTextData(t.Value);
|
||||
return new TextLayer(in layerArgs, refId);
|
||||
}
|
||||
}
|
||||
|
||||
default: throw Unreachable;
|
||||
|
@ -187,10 +193,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
shapes.Capacity = shapesJsonCount;
|
||||
for (var i = 0; i < shapesJsonCount; i++)
|
||||
{
|
||||
var item = ReadShapeContent(shapesJson.Value[i].AsObject().Value);
|
||||
if (item != null)
|
||||
var shapeObject = shapesJson.Value[i].AsObject();
|
||||
if (shapeObject != null)
|
||||
{
|
||||
shapes.Add(item);
|
||||
var item = ReadShapeContent(shapeObject.Value);
|
||||
if (item != null)
|
||||
{
|
||||
shapes.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +235,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
{
|
||||
foreach (var elem in array)
|
||||
{
|
||||
var obj = elem.AsObject().Value;
|
||||
var objObject = elem.AsObject();
|
||||
if (objObject is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var obj = objObject.Value;
|
||||
|
||||
// Ignoring property 'x' because it is not in the official spec.
|
||||
// The x property refers to the mask expansion. In AE you can
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
// Uncomment this to give each element a unique name. This is useful
|
||||
// for debugging how an element gets translated.
|
||||
//#define UniqueifyNames
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -70,7 +71,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
/// Parses a Lottie file to create a <see cref="LottieComposition"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="LottieComposition"/> read from the json stream.</returns>
|
||||
public static LottieComposition ReadLottieCompositionFromJsonStream(
|
||||
public static LottieComposition? ReadLottieCompositionFromJsonStream(
|
||||
Stream stream,
|
||||
Options options,
|
||||
out IReadOnlyList<(string Code, string Description)> issues)
|
||||
|
@ -86,7 +87,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
_animatableColorParser = new AnimatableColorParser(!options.HasFlag(Options.DoNotIgnoreAlpha));
|
||||
}
|
||||
|
||||
static LottieComposition ReadLottieCompositionFromJson(
|
||||
static LottieComposition? ReadLottieCompositionFromJson(
|
||||
in ReadOnlySpan<byte> utf8JsonText,
|
||||
Options options,
|
||||
out IReadOnlyList<(string Code, string Description)> issues)
|
||||
|
@ -94,7 +95,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
var reader = new LottieCompositionReader(options);
|
||||
var jsonReader = new Reader(reader, utf8JsonText);
|
||||
|
||||
LottieComposition result = null;
|
||||
LottieComposition? result = null;
|
||||
try
|
||||
{
|
||||
result = reader.ParseLottieComposition(ref jsonReader);
|
||||
|
@ -110,20 +111,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
LottieComposition ParseLottieComposition(ref Reader reader)
|
||||
{
|
||||
string version = null;
|
||||
string? version = null;
|
||||
double? framesPerSecond = null;
|
||||
double? inPoint = null;
|
||||
double? outPoint = null;
|
||||
double? width = null;
|
||||
double? height = null;
|
||||
string name = null;
|
||||
string? name = null;
|
||||
bool? is3d = null;
|
||||
var assets = Array.Empty<Asset>();
|
||||
var chars = Array.Empty<Char>();
|
||||
var fonts = Array.Empty<Font>();
|
||||
var layers = Array.Empty<Layer>();
|
||||
var markers = Array.Empty<Marker>();
|
||||
Dictionary<string, GenericDataObject> extraData = null;
|
||||
Dictionary<string, GenericDataObject?>? extraData = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -204,11 +205,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
if (extraData is null)
|
||||
{
|
||||
extraData = new Dictionary<string, GenericDataObject>();
|
||||
extraData = new Dictionary<string, GenericDataObject?>();
|
||||
}
|
||||
|
||||
using var subDocument = reader.ParseElement();
|
||||
extraData.Add(currentProperty, subDocument.RootElement.ToGenericDataObject());
|
||||
var subDocumentAsGenericDataObject = subDocument.RootElement.ToGenericDataObject();
|
||||
if (!(subDocumentAsGenericDataObject is null))
|
||||
{
|
||||
extraData.Add(currentProperty, subDocumentAsGenericDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -358,7 +363,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
if (pointsData is null)
|
||||
{
|
||||
return null;
|
||||
return new PathGeometry(new Sequence<BezierSegment>(Array.Empty<BezierSegment>(), takeOwnership: true), isClosed: false);
|
||||
}
|
||||
|
||||
var points = pointsData.Value;
|
||||
|
@ -449,7 +454,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
delegate T Parser<T>(ref Reader reader);
|
||||
|
||||
T[] ParseArray<T>(ref Reader reader, Parser<T> parser)
|
||||
T[] ParseArray<T>(ref Reader reader, Parser<T?> parser)
|
||||
where T : class
|
||||
{
|
||||
reader.ExpectToken(JsonTokenType.StartArray);
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
@ -70,7 +68,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
case JsonValueKind.Array:
|
||||
{
|
||||
var array = AsArray().Value;
|
||||
var array = AsArray()!.Value;
|
||||
switch (array.Count)
|
||||
{
|
||||
case 0:
|
||||
|
@ -104,7 +102,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
return null;
|
||||
}
|
||||
|
||||
internal string AsString()
|
||||
internal string? AsString()
|
||||
{
|
||||
switch (_wrapped.ValueKind)
|
||||
{
|
||||
|
@ -115,14 +113,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
internal GenericDataObject ToGenericDataObject()
|
||||
internal GenericDataObject? ToGenericDataObject()
|
||||
{
|
||||
switch (Kind)
|
||||
{
|
||||
case JsonValueKind.Object:
|
||||
|
||||
var obj = AsObject().Value;
|
||||
var dict = new Dictionary<string, GenericDataObject>();
|
||||
var obj = AsObject()!.Value;
|
||||
var dict = new Dictionary<string, GenericDataObject?>();
|
||||
foreach (var property in obj)
|
||||
{
|
||||
dict.Add(property.Key, property.Value.ToGenericDataObject());
|
||||
|
@ -130,11 +128,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
return GenericDataMap.Create(dict);
|
||||
case JsonValueKind.Array:
|
||||
return GenericDataList.Create(AsArray().Value.Select<GenericDataObject>(elem => elem.ToGenericDataObject()));
|
||||
return GenericDataList.Create(AsArray()!.Value.Select<GenericDataObject?>(elem => elem.ToGenericDataObject()));
|
||||
case JsonValueKind.String:
|
||||
return GenericDataString.Create(AsString());
|
||||
return GenericDataString.Create(AsString()!);
|
||||
case JsonValueKind.Number:
|
||||
return GenericDataNumber.Create(AsDouble().Value);
|
||||
return GenericDataNumber.Create(AsDouble()!.Value);
|
||||
case JsonValueKind.True:
|
||||
return GenericDataBool.True;
|
||||
case JsonValueKind.False:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -64,7 +62,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
result[i] = new Vector2(xs.Value[i].AsDouble() ?? 0.0, ys.Value[i].AsDouble() ?? 0.0);
|
||||
result[i] = new Vector2(xs!.Value[i].AsDouble() ?? 0.0, ys!.Value[i].AsDouble() ?? 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +106,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
internal LottieJsonObjectElement? ObjectPropertyOrNull(string propertyName)
|
||||
=> TryGetProperty(propertyName, out var value) ? value.AsObject() : null;
|
||||
|
||||
internal string StringPropertyOrNull(string propertyName)
|
||||
internal string? StringPropertyOrNull(string propertyName)
|
||||
=> TryGetProperty(propertyName, out var value) ? value.AsString() : null;
|
||||
|
||||
// Indicates that the given property will not be read because we don't yet support it.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
||||
|
@ -16,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
{
|
||||
reader.ExpectToken(JsonTokenType.StartObject);
|
||||
|
||||
string name = null;
|
||||
string name = string.Empty;
|
||||
double durationInFrames = 0;
|
||||
double frame = 0;
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using static Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization.Exceptions;
|
||||
|
||||
|
@ -13,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
#pragma warning disable SA1601 // Partial elements should be documented
|
||||
sealed partial class LottieCompositionReader
|
||||
{
|
||||
ShapeLayerContent ReadShapeContent(in LottieJsonObjectElement obj)
|
||||
ShapeLayerContent? ReadShapeContent(in LottieJsonObjectElement obj)
|
||||
{
|
||||
var args = default(ShapeLayerContent.ShapeLayerContentArgs);
|
||||
ReadShapeLayerContentArgs(obj, ref args);
|
||||
|
@ -100,7 +99,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
var miterLimit = obj.DoublePropertyOrNull("ml") ?? 4; // Default miter limit in After Effects is 4
|
||||
|
||||
// Get dash pattern to be set as StrokeDashArray
|
||||
Animatable<double> offset = null;
|
||||
Animatable<double>? offset = null;
|
||||
var dashPattern = new List<double>();
|
||||
var dashes = obj.ArrayPropertyOrNull("d");
|
||||
if (dashes != null)
|
||||
|
@ -335,8 +334,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
var polystarType = SyToPolystarType(obj.DoublePropertyOrNull("sy")) ?? Polystar.PolyStarType.Polygon;
|
||||
|
||||
Animatable<double> innerRadius;
|
||||
Animatable<double> innerRoundness;
|
||||
Animatable<double>? innerRadius;
|
||||
Animatable<double>? innerRoundness;
|
||||
|
||||
switch (polystarType)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -50,14 +50,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
// ... but pause it immediately so that it doesn't react to time. Instead, bind
|
||||
// its progress to the progress of the composition.
|
||||
var controller = compObject.TryGetAnimationController(target);
|
||||
controller.Pause();
|
||||
controller!.Pause();
|
||||
|
||||
// Bind it to the root visual's Progress property, scaling and offsetting if necessary.
|
||||
var key = new ScaleAndOffset(scale, offset);
|
||||
if (!state.ProgressBindingAnimations.TryGetValue(key, out var bindingAnimation))
|
||||
{
|
||||
bindingAnimation = context.ObjectFactory.CreateExpressionAnimation(ExpressionFactory.ScaledAndOffsetRootProgress(scale, offset));
|
||||
bindingAnimation.SetReferenceParameter(ExpressionFactory.RootName, context.RootVisual);
|
||||
bindingAnimation.SetReferenceParameter(ExpressionFactory.RootName, context.RootVisual!);
|
||||
if (context.AddDescriptions)
|
||||
{
|
||||
// Give the animation a nice readable name in codegen.
|
||||
|
@ -84,8 +84,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<double> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
if (targetObject.Properties == targetObject)
|
||||
{
|
||||
|
@ -108,8 +108,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Trim> value,
|
||||
CompositionGeometry targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
targetObject.Properties.InsertScalar(targetPropertyName, ConvertTo.Float(value.InitialValue));
|
||||
|
||||
|
@ -127,8 +127,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Rotation> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledRotation(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -139,8 +139,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<double> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledScalar(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -151,8 +151,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<double> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledScalar(context, value, 0.01, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -163,8 +163,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Opacity> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledOpacity(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -175,8 +175,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Trim> value,
|
||||
CompositionGeometry targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledTrimStartOrTrimEnd(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,8 +188,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription,
|
||||
string shortDescription)
|
||||
string? longDescription,
|
||||
string? shortDescription)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -213,8 +213,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription,
|
||||
string shortDescription)
|
||||
string? longDescription,
|
||||
string? shortDescription)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -238,8 +238,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -263,8 +263,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionGeometry targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription,
|
||||
string shortDescription)
|
||||
string? longDescription,
|
||||
string? shortDescription)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -296,8 +296,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Color> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -318,8 +318,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
Action<ColorKeyFrameAnimation> beforeStartCallback,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -343,8 +343,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Color> value,
|
||||
CompositionPropertySet targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -368,8 +368,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
ShapeFill.PathFillType fillType,
|
||||
CompositionPathGeometry targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
|
||||
|
@ -405,8 +405,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
ShapeFill.PathFillType fillType,
|
||||
CompositionPathGeometry targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
|
||||
|
@ -441,8 +441,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Vector3> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledVector2(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -454,8 +454,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -478,8 +478,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Vector3> value,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
=> ScaledVector3(context, value, 1, targetObject, targetPropertyName, longDescription, shortDescription);
|
||||
|
||||
/// <summary>
|
||||
|
@ -491,8 +491,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
double scale,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription = null,
|
||||
string shortDescription = null)
|
||||
string? longDescription = null,
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(value.IsAnimated, "Precondition");
|
||||
GenericCreateCompositionKeyFrameAnimation(
|
||||
|
@ -512,12 +512,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<T> value,
|
||||
Func<TCA> compositionAnimationFactory,
|
||||
Action<TCA, float, T, CompositionEasingFunction> keyFrameInserter,
|
||||
Action<TCA, float, CubicBezierFunction2, CompositionEasingFunction> expressionKeyFrameInserter,
|
||||
Action<TCA, float, CubicBezierFunction2, CompositionEasingFunction>? expressionKeyFrameInserter,
|
||||
CompositionObject targetObject,
|
||||
string targetPropertyName,
|
||||
string longDescription,
|
||||
string shortDescription,
|
||||
Action<TCA> beforeStartCallback = null)
|
||||
string? longDescription,
|
||||
string? shortDescription,
|
||||
Action<TCA>? beforeStartCallback = null)
|
||||
where TCA : KeyFrameAnimation_
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
|
@ -705,7 +705,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
// Add a reference to the root Visual if needed (i.e. if an expression keyframe was added).
|
||||
if (rootReferenceRequired)
|
||||
{
|
||||
compositionAnimation.SetReferenceParameter(ExpressionFactory.RootName, translationContext.RootVisual);
|
||||
compositionAnimation.SetReferenceParameter(ExpressionFactory.RootName, translationContext.RootVisual!);
|
||||
}
|
||||
|
||||
beforeStartCallback?.Invoke(compositionAnimation);
|
||||
|
@ -761,6 +761,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
// animation.
|
||||
if (progress <= 1)
|
||||
{
|
||||
if (expressionKeyFrameInserter is null)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
expressionKeyFrameInserter(animation, progress, expression, easing);
|
||||
}
|
||||
}
|
||||
|
@ -779,7 +784,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
internal double Offset { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is ScaleAndOffset other &&
|
||||
other.Scale == Scale &&
|
||||
other.Offset == Offset;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -128,7 +128,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
public static void TranslateAndApplyStroke(
|
||||
LayerContext context,
|
||||
ShapeStroke shapeStroke,
|
||||
ShapeStroke? shapeStroke,
|
||||
CompositionSpriteShape sprite,
|
||||
CompositeOpacity contextOpacity)
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
static void ApplyCommonStrokeProperties(
|
||||
LayerContext context,
|
||||
ShapeStroke shapeStroke,
|
||||
CompositionBrush brush,
|
||||
CompositionBrush? brush,
|
||||
CompositionSpriteShape sprite)
|
||||
{
|
||||
var strokeThickness = Optimizer.TrimAnimatable(context, shapeStroke.StrokeWidth);
|
||||
|
@ -253,7 +253,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
sprite.StrokeBrush = brush;
|
||||
}
|
||||
|
||||
public static CompositionBrush TranslateShapeFill(LayerContext context, ShapeFill shapeFill, CompositeOpacity opacity)
|
||||
public static CompositionBrush? TranslateShapeFill(LayerContext context, ShapeFill? shapeFill, CompositeOpacity opacity)
|
||||
{
|
||||
if (shapeFill is null)
|
||||
{
|
||||
|
@ -409,7 +409,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return result;
|
||||
}
|
||||
|
||||
static CompositionLinearGradientBrush TranslateLinearGradient(
|
||||
static CompositionLinearGradientBrush? TranslateLinearGradient(
|
||||
LayerContext context,
|
||||
IGradient linearGradient,
|
||||
CompositeOpacity opacity)
|
||||
|
@ -453,7 +453,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return result;
|
||||
}
|
||||
|
||||
static CompositionGradientBrush TranslateRadialGradient(
|
||||
static CompositionGradientBrush? TranslateRadialGradient(
|
||||
LayerContext context,
|
||||
IRadialGradient gradient,
|
||||
CompositeOpacity opacity)
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -16,11 +14,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
sealed class CompositeOpacity
|
||||
{
|
||||
readonly CompositeOpacity _previous;
|
||||
readonly CompositeOpacity? _previous;
|
||||
readonly Opacity _initialValue;
|
||||
readonly IReadOnlyList<KeyFrame<Opacity>> _keyFrames;
|
||||
|
||||
CompositeOpacity(CompositeOpacity previous, Opacity initialValue, IReadOnlyList<KeyFrame<Opacity>> keyFrames)
|
||||
CompositeOpacity(CompositeOpacity? previous, Opacity initialValue, IReadOnlyList<KeyFrame<Opacity>> keyFrames)
|
||||
{
|
||||
Debug.Assert(previous is null || keyFrames.Count > 1, "Precondition");
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Mgce;
|
||||
|
@ -178,7 +177,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return _compositor.CreateRadialGradientBrush();
|
||||
}
|
||||
|
||||
internal CompositionEasingFunction CreateCompositionEasingFunction(Easing easingFunction)
|
||||
[return: NotNullIfNotNull("easingFunction")]
|
||||
internal CompositionEasingFunction? CreateCompositionEasingFunction(Easing? easingFunction)
|
||||
{
|
||||
if (easingFunction is null)
|
||||
{
|
||||
|
|
|
@ -77,8 +77,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
Shapes.TranslateAndApplyShapeContext(
|
||||
context,
|
||||
compositionSpriteShape,
|
||||
reverseDirection: shapeContent.DrawingDirection == DrawingDirection.Reverse,
|
||||
trimOffsetDegrees: 0);
|
||||
reverseDirection: shapeContent.DrawingDirection == DrawingDirection.Reverse);
|
||||
|
||||
return compositionSpriteShape;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions;
|
||||
|
@ -221,10 +219,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
static Scalar CreateProgressExpression(ArraySegment<Segment> segments, Scalar progress)
|
||||
{
|
||||
if (segments.Count == 0 || segments.Array is null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
switch (segments.Count)
|
||||
{
|
||||
case 0:
|
||||
throw new ArgumentException();
|
||||
case 1:
|
||||
return segments.Array[segments.Offset].Value;
|
||||
default:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
|
@ -36,7 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
this IDescribable obj,
|
||||
TranslationContext context,
|
||||
string longDescription,
|
||||
string shortDescription = null)
|
||||
string? shortDescription = null)
|
||||
{
|
||||
Debug.Assert(context.AddDescriptions, "Descriptions should only be set when requested.");
|
||||
Debug.Assert(obj.ShortDescription is null, "Descriptions should never get set more than once.");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
|
@ -16,7 +16,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
static class Images
|
||||
{
|
||||
public static LayerTranslator CreateImageLayerTranslator(ImageLayerContext context)
|
||||
public static LayerTranslator? CreateImageLayerTranslator(ImageLayerContext context)
|
||||
{
|
||||
if (!Transforms.TryCreateContainerVisualTransformChain(context, out var containerVisualRootNode, out var containerVisualContentNode))
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return new LayerTranslator.FromVisual(containerVisualRootNode);
|
||||
}
|
||||
|
||||
static ImageAsset GetImageAsset(ImageLayerContext context) =>
|
||||
(ImageAsset)context.Translation.GetAssetById(context, context.Layer.RefId, Asset.AssetType.Image);
|
||||
static ImageAsset? GetImageAsset(ImageLayerContext context) =>
|
||||
(ImageAsset?)context.Translation.GetAssetById(context, context.Layer.RefId, Asset.AssetType.Image);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
|
||||
|
@ -16,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
abstract class LayerContext
|
||||
{
|
||||
FrameNumberEqualityComparer _frameNumberEqualityComparer;
|
||||
FrameNumberEqualityComparer? _frameNumberEqualityComparer;
|
||||
|
||||
private protected LayerContext(CompositionContext compositionContext, Layer layer)
|
||||
{
|
||||
|
@ -43,7 +41,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// Returns the <see cref="Layer"/> from which the current layer inherits transforms
|
||||
/// or null if there is no transform parent.
|
||||
/// </summary>
|
||||
public Layer TransformParentLayer =>
|
||||
public Layer? TransformParentLayer =>
|
||||
Layer.Parent.HasValue ? CompositionContext.Layers.GetLayerById(Layer.Parent.Value) : null;
|
||||
|
||||
public override string ToString() => $"{GetType().Name} - {Layer.Name}";
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
|
||||
|
@ -25,8 +23,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// Gets the translation of the layer as a <see cref="CompositionShape"/>.
|
||||
/// Only valid to call is <see cref="IsShape"/> is <c>true</c>.
|
||||
/// </summary>
|
||||
/// <returns>The CompositionShape.</returns>
|
||||
internal virtual CompositionShape GetShapeRoot(TranslationContext context)
|
||||
/// <returns>The <see cref="CompositionShape"/> or null if the layer is never visible.</returns>
|
||||
internal virtual CompositionShape? GetShapeRoot(TranslationContext context)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
@ -34,13 +32,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <summary>
|
||||
/// Gets the translation of the layer as a <see cref="Visual"/>.
|
||||
/// </summary>
|
||||
/// <returns>The Visual.</returns>
|
||||
/// <returns>The <see cref="Visual"/> or null if the layer is never visible.</returns>
|
||||
/// <remarks>
|
||||
/// The size (in the context) is needed in case a CompositionShape tree
|
||||
/// needs to be converted to a ShapeVisual. Shape trees need to know their
|
||||
/// maximum size.
|
||||
/// </remarks>
|
||||
internal abstract Visual GetVisualRoot(CompositionContext context);
|
||||
internal abstract Visual? GetVisualRoot(CompositionContext context);
|
||||
|
||||
/// <summary>
|
||||
/// True if the graph can be represented by a root CompositionShape.
|
||||
|
@ -50,22 +48,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
internal virtual bool IsShape => false;
|
||||
|
||||
public string LongDescription { get; set; }
|
||||
public string? LongDescription { get; set; }
|
||||
|
||||
public string ShortDescription { get; set; }
|
||||
public string? ShortDescription { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
private protected void Describe(TranslationContext context, IDescribable obj)
|
||||
{
|
||||
if (context.AddDescriptions && obj.LongDescription is null && obj.ShortDescription is null && !(string.IsNullOrWhiteSpace(LongDescription) || string.IsNullOrWhiteSpace(ShortDescription)))
|
||||
if (context.AddDescriptions &&
|
||||
obj.LongDescription is null &&
|
||||
obj.ShortDescription is null &&
|
||||
!(string.IsNullOrWhiteSpace(LongDescription) || string.IsNullOrWhiteSpace(ShortDescription)))
|
||||
{
|
||||
obj.SetDescription(context, LongDescription, ShortDescription);
|
||||
// IsNullOrWhiteSpace implies LongDescription is not null.
|
||||
obj.SetDescription(context, LongDescription!, ShortDescription);
|
||||
}
|
||||
|
||||
if (context.AddDescriptions && obj.Name is null && !string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
obj.SetName(Name);
|
||||
// !IsNullOrWhitespace(Name) implies Name is not null.
|
||||
obj.SetName(Name!);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -52,7 +50,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
}
|
||||
|
||||
// Combines 1 or more LayerTranslators as CompositionShape subgraphs under a ShapeVisual.
|
||||
static Visual GetVisualForLayerTranslators(CompositionContext context, IReadOnlyList<LayerTranslator> shapes)
|
||||
static Visual? GetVisualForLayerTranslators(CompositionContext context, IReadOnlyList<LayerTranslator> shapes)
|
||||
{
|
||||
Debug.Assert(shapes.All(s => s.IsShape), "Precondition");
|
||||
|
||||
|
@ -71,13 +69,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
// TODO - if the shape graphs share the same opacity and/or visiblity, get them
|
||||
// to translate without opacity/visiblity and we'll pull those
|
||||
// into the Visual.
|
||||
var shapeVisual = context.ObjectFactory.CreateShapeVisualWithChild(compositionShapes[0].shape, context.Size);
|
||||
var shapeVisual = context.ObjectFactory.CreateShapeVisualWithChild(compositionShapes[0].shape!, context.Size);
|
||||
|
||||
shapeVisual.SetDescription(context, () => "Layer aggregator");
|
||||
|
||||
for (var i = 1; i < compositionShapes.Length; i++)
|
||||
{
|
||||
shapeVisual.Shapes.Add(compositionShapes[i].shape);
|
||||
shapeVisual.Shapes.Add(compositionShapes[i].shape!);
|
||||
}
|
||||
|
||||
return shapeVisual;
|
||||
|
@ -133,7 +131,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
/// <returns>The <see cref="LayerTranslator"/> that will translate the
|
||||
/// given Lottie layer to a Shape or a Visual.</returns>
|
||||
static LayerTranslator CreateTranslatorForLayer(CompositionContext context, Layer layer)
|
||||
static LayerTranslator? CreateTranslatorForLayer(CompositionContext context, Layer layer)
|
||||
{
|
||||
if (layer.Is3d)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -144,7 +142,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
{
|
||||
// Save off the visual for the layer to be matted when we encounter it. The very next
|
||||
// layer is the matte layer.
|
||||
Visual mattedVisual = null;
|
||||
Visual? mattedVisual = null;
|
||||
Layer.MatteType matteType = Layer.MatteType.None;
|
||||
|
||||
// NOTE: The items appear in reverse order from how they appear in the original Lottie file.
|
||||
|
@ -154,7 +152,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
var layerIsMattedLayer = false;
|
||||
layerIsMattedLayer = layer.LayerMatteType != Layer.MatteType.None;
|
||||
|
||||
Visual visual = null;
|
||||
Visual? visual = null;
|
||||
|
||||
if (translatedLayer.IsShape)
|
||||
{
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
|
||||
|
@ -31,7 +28,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
public IReadOnlyList<PathGeometry> Data { get; }
|
||||
|
||||
public bool Equals(PathGeometryGroup other) => other != null && Enumerable.SequenceEqual(Data, other.Data);
|
||||
public bool Equals(PathGeometryGroup? other) => other != null && Enumerable.SequenceEqual(Data, other.Data);
|
||||
|
||||
// Takes a group of possibly-animated paths and returns an animatable
|
||||
// of PathGeometryGroups. Returns true if it succeeds without issues.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -123,8 +121,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
Shapes.TranslateAndApplyShapeContext(
|
||||
context,
|
||||
compositionSpriteShape,
|
||||
path.DrawingDirection == DrawingDirection.Reverse,
|
||||
trimOffsetDegrees: 0);
|
||||
path.DrawingDirection == DrawingDirection.Reverse);
|
||||
|
||||
return compositionSpriteShape;
|
||||
}
|
||||
|
@ -166,8 +163,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
Shapes.TranslateAndApplyShapeContext(
|
||||
context,
|
||||
compositionSpriteShape,
|
||||
reverseDirection: directions[0] == DrawingDirection.Reverse,
|
||||
trimOffsetDegrees: 0);
|
||||
reverseDirection: directions[0] == DrawingDirection.Reverse);
|
||||
|
||||
return compositionSpriteShape;
|
||||
}
|
||||
|
@ -397,7 +393,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
}
|
||||
}
|
||||
|
||||
static ShapeFill.PathFillType GetPathFillType(ShapeFill fill) => fill is null ? ShapeFill.PathFillType.EvenOdd : fill.FillType;
|
||||
static ShapeFill.PathFillType GetPathFillType(ShapeFill? fill) => fill is null ? ShapeFill.PathFillType.EvenOdd : fill.FillType;
|
||||
|
||||
static bool IsFuzzyEqual(in Vector2 a, in Vector2 b, in double acceptableError)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
using Sn = System.Numerics;
|
||||
|
||||
|
@ -32,6 +30,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
public CompositionContext ChildrenCompositionContext { get; }
|
||||
|
||||
static LayerCollection GetLayerCollectionByAssetId(PreCompLayerContext context, string assetId)
|
||||
=> ((LayerCollectionAsset)context.Translation.GetAssetById(context, assetId, Asset.AssetType.LayerCollection))?.Layers;
|
||||
=> ((LayerCollectionAsset?)context.Translation.GetAssetById(context, assetId, Asset.AssetType.LayerCollection))?.Layers ??
|
||||
LayerCollection.Empty;
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Linq;
|
||||
|
||||
#if DEBUG
|
||||
|
@ -18,7 +16,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
static class PreComps
|
||||
{
|
||||
public static LayerTranslator CreatePreCompLayerTranslator(PreCompLayerContext context)
|
||||
public static LayerTranslator? CreatePreCompLayerTranslator(PreCompLayerContext context)
|
||||
{
|
||||
// TODO - the animations produced inside a PreComp need to be time-mapped.
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
@ -67,7 +65,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
sealed class ProgressVariable
|
||||
{
|
||||
Range _rangesHead;
|
||||
Range? _rangesHead;
|
||||
|
||||
internal ProgressVariable(string name, double scale, double offset)
|
||||
{
|
||||
|
@ -170,17 +168,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
internal float End { get; }
|
||||
|
||||
internal Easing Easing { get; }
|
||||
internal Easing? Easing { get; }
|
||||
|
||||
internal Range Next { get; set; }
|
||||
internal Range? Next { get; set; }
|
||||
|
||||
bool Equals(Range other)
|
||||
=> (!(other is null)) && (other.Start == Start) && (other.End == End) && other.Easing.Equals(Easing);
|
||||
bool Equals(Range? other)
|
||||
=> (!(other is null)) && (other.Start == Start) && (other.End == End) && other.Easing == Easing;
|
||||
|
||||
public override bool Equals(object obj) => Equals(obj as Range);
|
||||
public override bool Equals(object? obj) => Equals(obj as Range);
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Easing.GetHashCode() ^ Start.GetHashCode() ^ End.GetHashCode();
|
||||
=> (Easing?.GetHashCode() ?? 0) ^ Start.GetHashCode() ^ End.GetHashCode();
|
||||
|
||||
public override string ToString() => $"{Start}-{End}";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,44 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
static class Rectangles
|
||||
{
|
||||
// NOTES ABOUT RECTANGLE DRAWING AND CORNERS:
|
||||
// ==========================================
|
||||
// A rectangle can be thought of as having 8 components -
|
||||
// 4 sides (1,3,5,7) and 4 corners (2,4,6,8):
|
||||
//
|
||||
// 1
|
||||
// 8╭ ─────────── ╮2
|
||||
// ╷ ╷
|
||||
// 7│ │3
|
||||
// ╵ ╵
|
||||
// 6╰ ─────────── ╯4
|
||||
// 5
|
||||
//
|
||||
// Windows.Composition draws in order 1,2,3,4,5,6,7,8.
|
||||
//
|
||||
// Lottie draws in one of two different ways depending on
|
||||
// whether the corners are controlled by RoundCorners or by
|
||||
// Rectangle.CornerRadius.
|
||||
// If RoundCorners the order is 2,3,4,5,6,7,8,1.
|
||||
// If Rectangle.CornerRadius the order is 3,4,5,6,7,8,1,2.
|
||||
//
|
||||
// If the corners have 0 radius, the corners are irrelevant
|
||||
// resulting in:
|
||||
// Windows.Composition: 1,3,5,7.
|
||||
// Lottie: 3,5,7,1.
|
||||
//
|
||||
// The order of drawing matters only if there is a TrimPath, and in
|
||||
// that case:
|
||||
// a) If there are no RoundCorners, a TrimOffset equivalent to 90 degrees
|
||||
// must be added.
|
||||
// b) If there are RoundCorners, swap width and height, rotate the rectangle
|
||||
// by 90 degrees around the center, and transform the trim path so that
|
||||
// it effectively draws in the reverse direction.
|
||||
//
|
||||
// TODO - the RoundCorners case with TrimPath is currently not handled correctly
|
||||
// and will cause the trim to appear to be rotated by 90 degrees.
|
||||
//
|
||||
//
|
||||
// Translates a Lottie rectangle to a CompositionShape.
|
||||
public static CompositionShape TranslateRectangleContent(ShapeContext context, Rectangle rectangle)
|
||||
{
|
||||
|
@ -224,6 +262,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Vector3> position,
|
||||
RectangleOrRoundedRectangleGeometry geometry)
|
||||
{
|
||||
if (compositionRectangle.Geometry is null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
if (position.IsAnimated || size.IsAnimated)
|
||||
{
|
||||
Expressions.Vector2 offsetExpression;
|
||||
|
@ -274,7 +317,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
var height = size.InitialValue.Y;
|
||||
var trimOffsetDegrees = (width / (2 * (width + height))) * 360;
|
||||
|
||||
Shapes.TranslateAndApplyShapeContext(
|
||||
Shapes.TranslateAndApplyShapeContextWithTrimOffset(
|
||||
context,
|
||||
compositionRectangle,
|
||||
rectangle.DrawingDirection == DrawingDirection.Reverse,
|
||||
|
@ -293,6 +336,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
in TrimmedAnimatable<Vector3> position,
|
||||
RectangleOrRoundedRectangleGeometry geometry)
|
||||
{
|
||||
if (compositionRectangle.Geometry is null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
if (position.IsAnimated || width.IsAnimated || height.IsAnimated)
|
||||
{
|
||||
Expressions.Vector2 offsetExpression;
|
||||
|
@ -359,7 +407,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
var initialHeight = height.InitialValue;
|
||||
var trimOffsetDegrees = (initialWidth / (2 * (initialWidth + initialHeight))) * 360;
|
||||
|
||||
Shapes.TranslateAndApplyShapeContext(
|
||||
Shapes.TranslateAndApplyShapeContextWithTrimOffset(
|
||||
context,
|
||||
compositionRectangle,
|
||||
rectangle.DrawingDirection == DrawingDirection.Reverse,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -35,11 +35,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
public TranslationIssues Issues => Translation.Issues;
|
||||
|
||||
internal ShapeStroke Stroke { get; private set; }
|
||||
internal ShapeStroke? Stroke { get; private set; }
|
||||
|
||||
internal ShapeFill Fill { get; private set; }
|
||||
internal ShapeFill? Fill { get; private set; }
|
||||
|
||||
internal TrimPath TrimPath { get; private set; }
|
||||
internal TrimPath? TrimPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Never null. If there is no <see cref="RoundCorners"/> set, a default
|
||||
|
@ -47,7 +47,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
internal RoundCorners RoundCorners { get; private set; } = s_defaultRoundCorners;
|
||||
|
||||
internal Transform Transform { get; private set; }
|
||||
internal Transform? Transform { get; private set; }
|
||||
|
||||
// Opacity is not part of the Lottie context for shapes. But because WinComp
|
||||
// doesn't support opacity on shapes, the opacity is inherited from
|
||||
|
@ -117,7 +117,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
Transform = Transform,
|
||||
};
|
||||
|
||||
ShapeFill ComposeFills(ShapeFill a, ShapeFill b)
|
||||
ShapeFill? ComposeFills(ShapeFill? a, ShapeFill? b)
|
||||
{
|
||||
if (a is null)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return b;
|
||||
}
|
||||
|
||||
ShapeStroke ComposeStrokes(ShapeStroke a, ShapeStroke b)
|
||||
ShapeStroke? ComposeStrokes(ShapeStroke? a, ShapeStroke? b)
|
||||
{
|
||||
if (a is null)
|
||||
{
|
||||
|
@ -197,8 +197,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
LinearGradientStroke ComposeLinearGradientStrokes(LinearGradientStroke a, LinearGradientStroke b)
|
||||
{
|
||||
Debug.Assert(a != null && b != null, "Precondition");
|
||||
|
||||
if (!a.StrokeWidth.IsAnimated && !b.StrokeWidth.IsAnimated &&
|
||||
a.Opacity.IsAlways(LottieData.Opacity.Opaque) && b.Opacity.IsAlways(LottieData.Opacity.Opaque))
|
||||
{
|
||||
|
@ -215,8 +213,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
RadialGradientStroke ComposeRadialGradientStrokes(RadialGradientStroke a, RadialGradientStroke b)
|
||||
{
|
||||
Debug.Assert(a != null && b != null, "Precondition");
|
||||
|
||||
if (!a.StrokeWidth.IsAnimated && !b.StrokeWidth.IsAnimated &&
|
||||
a.Opacity.IsAlways(LottieData.Opacity.Opaque) && b.Opacity.IsAlways(LottieData.Opacity.Opaque))
|
||||
{
|
||||
|
@ -233,8 +229,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
SolidColorStroke ComposeSolidColorStrokes(SolidColorStroke a, SolidColorStroke b)
|
||||
{
|
||||
Debug.Assert(a != null && b != null, "Precondition");
|
||||
|
||||
if (!a.StrokeWidth.IsAnimated && !b.StrokeWidth.IsAnimated &&
|
||||
!a.DashPattern.Any() && !b.DashPattern.Any() &&
|
||||
a.Opacity.IsAlways(LottieData.Opacity.Opaque) && b.Opacity.IsAlways(LottieData.Opacity.Opaque))
|
||||
|
@ -280,7 +274,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return b;
|
||||
}
|
||||
|
||||
TrimPath ComposeTrimPaths(TrimPath a, TrimPath b)
|
||||
TrimPath? ComposeTrimPaths(TrimPath? a, TrimPath? b)
|
||||
{
|
||||
if (a is null)
|
||||
{
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
|
@ -23,16 +24,25 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
new ShapeLayerTranslator(context);
|
||||
|
||||
public static void TranslateAndApplyShapeContext(
|
||||
ShapeContext context,
|
||||
CompositionSpriteShape shape,
|
||||
bool reverseDirection) =>
|
||||
TranslateAndApplyShapeContextWithTrimOffset(context, shape, reverseDirection, 0);
|
||||
|
||||
public static void TranslateAndApplyShapeContextWithTrimOffset(
|
||||
ShapeContext context,
|
||||
CompositionSpriteShape shape,
|
||||
bool reverseDirection,
|
||||
double trimOffsetDegrees)
|
||||
{
|
||||
Debug.Assert(shape.Geometry != null, "Precondition");
|
||||
|
||||
shape.FillBrush = Brushes.TranslateShapeFill(context, context.Fill, context.Opacity);
|
||||
Brushes.TranslateAndApplyStroke(context, context.Stroke, shape, context.Opacity);
|
||||
|
||||
TranslateAndApplyTrimPath(
|
||||
context,
|
||||
shape.Geometry,
|
||||
geometry: shape.Geometry!,
|
||||
reverseDirection,
|
||||
trimOffsetDegrees);
|
||||
}
|
||||
|
@ -221,7 +231,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
// Merge the stack into a single shape. Merging is done recursively - the top geometry on the
|
||||
// stack is merged with the merge of the remainder of the stack.
|
||||
static CompositionShape TranslateMergePathsContent(ShapeContext context, Stack<ShapeLayerContent> stack, MergePaths.MergeMode mergeMode)
|
||||
static CompositionShape? TranslateMergePathsContent(ShapeContext context, Stack<ShapeLayerContent> stack, MergePaths.MergeMode mergeMode)
|
||||
{
|
||||
var mergedGeometry = MergeShapeLayerContent(context, stack, mergeMode);
|
||||
if (mergedGeometry != null)
|
||||
|
@ -232,8 +242,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
TranslateAndApplyShapeContext(
|
||||
context,
|
||||
result,
|
||||
reverseDirection: false,
|
||||
trimOffsetDegrees: 0);
|
||||
reverseDirection: false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -243,7 +252,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
}
|
||||
}
|
||||
|
||||
static CanvasGeometry MergeShapeLayerContent(ShapeContext context, Stack<ShapeLayerContent> stack, MergePaths.MergeMode mergeMode)
|
||||
static CanvasGeometry? MergeShapeLayerContent(ShapeContext context, Stack<ShapeLayerContent> stack, MergePaths.MergeMode mergeMode)
|
||||
{
|
||||
var pathFillType = context.Fill is null ? ShapeFill.PathFillType.EvenOdd : context.Fill.FillType;
|
||||
var geometries = CreateCanvasGeometries(context, stack, pathFillType).ToArray();
|
||||
|
@ -260,7 +269,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
}
|
||||
|
||||
// Combine all of the given geometries into a single geometry.
|
||||
static CanvasGeometry CombineGeometries(
|
||||
static CanvasGeometry? CombineGeometries(
|
||||
TranslationContext context,
|
||||
CanvasGeometry[] geometries,
|
||||
MergePaths.MergeMode mergeMode)
|
||||
|
@ -331,7 +340,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
break;
|
||||
case ShapeContentType.MergePaths:
|
||||
yield return MergeShapeLayerContent(context, stack, ((MergePaths)shapeContent).Mode);
|
||||
var mergedShapeLayerContent = MergeShapeLayerContent(context, stack, ((MergePaths)shapeContent).Mode);
|
||||
if (mergedShapeLayerContent != null)
|
||||
{
|
||||
yield return mergedShapeLayerContent;
|
||||
}
|
||||
|
||||
break;
|
||||
case ShapeContentType.Repeater:
|
||||
context.Issues.RepeaterIsNotSupported();
|
||||
|
@ -624,7 +638,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
internal override bool IsShape => !_context.Layer.Masks.Any();
|
||||
|
||||
internal override CompositionShape GetShapeRoot(TranslationContext context)
|
||||
internal override CompositionShape? GetShapeRoot(TranslationContext context)
|
||||
{
|
||||
bool layerHasMasks = false;
|
||||
#if !NoClipping
|
||||
|
@ -651,7 +665,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return rootNode;
|
||||
}
|
||||
|
||||
internal override Visual GetVisualRoot(CompositionContext context)
|
||||
internal override Visual? GetVisualRoot(CompositionContext context)
|
||||
{
|
||||
bool layerHasMasks = false;
|
||||
#if !NoClipping
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
using Sn = System.Numerics;
|
||||
|
@ -32,7 +30,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
internal override bool IsShape =>
|
||||
!_context.Layer.Masks.Any() || _context.Layer.IsHidden || _context.Layer.Transform.Opacity.IsAlways(LottieData.Opacity.Transparent);
|
||||
|
||||
internal override CompositionShape GetShapeRoot(TranslationContext context)
|
||||
internal override CompositionShape? GetShapeRoot(TranslationContext context)
|
||||
{
|
||||
if (_context.Layer.IsHidden || _context.Layer.Transform.Opacity.IsAlways(LottieData.Opacity.Transparent))
|
||||
{
|
||||
|
@ -67,7 +65,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
return containerRootNode;
|
||||
}
|
||||
|
||||
internal override Visual GetVisualRoot(CompositionContext context)
|
||||
internal override Visual? GetVisualRoot(CompositionContext context)
|
||||
{
|
||||
// Translate the SolidLayer to a Visual.
|
||||
if (_context.Layer.IsHidden || _context.Layer.Transform.Opacity.IsAlways(LottieData.Opacity.Transparent))
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
|
@ -29,7 +27,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
/// <returns>The name of the corresponding property in the theme <see cref="CompositionPropertySet"/>
|
||||
/// or null.</returns>
|
||||
public static string GetThemeBindingNameForLottieProperty(TranslationContext context, string bindingSpec, string propertyName)
|
||||
public static string? GetThemeBindingNameForLottieProperty(TranslationContext context, string bindingSpec, string propertyName)
|
||||
=> context.TranslatePropertyBindings
|
||||
? PropertyBindings.FindFirstBindingNameForProperty(bindingSpec, propertyName)
|
||||
: null;
|
||||
|
@ -59,19 +57,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
case CompositionGetValueStatus.NotFound:
|
||||
// The property hasn't been added yet. Add it.
|
||||
themePropertySet.InsertVector4(bindingName, ConvertTo.Vector4(defaultValueAsWinUIColor));
|
||||
context.Translation.PropertyBindings.AddPropertyBinding(new CompMetadata.PropertyBinding
|
||||
{
|
||||
BindingName = bindingName,
|
||||
DisplayName = displayName,
|
||||
ActualType = PropertySetValueType.Vector4,
|
||||
ExposedType = PropertySetValueType.Color,
|
||||
DefaultValue = defaultValueAsWinUIColor,
|
||||
});
|
||||
context.Translation.PropertyBindings.AddPropertyBinding(new CompMetadata.PropertyBinding(
|
||||
bindingName : bindingName,
|
||||
displayName : displayName,
|
||||
actualType : PropertySetValueType.Vector4,
|
||||
exposedType : PropertySetValueType.Color,
|
||||
defaultValue : defaultValueAsWinUIColor));
|
||||
break;
|
||||
|
||||
case CompositionGetValueStatus.Succeeded:
|
||||
// The property has already been added.
|
||||
var existingValue = ConvertTo.Color(ConvertTo.Color(existingColorAsVector4));
|
||||
var existingValue = ConvertTo.Color(ConvertTo.Color(existingColorAsVector4!.Value));
|
||||
|
||||
if (defaultValueAsVector4 != existingColorAsVector4)
|
||||
{
|
||||
|
@ -100,14 +96,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
case CompositionGetValueStatus.NotFound:
|
||||
// The property hasn't been added yet. Add it.
|
||||
themePropertySet.InsertScalar(bindingName, defaultValueAsFloat);
|
||||
context.PropertyBindings.AddPropertyBinding(new CompMetadata.PropertyBinding
|
||||
{
|
||||
BindingName = bindingName,
|
||||
DisplayName = displayName,
|
||||
ActualType = PropertySetValueType.Scalar,
|
||||
ExposedType = PropertySetValueType.Scalar,
|
||||
DefaultValue = ConvertTo.Float(defaultValue),
|
||||
});
|
||||
context.PropertyBindings.AddPropertyBinding(new CompMetadata.PropertyBinding(
|
||||
bindingName : bindingName,
|
||||
displayName : displayName,
|
||||
actualType : PropertySetValueType.Scalar,
|
||||
exposedType : PropertySetValueType.Scalar,
|
||||
defaultValue : ConvertTo.Float(defaultValue)));
|
||||
break;
|
||||
|
||||
case CompositionGetValueStatus.Succeeded:
|
||||
|
@ -154,7 +148,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
|
||||
sealed class StateCache
|
||||
{
|
||||
CompositionPropertySet _themePropertySet;
|
||||
CompositionPropertySet? _themePropertySet;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CompositionPropertySet"/> used for property bindings for themed Lotties.
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.LottieData;
|
||||
using Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData;
|
||||
using Expr = Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions.Expression;
|
||||
|
@ -21,7 +20,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// </summary>
|
||||
static class Transforms
|
||||
{
|
||||
public static Sn.Matrix3x2 CreateMatrixFromTransform(LayerContext context, Transform transform)
|
||||
public static Sn.Matrix3x2 CreateMatrixFromTransform(LayerContext context, Transform? transform)
|
||||
{
|
||||
if (transform is null)
|
||||
{
|
||||
|
@ -58,8 +57,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <returns><c>true</c> if the the chain was created.</returns>
|
||||
public static bool TryCreateShapeVisualTransformChain(
|
||||
LayerContext context,
|
||||
out ContainerVisual rootNode,
|
||||
out CompositionContainerShape contentsNode)
|
||||
[NotNullWhen(true)] out ContainerVisual? rootNode,
|
||||
[NotNullWhen(true)] out CompositionContainerShape? contentsNode)
|
||||
{
|
||||
// Create containers for the contents in the layer.
|
||||
// The rootNode is the root for the layer.
|
||||
|
@ -148,8 +147,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <returns><c>true</c> if the the chain was created.</returns>
|
||||
public static bool TryCreateContainerShapeTransformChain(
|
||||
LayerContext context,
|
||||
out CompositionContainerShape rootNode,
|
||||
out CompositionContainerShape contentsNode)
|
||||
[NotNullWhen(true)] out CompositionContainerShape? rootNode,
|
||||
[NotNullWhen(true)] out CompositionContainerShape? contentsNode)
|
||||
{
|
||||
// Create containers for the contents in the layer.
|
||||
// The rootNode is the root for the layer. It may be the same object
|
||||
|
@ -250,8 +249,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <returns><c>true</c> if the the chain was created.</returns>
|
||||
public static bool TryCreateContainerVisualTransformChain(
|
||||
LayerContext context,
|
||||
out ContainerVisual rootNode,
|
||||
out ContainerVisual contentsNode)
|
||||
[NotNullWhen(true)] out ContainerVisual? rootNode,
|
||||
[NotNullWhen(true)] out ContainerVisual? contentsNode)
|
||||
{
|
||||
// Create containers for the contents in the layer.
|
||||
// The rootTransformNode is the root for the layer. It may be the same object
|
||||
|
@ -393,7 +392,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
if (layer.Parent != null)
|
||||
{
|
||||
var parentLayer = context.CompositionContext.Layers.GetLayerById(layer.Parent.Value);
|
||||
TranslateTransformOnContainerVisualForLayer(context, parentLayer, out rootTransformNode, out var parentLeafTransform);
|
||||
TranslateTransformOnContainerVisualForLayer(context, parentLayer!, out rootTransformNode, out var parentLeafTransform);
|
||||
parentLeafTransform.Children.Add(leafTransformNode);
|
||||
}
|
||||
else
|
||||
|
@ -420,7 +419,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
if (layer.Parent != null)
|
||||
{
|
||||
var parentLayer = context.CompositionContext.Layers.GetLayerById(layer.Parent.Value);
|
||||
TranslateTransformOnContainerShapeForLayer(context, parentLayer, out rootTransformNode, out var parentLeafTransform);
|
||||
TranslateTransformOnContainerShapeForLayer(context, parentLayer!, out rootTransformNode, out var parentLeafTransform);
|
||||
parentLeafTransform.Shapes.Add(leafTransformNode);
|
||||
leafTransformNode.SetDescription(context, () => ($"Transforms for {layer.Name}", $"Transforms: {layer.Name}"));
|
||||
}
|
||||
|
@ -589,7 +588,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
}
|
||||
|
||||
// If the position or anchor are animated, the offset needs to be calculated via an expression.
|
||||
ExpressionAnimation offsetExpression = null;
|
||||
ExpressionAnimation? offsetExpression = null;
|
||||
if (positionIsAnimated && anchorIsAnimated)
|
||||
{
|
||||
// Both position and anchor are animated.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable disable // Temporary while enabling nullable everywhere.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -105,7 +103,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <summary>
|
||||
/// The palette of colors in fills and strokes. Null if color bindings are not enabled.
|
||||
/// </summary>
|
||||
public Dictionary<Color, string> ColorPalette { get; }
|
||||
public Dictionary<Color, string>? ColorPalette { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Factory for creating composition objects.
|
||||
|
@ -147,7 +145,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <summary>
|
||||
/// The root Visual of the resulting translation.
|
||||
/// </summary>
|
||||
public ContainerVisual RootVisual { get; private set; }
|
||||
public ContainerVisual? RootVisual { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// True iff theme property bindings are enabled.
|
||||
|
@ -183,7 +181,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// Returns the asset with the given ID and type, or null if no such asset exists.
|
||||
/// </summary>
|
||||
/// <returns>The asset or null.</returns>
|
||||
public Asset GetAssetById(LayerContext context, string assetId, Asset.AssetType expectedAssetType)
|
||||
public Asset? GetAssetById(LayerContext context, string assetId, Asset.AssetType expectedAssetType)
|
||||
{
|
||||
var referencedAsset = LottieComposition.Assets.GetAssetById(assetId);
|
||||
if (referencedAsset is null)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
sealed class TranslationResult
|
||||
{
|
||||
internal TranslationResult(
|
||||
Visual rootVisual,
|
||||
Visual? rootVisual,
|
||||
IEnumerable<TranslationIssue> translationIssues,
|
||||
uint minimumRequiredUapVersion,
|
||||
IReadOnlyDictionary<Guid, object> sourceMetadata)
|
||||
|
@ -32,7 +32,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
/// <summary>
|
||||
/// The <see cref="Visual"/> at the root of the translation, or null if the translation failed.
|
||||
/// </summary>
|
||||
public Visual RootVisual { get; }
|
||||
public Visual? RootVisual { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Metadata from the source.
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
// 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.
|
||||
|
||||
//
|
||||
// This file is a workaround for the current lack of support for
|
||||
// nullables in .NET Native. As long as nullables are enabled in
|
||||
// the C# compiler, and this file is included, nullables will work.
|
||||
// Without this file, the definitions for the attributes will not
|
||||
// be found causing build errors.
|
||||
//
|
||||
// The file is only needed for projects built for older frameworks
|
||||
// that do not include these attributes.
|
||||
#pragma warning disable SA1402 // File should only contain one type
|
||||
#pragma warning disable SA1649 // File name should match first type name
|
||||
|
||||
namespace System.Diagnostics.CodeAnalysis
|
||||
{
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Field | AttributeTargets.Parameter |
|
||||
AttributeTargets.Property | AttributeTargets.ReturnValue
|
||||
)]
|
||||
internal sealed class MaybeNullAttribute : Attribute
|
||||
{
|
||||
public MaybeNullAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
internal sealed class MaybeNullWhenAttribute : Attribute
|
||||
{
|
||||
public bool ReturnValue { get; }
|
||||
|
||||
public MaybeNullWhenAttribute(bool returnValue)
|
||||
{
|
||||
ReturnValue = returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue,
|
||||
AllowMultiple = true
|
||||
)]
|
||||
sealed class NotNullIfNotNullAttribute : Attribute
|
||||
{
|
||||
public string ParameterName { get; }
|
||||
|
||||
public NotNullIfNotNullAttribute(string parameterName)
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
internal sealed class NotNullWhenAttribute : Attribute
|
||||
{
|
||||
public bool ReturnValue { get; }
|
||||
|
||||
public NotNullWhenAttribute(bool returnValue)
|
||||
{
|
||||
ReturnValue = returnValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>8c8964a7-a4f1-40a0-9a44-74371c9ec858</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)NullablesAttributes.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>e32587a8-94e8-4b68-91ad-f3612a48a62b</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<Import Project="NullablesAttributes.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче