Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Add LottieIsland and LottieWinRT for frameworkless or native applications #557

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
03637d8
Moved Lottie Island project files over to this repo
getrou Mar 15, 2024
15673a6
SimpleIslandApp now calls into C# JSON loader and works end to end. H…
getrou Mar 15, 2024
f715f7b
Merge pull request #1 from getrou/getrou/c_sharp_sample_working
getrou Mar 15, 2024
7d583f3
Updated sample app to match FHL sample
getrou Mar 20, 2024
2669684
Changed LottieVisualSource2 to LottieVisualSourceFrameworkless and wr…
getrou Apr 12, 2024
3e107ef
Updated sample and LottieIsland to consume new interfaces
getrou Apr 16, 2024
0329c09
Removed unused projects, moved LottieWinRT over to custom interface
getrou Apr 18, 2024
9cf356a
Reduced CsWinRT issue down to simpler form, added logic to build scri…
getrou Apr 18, 2024
567d126
Changed LottieIsland.IAnimatedVisualSource to LottieIsland.IAnimatedV…
getrou Apr 18, 2024
aef4a7c
Moved LottieWinRT to be based on public Lottie-WinUI nuget package in…
getrou Apr 18, 2024
87525d0
Worked through threading issues from using C# events
getrou Apr 19, 2024
e7a6d2f
Test app working, loading Lottie. Working through small bug around re…
getrou Apr 19, 2024
381c02d
Add nuget restore for LottieIsland.vcxproj
getrou Apr 19, 2024
7263a34
Fix project references so everything builds out of the box with no cu…
getrou Apr 19, 2024
807c32a
Merge branch 'dev/getrou/lottie_island' into dev/getrou/lottie_island…
getrou Apr 19, 2024
8fd5e6b
Add nuget restore for SimpleLottieIslandApp.vcxproj
getrou Apr 19, 2024
b41d8fd
More project reference work
getrou Apr 19, 2024
66b537b
Add C# app and show how to consume nuget packages. (Only working in C…
getrou Apr 20, 2024
457d0b7
Clean up C# app and add comments
getrou Apr 20, 2024
10d8542
Remove C# sample app, change LottieIsland to take an AnimatedVisual
getrou Apr 24, 2024
623d418
Merge branch 'dev/getrou/lottie_island' into dev/getrou/lottie_island…
getrou Apr 24, 2024
ddcc1a6
Fixed LottieWinRT x86 project dependencies
getrou Apr 24, 2024
144a389
Fixed sample app Release configuration
getrou Apr 25, 2024
af22bdc
Can build from command line: msbuild .\Lottie-Windows.sln /p:Platform…
getrou Apr 25, 2024
7201843
Add nuget.config
getrou Apr 25, 2024
95e6616
Fixed up some more project configurations
getrou Apr 25, 2024
544cde6
Remove UWP samples from sln file to allow solution to build
getrou Apr 25, 2024
8d9c060
Fix pack targets
getrou Apr 25, 2024
5896c83
Cleaned up nuget generation
getrou Apr 25, 2024
9e92f8e
Make nuget package for LottieWinRT include projection DLLs for projec…
getrou Apr 25, 2024
1167c74
Remove AnyCPU from LottieWinRT
getrou Apr 25, 2024
b40f53f
Remove build target for LottieWinRT AnyCPU
getrou Apr 25, 2024
9a0ce7c
Removed a few comments
getrou Apr 25, 2024
0840bbb
Add Lottie-Windows-WinUI3-Controls project and package to remove the …
getrou Apr 26, 2024
32e0e81
Fixes to get build to succeed
getrou Apr 26, 2024
a542db3
Fixups for PR feedback
getrou Apr 26, 2024
05d2e1f
Remove outdated tooling, old .NET versions
getrou Apr 26, 2024
267afe5
Removed more unneeded code
getrou Apr 28, 2024
f91bf4d
Resolve merge conflicts with main
getrou Apr 28, 2024
d8752d4
Bump Lottie-Windows TFM to 19041
getrou Apr 29, 2024
845f6f3
Add UIA support
May 7, 2024
750f44c
Update version to 8.1 and start producing Controls package
getrou May 8, 2024
81b8438
Don't take the lock in Add/GetHandler in AutomationBase
getrou May 8, 2024
eac0dc2
Use AppData in LottieIsland
May 8, 2024
0945863
Merge pull request #558 from CommunityToolkit/user/adpa-ms/lottie_isl…
getrou May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt

# Visual Studio editor config file
.editorconfig

# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
Expand Down Expand Up @@ -234,4 +237,6 @@ msbuild.binlog
LottieGenOutput-*/

# Visual Studio debugging configuration file.
launchSettings.json
launchSettings.json

Generated Files/
284 changes: 156 additions & 128 deletions Lottie-Windows.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows10.0.18362.0</TargetFramework>
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
<OutputType>Library</OutputType>

<PackageId>CommunityToolkit.WinUI.Lottie</PackageId>
<PackageTags>WinUI3 Toolkit Windows Animations Lottie XAML</PackageTags>

<Nullable>enable</Nullable>
<Platforms>AnyCPU</Platforms>
<CsWinRTIncludes>Microsoft</CsWinRTIncludes>
<DefineConstants>WINAPPSDK</DefineConstants>
<SignAssembly>True</SignAssembly>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.4" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230331000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240404000" />
</ItemGroup>

<Import Project="..\Lottie-Windows.props" />
Expand Down
4,309 changes: 4,309 additions & 0 deletions LottieGen/AnimatedVisuals.LottieLogo1.cpp

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions LottieGen/AnimatedVisuals.LottieLogo1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#pragma once
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// LottieGen version:
// 8.0.230813-rc.7+0443b1e789
//
// Command:
// LottieGen -Language Cppwinrt -WinUIVersion 3.0 -InputFile LottieLogo1.json
//
// Input file:
// LottieLogo1.json (190271 bytes created 0:40-04:00 Mar 13 2024)
//
// LottieGen source:
// http://aka.ms/Lottie
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#include "AnimatedVisuals.LottieLogo1.g.h"

namespace winrt::AnimatedVisuals
{
// Frame rate: 30 fps
// Frame count: 179
// Duration: 5966.7 mS
namespace implementation
{
class LottieLogo1
: public LottieLogo1T<LottieLogo1>
{
public:
// Animation duration: 5.967 seconds.
static constexpr int64_t c_durationTicks{ 59666666L };

winrt::Microsoft::UI::Xaml::Controls::IAnimatedVisual TryCreateAnimatedVisual(
winrt::Microsoft::UI::Composition::Compositor const& compositor);

winrt::Microsoft::UI::Xaml::Controls::IAnimatedVisual TryCreateAnimatedVisual(
winrt::Microsoft::UI::Composition::Compositor const& compositor,
winrt::Windows::Foundation::IInspectable& diagnostics);

// Gets the number of frames in the animation.
double FrameCount();

// Gets the framerate of the animation.
double Framerate();

// Gets the duration of the animation.
winrt::Windows::Foundation::TimeSpan Duration();

// Converts a zero-based frame number to the corresponding progress value denoting the
// start of the frame.
double FrameToProgress(double frameNumber);

// Returns a map from marker names to corresponding progress values.
winrt::Windows::Foundation::Collections::IMapView<hstring, double> Markers();

// Sets the color property with the given name, or does nothing if no such property
// exists.
void SetColorProperty(hstring const& propertyName, winrt::Windows::UI::Color value);

// Sets the scalar property with the given name, or does nothing if no such property
// exists.
void SetScalarProperty(hstring const& propertyName, double value);
};
}

namespace factory_implementation
{
struct LottieLogo1 : LottieLogo1T<LottieLogo1, implementation::LottieLogo1>
{
};
}
}
29 changes: 29 additions & 0 deletions LottieGen/AnimatedVisuals.LottieLogo1.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// LottieGen version:
// 8.0.230813-rc.7+0443b1e789
//
// Command:
// LottieGen -Language Cppwinrt -WinUIVersion 3.0 -InputFile LottieLogo1.json
//
// Input file:
// LottieLogo1.json (190271 bytes created 0:40-04:00 Mar 13 2024)
//
// LottieGen source:
// http://aka.ms/Lottie
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AnimatedVisuals
{
runtimeclass LottieLogo1
: [default] Microsoft.UI.Xaml.Controls.IAnimatedVisualSource
, Microsoft.UI.Xaml.Controls.IAnimatedVisualSource2
{
LottieLogo1();
};
}
3 changes: 3 additions & 0 deletions LottieIsland/CommunityToolkit.WinAppSDK.LottieIsland.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPORTS
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
44 changes: 44 additions & 0 deletions LottieIsland/CommunityToolkit.WinAppSDK.LottieIsland.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace CommunityToolkit.WinAppSDK.LottieIsland
{
interface IAnimatedVisualFrameworkless
{
Windows.Foundation.TimeSpan Duration{ get; };
Microsoft.UI.Composition.Visual RootVisual{ get; };
Windows.Foundation.Numerics.Vector2 Size{ get; };
};

runtimeclass LottieContentIsland
{
static LottieContentIsland Create(Microsoft.UI.Composition.Compositor compositor);

Microsoft.UI.Content.ContentIsland Island{ get; };

IAnimatedVisualFrameworkless AnimatedVisual;

Windows.Foundation.TimeSpan Duration{ get; };

Boolean IsAnimationLoaded{ get; };

Boolean IsPlaying{ get; };

Single PlaybackRate;

event Windows.Foundation.TypedEventHandler<LottieContentIsland, Microsoft.UI.Input.PointerEventArgs> PointerEntered;
getrou marked this conversation as resolved.
Show resolved Hide resolved

event Windows.Foundation.TypedEventHandler<LottieContentIsland, Microsoft.UI.Input.PointerEventArgs> PointerExited;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these just be configured on the ContentIsland directly? Why does it need to be exposed from this object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow a hosting application to hook into input to configure e.g. click to pause. We didn't want to have the hosting application directly calling InputPointerSource.GetForIsland

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No really, I'd like to remove it for now. We're already passing the ContentIsland out as a property. The app can call InputPointerSource.GetForIsland. Unless there's an important reason to wrap and re-expose all of this (e.g., something about object destruction), it's much better to not need to duplicate all of these APIs.


event Windows.Foundation.TypedEventHandler<LottieContentIsland, Microsoft.UI.Input.PointerEventArgs> PointerMoved;

event Windows.Foundation.TypedEventHandler<LottieContentIsland, Microsoft.UI.Input.PointerEventArgs> PointerPressed;

event Windows.Foundation.TypedEventHandler<LottieContentIsland, Microsoft.UI.Input.PointerEventArgs> PointerReleased;

void Pause();

Windows.Foundation.IAsyncAction PlayAsync(Single fromProgress, Single toProgress, Boolean looped);

void Resume();

void Stop();
}
}
7 changes: 7 additions & 0 deletions LottieIsland/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<BuildOutDir>$([MSBuild]::NormalizeDirectory('$(SolutionDir)', '_build', '$(Platform)', '$(Configuration)'))</BuildOutDir>
<OutDir>$([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'bin'))</OutDir>
<IntDir>$([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'obj'))</IntDir>
</PropertyGroup>
</Project>
Loading