Skip to content

Commit

Permalink
Determinate ProgressRing with Lottie (#2584)
Browse files Browse the repository at this point in the history
* add determinate player

* Lottie determinate fix

* updateLottieProgress with PlayAsync

* rebase fix

* have one AnimatedPlayer in xaml

* add determinateRing

* switch source for IsIndeterminate toggle

* re-add second animated visual player

* fix bugs for re-template scenarios

* lottie SetColor fix

* opacity change fix

* update tests

* changes from comments

* remove register OpacityProperty callback for determinate player

* changes from comments + color fix

* move animated visuals to folder

* disable animation for tests

* fix animatedVisual directories

* disable animation in testUI

* rename IndeterminateActive state to Active

* fix rebase errors

* replace 0 sec animation with property setter

* make sources public

* remove second AVP

* add update states logic

* Update TestUI pages

* disable colour update for custom animation

* rename progressRing variable

* remove OnOpacityChanged / add comments

* comments

* IThemedAnimatedVisualSource.h

* update ProgressRingIndeterminate codegen
  • Loading branch information
karkarl authored Jul 31, 2020
1 parent 2b03c3e commit bae964c
Show file tree
Hide file tree
Showing 21 changed files with 1,271 additions and 372 deletions.
102 changes: 102 additions & 0 deletions dev/Generated/ProgressRing.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ namespace winrt::Microsoft::UI::Xaml::Controls

#include "ProgressRing.g.cpp"

GlobalDependencyProperty ProgressRingProperties::s_DeterminateSourceProperty{ nullptr };
GlobalDependencyProperty ProgressRingProperties::s_IndeterminateSourceProperty{ nullptr };
GlobalDependencyProperty ProgressRingProperties::s_IsActiveProperty{ nullptr };
GlobalDependencyProperty ProgressRingProperties::s_IsIndeterminateProperty{ nullptr };
GlobalDependencyProperty ProgressRingProperties::s_TemplateSettingsProperty{ nullptr };

ProgressRingProperties::ProgressRingProperties()
Expand All @@ -23,6 +26,28 @@ ProgressRingProperties::ProgressRingProperties()

void ProgressRingProperties::EnsureProperties()
{
if (!s_DeterminateSourceProperty)
{
s_DeterminateSourceProperty =
InitializeDependencyProperty(
L"DeterminateSource",
winrt::name_of<winrt::IAnimatedVisualSource>(),
winrt::name_of<winrt::ProgressRing>(),
false /* isAttached */,
ValueHelper<winrt::IAnimatedVisualSource>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnDeterminateSourcePropertyChanged));
}
if (!s_IndeterminateSourceProperty)
{
s_IndeterminateSourceProperty =
InitializeDependencyProperty(
L"IndeterminateSource",
winrt::name_of<winrt::IAnimatedVisualSource>(),
winrt::name_of<winrt::ProgressRing>(),
false /* isAttached */,
ValueHelper<winrt::IAnimatedVisualSource>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnIndeterminateSourcePropertyChanged));
}
if (!s_IsActiveProperty)
{
s_IsActiveProperty =
Expand All @@ -34,6 +59,17 @@ void ProgressRingProperties::EnsureProperties()
ValueHelper<bool>::BoxValueIfNecessary(true),
winrt::PropertyChangedCallback(&OnIsActivePropertyChanged));
}
if (!s_IsIndeterminateProperty)
{
s_IsIndeterminateProperty =
InitializeDependencyProperty(
L"IsIndeterminate",
winrt::name_of<bool>(),
winrt::name_of<winrt::ProgressRing>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(true),
winrt::PropertyChangedCallback(&OnIsIndeterminatePropertyChanged));
}
if (!s_TemplateSettingsProperty)
{
s_TemplateSettingsProperty =
Expand All @@ -49,10 +85,29 @@ void ProgressRingProperties::EnsureProperties()

void ProgressRingProperties::ClearProperties()
{
s_DeterminateSourceProperty = nullptr;
s_IndeterminateSourceProperty = nullptr;
s_IsActiveProperty = nullptr;
s_IsIndeterminateProperty = nullptr;
s_TemplateSettingsProperty = nullptr;
}

void ProgressRingProperties::OnDeterminateSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ProgressRing>();
winrt::get_self<ProgressRing>(owner)->OnDeterminateSourcePropertyChanged(args);
}

void ProgressRingProperties::OnIndeterminateSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ProgressRing>();
winrt::get_self<ProgressRing>(owner)->OnIndeterminateSourcePropertyChanged(args);
}

void ProgressRingProperties::OnIsActivePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
Expand All @@ -61,6 +116,40 @@ void ProgressRingProperties::OnIsActivePropertyChanged(
winrt::get_self<ProgressRing>(owner)->OnIsActivePropertyChanged(args);
}

void ProgressRingProperties::OnIsIndeterminatePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ProgressRing>();
winrt::get_self<ProgressRing>(owner)->OnIsIndeterminatePropertyChanged(args);
}

void ProgressRingProperties::DeterminateSource(winrt::IAnimatedVisualSource const& value)
{
[[gsl::suppress(con)]]
{
static_cast<ProgressRing*>(this)->SetValue(s_DeterminateSourceProperty, ValueHelper<winrt::IAnimatedVisualSource>::BoxValueIfNecessary(value));
}
}

winrt::IAnimatedVisualSource ProgressRingProperties::DeterminateSource()
{
return ValueHelper<winrt::IAnimatedVisualSource>::CastOrUnbox(static_cast<ProgressRing*>(this)->GetValue(s_DeterminateSourceProperty));
}

void ProgressRingProperties::IndeterminateSource(winrt::IAnimatedVisualSource const& value)
{
[[gsl::suppress(con)]]
{
static_cast<ProgressRing*>(this)->SetValue(s_IndeterminateSourceProperty, ValueHelper<winrt::IAnimatedVisualSource>::BoxValueIfNecessary(value));
}
}

winrt::IAnimatedVisualSource ProgressRingProperties::IndeterminateSource()
{
return ValueHelper<winrt::IAnimatedVisualSource>::CastOrUnbox(static_cast<ProgressRing*>(this)->GetValue(s_IndeterminateSourceProperty));
}

void ProgressRingProperties::IsActive(bool value)
{
[[gsl::suppress(con)]]
Expand All @@ -74,6 +163,19 @@ bool ProgressRingProperties::IsActive()
return ValueHelper<bool>::CastOrUnbox(static_cast<ProgressRing*>(this)->GetValue(s_IsActiveProperty));
}

void ProgressRingProperties::IsIndeterminate(bool value)
{
[[gsl::suppress(con)]]
{
static_cast<ProgressRing*>(this)->SetValue(s_IsIndeterminateProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}
}

bool ProgressRingProperties::IsIndeterminate()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<ProgressRing*>(this)->GetValue(s_IsIndeterminateProperty));
}

void ProgressRingProperties::TemplateSettings(winrt::ProgressRingTemplateSettings const& value)
{
[[gsl::suppress(con)]]
Expand Down
27 changes: 27 additions & 0 deletions dev/Generated/ProgressRing.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,49 @@ class ProgressRingProperties
public:
ProgressRingProperties();

void DeterminateSource(winrt::IAnimatedVisualSource const& value);
winrt::IAnimatedVisualSource DeterminateSource();

void IndeterminateSource(winrt::IAnimatedVisualSource const& value);
winrt::IAnimatedVisualSource IndeterminateSource();

void IsActive(bool value);
bool IsActive();

void IsIndeterminate(bool value);
bool IsIndeterminate();

void TemplateSettings(winrt::ProgressRingTemplateSettings const& value);
winrt::ProgressRingTemplateSettings TemplateSettings();

static winrt::DependencyProperty DeterminateSourceProperty() { return s_DeterminateSourceProperty; }
static winrt::DependencyProperty IndeterminateSourceProperty() { return s_IndeterminateSourceProperty; }
static winrt::DependencyProperty IsActiveProperty() { return s_IsActiveProperty; }
static winrt::DependencyProperty IsIndeterminateProperty() { return s_IsIndeterminateProperty; }
static winrt::DependencyProperty TemplateSettingsProperty() { return s_TemplateSettingsProperty; }

static GlobalDependencyProperty s_DeterminateSourceProperty;
static GlobalDependencyProperty s_IndeterminateSourceProperty;
static GlobalDependencyProperty s_IsActiveProperty;
static GlobalDependencyProperty s_IsIndeterminateProperty;
static GlobalDependencyProperty s_TemplateSettingsProperty;

static void EnsureProperties();
static void ClearProperties();

static void OnDeterminateSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnIndeterminateSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnIsActivePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnIsIndeterminatePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);
};
Loading

0 comments on commit bae964c

Please sign in to comment.