Skip to content

Commit 4e15df5

Browse files
author
Simeon
authored
Create a project just for the animatables. (#413)
* Create a project just for the animatables. The animatables are types that are used by both LottieData and the upcoming intermediate representation, so we need them to be in a separate project so the code can be shared. This also adds some small features to some animatables for use by IR, and changes some IAnimatableVector3 types to IAnimatableVector2 (e.g. gradient stops should never by vector3. I've also removed the "property index" from animatables. That is a Lottie concept that is only needed if you are supporting javascript expressions. We will never support javascript expressions, so they're not needed. Removing them makes the code a bit cleaner.
1 parent d163ea8 commit 4e15df5

File tree

100 files changed

+915
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+915
-338
lines changed

Lottie-Windows.sln

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "DotLottie", "source\DotLott
158158
EndProject
159159
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotLottie.dll", "dlls\DotLottie\DotLottie.dll.csproj", "{AB2ACC11-DE31-4E47-8A5B-895D6934684F}"
160160
EndProject
161+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Animatables.dll", "dlls\Animatables\Animatables.dll.csproj", "{88C07427-E8AF-4F9D-A4FE-07EB2D975723}"
162+
EndProject
163+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Animatables", "source\Animatables\Animatables.shproj", "{FC89273A-B2DA-4625-8A73-EF02A658D65E}"
164+
EndProject
161165
Global
162166
GlobalSection(SharedMSBuildProjectFiles) = preSolution
163167
source\LottieToWinComp\LottieToWinComp.projitems*{0340244a-683c-405e-838b-f93872779532}*SharedItemsImports = 13
@@ -169,6 +173,7 @@ Global
169173
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{30059ca7-0745-4eec-8d11-b14850a70c98}*SharedItemsImports = 13
170174
source\YamlData\YamlData.projitems*{39c6b7f3-5e75-4019-82ab-00fd8a0a06e2}*SharedItemsImports = 13
171175
source\LottieReader\LottieReader.projitems*{4e7d8957-3f5f-46e1-99a8-2012b806c9b0}*SharedItemsImports = 13
176+
source\Animatables\Animatables.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
172177
source\CompMetadata\CompMetadata.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
173178
source\DotLottie\DotLottie.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
174179
source\GenericData\GenericData.projitems*{5120efd7-a556-46bf-8d56-f65f1ef9a305}*SharedItemsImports = 4
@@ -189,6 +194,7 @@ Global
189194
source\DotLottie\DotLottie.projitems*{7012420d-624c-4bd4-a1d2-1c6c1655ed3a}*SharedItemsImports = 13
190195
source\UIData\UIData.projitems*{74601e6c-2dfe-4842-b170-047941abff2c}*SharedItemsImports = 13
191196
source\GenericData\GenericData.projitems*{77bcd724-8555-463b-985f-f8e8110164c4}*SharedItemsImports = 13
197+
source\Animatables\Animatables.projitems*{88c07427-e8af-4f9d-a4fe-07eb2d975723}*SharedItemsImports = 5
192198
source\Lottie\Lottie.projitems*{8ef7bd77-28e9-4998-8dbb-8036f988fe65}*SharedItemsImports = 13
193199
source\UIData\UIData.projitems*{9a99e690-71d2-4e26-9000-0e0920394dfe}*SharedItemsImports = 5
194200
source\UIDataCodeGen\UIDataCodeGen.projitems*{9b6c0b7f-0d0f-4086-9746-0d34d7667db5}*SharedItemsImports = 5
@@ -199,6 +205,7 @@ Global
199205
source\LottieData\LottieData.projitems*{b3db16ee-a821-4474-a188-e64926529bbd}*SharedItemsImports = 13
200206
source\LottieReader\LottieReader.projitems*{bb081e5a-cf3c-490f-8f8e-450a79f6ca33}*SharedItemsImports = 5
201207
source\LottieToWinComp\LottieToWinComp.projitems*{bcedf904-f986-42ec-a22d-e0662777b7f9}*SharedItemsImports = 5
208+
source\Animatables\Animatables.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
202209
source\CompMetadata\CompMetadata.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
203210
source\DotLottie\DotLottie.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
204211
source\GenericData\GenericData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
@@ -216,6 +223,7 @@ Global
216223
source\WinCompData\WinCompData.projitems*{d02870de-7ded-4916-85d4-3175ceedef74}*SharedItemsImports = 13
217224
source\UIDataCodeGen\UIDataCodeGen.projitems*{d02be6c8-14db-4b4f-8600-f3c9b69c104d}*SharedItemsImports = 13
218225
source\NullablesAttributes\NullablesAttributes.projitems*{e32587a8-94e8-4b68-91ad-f3612a48a62b}*SharedItemsImports = 13
226+
source\Animatables\Animatables.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
219227
source\CompMetadata\CompMetadata.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
220228
source\DotLottie\DotLottie.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
221229
source\GenericData\GenericData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
@@ -230,6 +238,7 @@ Global
230238
source\WinStorageStreamsData\WinStorageStreamsData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
231239
source\WinUIXamlMediaData\WinUIXamlMediaData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
232240
source\YamlData\YamlData.projitems*{e392bad0-f936-4b64-a445-552597795cc7}*SharedItemsImports = 5
241+
source\Animatables\Animatables.projitems*{fc89273a-b2da-4625-8a73-ef02a658d65e}*SharedItemsImports = 13
233242
EndGlobalSection
234243
GlobalSection(SolutionConfigurationPlatforms) = preSolution
235244
BETA|Any CPU = BETA|Any CPU
@@ -578,6 +587,36 @@ Global
578587
{AB2ACC11-DE31-4E47-8A5B-895D6934684F}.Release|ARM64.ActiveCfg = Release|Any CPU
579588
{AB2ACC11-DE31-4E47-8A5B-895D6934684F}.Release|x64.ActiveCfg = Release|Any CPU
580589
{AB2ACC11-DE31-4E47-8A5B-895D6934684F}.Release|x86.ActiveCfg = Release|Any CPU
590+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|Any CPU.ActiveCfg = Debug|Any CPU
591+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|Any CPU.Build.0 = Debug|Any CPU
592+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|ARM.ActiveCfg = Debug|Any CPU
593+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|ARM.Build.0 = Debug|Any CPU
594+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|ARM64.ActiveCfg = Debug|Any CPU
595+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|ARM64.Build.0 = Debug|Any CPU
596+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|x64.ActiveCfg = Debug|Any CPU
597+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|x64.Build.0 = Debug|Any CPU
598+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|x86.ActiveCfg = Debug|Any CPU
599+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.BETA|x86.Build.0 = Debug|Any CPU
600+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
601+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|Any CPU.Build.0 = Debug|Any CPU
602+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|ARM.ActiveCfg = Debug|Any CPU
603+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|ARM.Build.0 = Debug|Any CPU
604+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|ARM64.ActiveCfg = Debug|Any CPU
605+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|ARM64.Build.0 = Debug|Any CPU
606+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|x64.ActiveCfg = Debug|Any CPU
607+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|x64.Build.0 = Debug|Any CPU
608+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|x86.ActiveCfg = Debug|Any CPU
609+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Debug|x86.Build.0 = Debug|Any CPU
610+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|Any CPU.ActiveCfg = Release|Any CPU
611+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|Any CPU.Build.0 = Release|Any CPU
612+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|ARM.ActiveCfg = Release|Any CPU
613+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|ARM.Build.0 = Release|Any CPU
614+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|ARM64.ActiveCfg = Release|Any CPU
615+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|ARM64.Build.0 = Release|Any CPU
616+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|x64.ActiveCfg = Release|Any CPU
617+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|x64.Build.0 = Release|Any CPU
618+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|x86.ActiveCfg = Release|Any CPU
619+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723}.Release|x86.Build.0 = Release|Any CPU
581620
EndGlobalSection
582621
GlobalSection(SolutionProperties) = preSolution
583622
HideSolutionNode = FALSE
@@ -614,6 +653,8 @@ Global
614653
{E32587A8-94E8-4B68-91AD-F3612A48A62B} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
615654
{7012420D-624C-4BD4-A1D2-1C6C1655ED3A} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
616655
{AB2ACC11-DE31-4E47-8A5B-895D6934684F} = {C75BD686-21A6-4EB3-8D4B-D5A01C019C52}
656+
{88C07427-E8AF-4F9D-A4FE-07EB2D975723} = {C75BD686-21A6-4EB3-8D4B-D5A01C019C52}
657+
{FC89273A-B2DA-4625-8A73-EF02A658D65E} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
617658
EndGlobalSection
618659
GlobalSection(ExtensibilityGlobals) = postSolution
619660
SolutionGuid = {51B9BB4C-5196-41CF-950C-12B04AD8A61C}

Lottie-Windows/Lottie-Windows.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
</PackageReference>
4848
</ItemGroup>
4949

50+
<Import Project="..\source\Animatables\Animatables.projitems" Label="Shared" />
5051
<Import Project="..\source\DotLottie\DotLottie.projitems" Label="Shared" />
5152
<Import Project="..\source\CompMetadata\CompMetadata.projitems" Label="Shared" />
5253
<Import Project="..\source\GenericData\GenericData.projitems" Label="Shared" />

LottieGen/LottieGen.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
<Import Project="..\source\WinUIXamlMediaData\WinUIXamlMediaData.projitems" Label="Shared" />
4040
<Import Project="..\source\YamlData\YamlData.projitems" Label="Shared" />
4141
<Import Project="..\source\UIDataCodeGen\UIDataCodeGen.projitems" Label="Shared" />
42+
<Import Project="..\source\Animatables\Animatables.projitems" Label="Shared" />
4243

4344
</Project>

LottieGen/LottieGen.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompMetadata", "..\source\C
105105
EndProject
106106
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "DotLottie", "..\source\DotLottie\DotLottie.shproj", "{7012420D-624C-4BD4-A1D2-1C6C1655ED3A}"
107107
EndProject
108+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Animatables", "..\source\Animatables\Animatables.shproj", "{FC89273A-B2DA-4625-8A73-EF02A658D65E}"
109+
EndProject
108110
Global
109111
GlobalSection(SharedMSBuildProjectFiles) = preSolution
110112
..\source\LottieToWinComp\LottieToWinComp.projitems*{0340244a-683c-405e-838b-f93872779532}*SharedItemsImports = 13
@@ -118,6 +120,7 @@ Global
118120
..\source\GenericData\GenericData.projitems*{77bcd724-8555-463b-985f-f8e8110164c4}*SharedItemsImports = 13
119121
..\source\CompMetadata\CompMetadata.projitems*{b0197c19-bdf5-473e-a022-e21f6122eee5}*SharedItemsImports = 13
120122
..\source\LottieData\LottieData.projitems*{b3db16ee-a821-4474-a188-e64926529bbd}*SharedItemsImports = 13
123+
..\source\Animatables\Animatables.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
121124
..\source\CompMetadata\CompMetadata.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
122125
..\source\DotLottie\DotLottie.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
123126
..\source\GenericData\GenericData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
@@ -133,6 +136,7 @@ Global
133136
..\source\YamlData\YamlData.projitems*{cb12d5ba-a6fe-41e2-b555-83c903cce92a}*SharedItemsImports = 5
134137
..\source\WinCompData\WinCompData.projitems*{d02870de-7ded-4916-85d4-3175ceedef74}*SharedItemsImports = 13
135138
..\source\UIDataCodeGen\UIDataCodeGen.projitems*{d02be6c8-14db-4b4f-8600-f3c9b69c104d}*SharedItemsImports = 13
139+
..\source\Animatables\Animatables.projitems*{fc89273a-b2da-4625-8a73-ef02a658d65e}*SharedItemsImports = 13
136140
EndGlobalSection
137141
GlobalSection(SolutionConfigurationPlatforms) = preSolution
138142
Debug|Any CPU = Debug|Any CPU
@@ -179,6 +183,7 @@ Global
179183
{04B43A1A-DDFB-4A61-BF36-39F5E666C702} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
180184
{B0197C19-BDF5-473E-A022-E21F6122EEE5} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
181185
{7012420D-624C-4BD4-A1D2-1C6C1655ED3A} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
186+
{FC89273A-B2DA-4625-8A73-EF02A658D65E} = {AB232F35-AAF7-4AE2-B1D2-45DD9BC2F7D7}
182187
EndGlobalSection
183188
GlobalSection(ExtensibilityGlobals) = postSolution
184189
SolutionGuid = {51B9BB4C-5196-41CF-950C-12B04AD8A61C}

LottieViewer/LottieViewer.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
54
<!-- Defaults if not specified. -->
65
<PropertyGroup>
76
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
87
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
98
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
109
</PropertyGroup>
11-
1210
<PropertyGroup>
1311
<AppDesignerFolder>Properties</AppDesignerFolder>
1412
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
@@ -42,28 +40,24 @@
4240
<UseVSHostingProcess>false</UseVSHostingProcess>
4341
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
4442
</PropertyGroup>
45-
4643
<!-- BETA allows building of a Release build with some small changes (e.g. app name
4744
and some assets) to make it clear that the code is for BETA testing. -->
4845
<PropertyGroup Condition=" '$(Configuration)' == 'BETA' ">
4946
<DebugType>pdbonly</DebugType>
5047
<Optimize>true</Optimize>
5148
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
5249
</PropertyGroup>
53-
5450
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
5551
<DebugSymbols>true</DebugSymbols>
5652
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
5753
<DebugType>full</DebugType>
5854
</PropertyGroup>
59-
6055
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
6156
<DebugType>pdbonly</DebugType>
6257
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
6358
<Optimize>true</Optimize>
6459
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
6560
</PropertyGroup>
66-
6761
<!-- These PropertyGroups are required to exist so that the VS Configuration Manager
6862
will recognize these configurations as valid. -->
6963
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'BETA|ARM' ">
@@ -90,7 +84,6 @@
9084
</PropertyGroup>
9185
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
9286
</PropertyGroup>
93-
9487
<ItemGroup>
9588
<Compile Include="AnimatedVisuals\LottieViewer_04_Playback.cs" />
9689
<Compile Include="App.xaml.cs">
@@ -247,6 +240,7 @@
247240
<Import Project="..\source\WinUIXamlMediaData\WinUIXamlMediaData.projitems" Label="Shared" />
248241
<Import Project="..\source\YamlData\YamlData.projitems" Label="Shared" />
249242
<Import Project="..\source\DotLottie\DotLottie.projitems" Label="Shared" />
243+
<Import Project="..\source\Animatables\Animatables.projitems" Label="Shared" />
250244
<Target Name="Pack">
251245
<!-- Dummy target to mute warnings about attempts to create a NuPkg -->
252246
</Target>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<Configurations>Debug;Release</Configurations>
6+
<LangVersion>latest</LangVersion>
7+
<DefineConstants>PUBLIC_Animatables</DefineConstants>
8+
</PropertyGroup>
9+
10+
<Import Project="..\..\source\Animatables\Animatables.projitems" Label="Shared" />
11+
12+
</Project>

dlls/LottieData/LottieData.dll.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18+
<ProjectReference Include="..\Animatables\Animatables.dll.csproj" />
1819
<ProjectReference Include="..\GenericData\GenericData.dll.csproj" />
1920
<ProjectReference Include="..\YamlData\YamlData.dll.csproj" />
2021
</ItemGroup>

dlls/LottieToWinComp/LottieToWinComp.dll.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Import Project="..\..\source\LottieToWinComp\LottieToWinComp.projitems" Label="Shared" />
1111

1212
<ItemGroup>
13+
<ProjectReference Include="..\Animatables\Animatables.dll.csproj" />
1314
<ProjectReference Include="..\CompMetadata\CompMetadata.dll.csproj" />
1415
<ProjectReference Include="..\LottieData\LottieData.dll.csproj" />
1516
<ProjectReference Include="..\LottieMetadata\LottieMetadata.dll.csproj" />

source/LottieData/Animatable.cs renamed to source/Animatables/Animatable.cs

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
using System;
88
using System.Collections.Generic;
9-
using System.Diagnostics;
9+
using System.Diagnostics.CodeAnalysis;
1010
using System.Linq;
1111

12-
namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData
12+
namespace Microsoft.Toolkit.Uwp.UI.Lottie.Animatables
1313
{
1414
/// <summary>
1515
/// A value that may be animated.
1616
/// </summary>
1717
/// <typeparam name="T">The type of the value.</typeparam>
18-
#if PUBLIC_LottieData
18+
#if PUBLIC_Animatables
1919
public
2020
#endif
2121
class Animatable<T> : IAnimatableValue<T>
@@ -25,18 +25,17 @@ class Animatable<T> : IAnimatableValue<T>
2525
/// Initializes a new instance of the <see cref="Animatable{T}"/> class with
2626
/// a non-animated value.
2727
/// </summary>
28-
public Animatable(T value, int? propertyIndex)
28+
public Animatable(T value)
2929
{
3030
KeyFrames = Array.Empty<KeyFrame<T>>();
3131
InitialValue = value;
32-
PropertyIndex = propertyIndex;
3332
}
3433

3534
/// <summary>
3635
/// Initializes a new instance of the <see cref="Animatable{T}"/> class with
3736
/// the given key frames.
3837
/// </summary>
39-
public Animatable(IEnumerable<KeyFrame<T>> keyFrames, int? propertyIndex)
38+
public Animatable(IEnumerable<KeyFrame<T>> keyFrames)
4039
{
4140
KeyFrames = keyFrames.ToArray();
4241

@@ -49,15 +48,13 @@ public Animatable(IEnumerable<KeyFrame<T>> keyFrames, int? propertyIndex)
4948
// saved the value in InitialValue. Might as well ditch the key frames.
5049
KeyFrames = Array.Empty<KeyFrame<T>>();
5150
}
52-
53-
PropertyIndex = propertyIndex;
5451
}
5552

5653
/// <summary>
5754
/// Initializes a new instance of the <see cref="Animatable{T}"/> class with
5855
/// the given key frames.
5956
/// </summary>
60-
public Animatable(T initialValue, IReadOnlyList<KeyFrame<T>> keyFrames, int? propertyIndex)
57+
public Animatable(T initialValue, IReadOnlyList<KeyFrame<T>> keyFrames)
6158
{
6259
KeyFrames = keyFrames;
6360

@@ -69,8 +66,6 @@ public Animatable(T initialValue, IReadOnlyList<KeyFrame<T>> keyFrames, int? pro
6966
// saved the value in InitialValue. Might as well ditch the key frames.
7067
KeyFrames = Array.Empty<KeyFrame<T>>();
7168
}
72-
73-
PropertyIndex = propertyIndex;
7469
}
7570

7671
/// <summary>
@@ -83,11 +78,6 @@ public Animatable(T initialValue, IReadOnlyList<KeyFrame<T>> keyFrames, int? pro
8378
/// </summary>
8479
public IReadOnlyList<KeyFrame<T>> KeyFrames { get; }
8580

86-
/// <summary>
87-
/// Gets the property index used for expressions.
88-
/// </summary>
89-
public int? PropertyIndex { get; }
90-
9181
/// <summary>
9282
/// Gets a value indicating whether the <see cref="Animatable{T}"/> has any key frames.
9383
/// </summary>
@@ -111,25 +101,25 @@ public Animatable(T initialValue, IReadOnlyList<KeyFrame<T>> keyFrames, int? pro
111101
/// <returns><c>true</c> if this value is ever not equal to the given value.</returns>
112102
public bool IsEverNot(T value) => !IsAlways(value);
113103

104+
public Animatable<T> WithTimeOffset(double timeOffset)
105+
=> timeOffset == 0
106+
? this
107+
: new Animatable<T>(KeyFrames.Select(kf => kf.WithTimeOffset(timeOffset)));
108+
109+
IAnimatableValue<T> IAnimatableValue<T>.WithTimeOffset(double timeOffset)
110+
=> WithTimeOffset(timeOffset);
111+
112+
public Animatable<T> Select(Func<T, T> selector)
113+
=> new Animatable<T>(KeyFrames.Select(kf => new KeyFrame<T>(kf.Frame, selector(kf.Value), kf.Easing)));
114+
115+
public Animatable<Tnew> Select<Tnew>(Func<T, Tnew> selector)
116+
where Tnew : IEquatable<Tnew>
117+
=> new Animatable<Tnew>(KeyFrames.Select(kf => new KeyFrame<Tnew>(kf.Frame, selector(kf.Value), kf.Easing)));
118+
114119
/// <inheritdoc/>
115120
// Not a great hash code because it ignore the KeyFrames, but quick.
116121
public override int GetHashCode() => InitialValue.GetHashCode();
117122

118-
internal Animatable<T> CloneWithSelectedValue(Func<T, T> selector)
119-
{
120-
if (IsAnimated)
121-
{
122-
var keyframes =
123-
from kf in KeyFrames.ToArray()
124-
select new KeyFrame<T>(kf.Frame, selector(kf.Value), kf.Easing);
125-
return new Animatable<T>(keyframes, PropertyIndex);
126-
}
127-
else
128-
{
129-
return new Animatable<T>(selector(InitialValue), PropertyIndex);
130-
}
131-
}
132-
133123
/// <inheritdoc/>
134124
public override string? ToString() =>
135125
IsAnimated

0 commit comments

Comments
 (0)