From 8814a1bc32ace4dbeda21ec130abc9dd0dc2264c Mon Sep 17 00:00:00 2001 From: Clarik <54880771+Clarik@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:25:06 +0700 Subject: [PATCH] [NUI] LottieAnimationViewBindableProperty changes (#6076) --- .../public/BaseComponents/LottieAnimationView.cs | 144 +++++++++++++++++++-- .../LottieAnimationViewBindableProperty.cs | 77 +++++++---- 2 files changed, 179 insertions(+), 42 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 886356c..a066c31 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -20,6 +20,8 @@ using global::System.Runtime.InteropServices; using System.ComponentModel; using System.Collections.Generic; using System.Globalization; +using Tizen.NUI; +using Tizen.NUI.Binding; namespace Tizen.NUI.BaseComponents { @@ -29,6 +31,22 @@ namespace Tizen.NUI.BaseComponents /// 7 public partial class LottieAnimationView : ImageView { + static LottieAnimationView() + { + URLProperty = BindableProperty.Create(nameof(URL), typeof(string), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), string.Empty, propertyChanged: SetInternalURLProperty, defaultValueCreator: GetInternalURLProperty); + + CurrentFrameProperty = BindableProperty.Create(nameof(CurrentFrame), typeof(int), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), 0, propertyChanged: SetInternalCurrentFrameProperty, defaultValueCreator: GetInternalCurrentFrameProperty); + + LoopingModeProperty = BindableProperty.Create(nameof(LoopingMode), typeof(LoopingModeType), typeof(LottieAnimationView), default(LoopingModeType), propertyChanged: SetInternalLoopingModeProperty, defaultValueCreator: GetInternalLoopingModeProperty); + + LoopCountProperty = BindableProperty.Create(nameof(LoopCount), typeof(int), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), 0, propertyChanged: SetInternalLoopCountProperty, defaultValueCreator: GetInternalLoopCountProperty); + + StopBehaviorProperty = BindableProperty.Create(nameof(StopBehavior), typeof(StopBehaviorType), typeof(LottieAnimationView), default(StopBehaviorType), propertyChanged: SetInternalStopBehaviorProperty, defaultValueCreator: GetInternalStopBehaviorProperty); + + RedrawInScalingDownProperty = BindableProperty.Create(nameof(RedrawInScalingDown), typeof(bool), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), false, propertyChanged: SetInternalRedrawInScalingDownProperty, defaultValueCreator: GetInternalRedrawInScalingDownProperty); + + EnableFrameCacheProperty = BindableProperty.Create(nameof(EnableFrameCache), typeof(bool), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), false, propertyChanged: SetInternalEnableFrameCacheProperty, defaultValueCreator: GetInternalEnableFrameCacheProperty); + } #region Constructor, Destructor, Dispose /// @@ -123,11 +141,25 @@ namespace Tizen.NUI.BaseComponents { get { - return GetValue(URLProperty) as string; + if (NUIApplication.IsUsingXaml) + { + return GetValue(URLProperty) as string; + } + else + { + return GetInternalURLProperty(this) as string; + } } set { - SetValue(URLProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(URLProperty, value); + } + else + { + SetInternalURLProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -349,11 +381,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (int)GetValue(CurrentFrameProperty); + if (NUIApplication.IsUsingXaml) + { + return (int)GetValue(CurrentFrameProperty); + } + else + { + return (int) GetInternalCurrentFrameProperty(this); + } } set { - SetValue(CurrentFrameProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(CurrentFrameProperty, value); + } + else + { + SetInternalCurrentFrameProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -385,11 +431,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (LoopingModeType)GetValue(LoopingModeProperty); + if (NUIApplication.IsUsingXaml) + { + return (LoopingModeType)GetValue(LoopingModeProperty); + } + else + { + return (LoopingModeType)GetInternalLoopingModeProperty(this); + } } set { - SetValue(LoopingModeProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(LoopingModeProperty, value); + } + else + { + SetInternalLoopingModeProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -438,11 +498,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (int)GetValue(LoopCountProperty); + if (NUIApplication.IsUsingXaml) + { + return (int)GetValue(LoopCountProperty); + } + else + { + return (int)GetInternalLoopCountProperty(this); + } } set { - SetValue(LoopCountProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(LoopCountProperty, value); + } + else + { + SetInternalLoopCountProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -476,11 +550,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (StopBehaviorType)GetValue(StopBehaviorProperty); + if (NUIApplication.IsUsingXaml) + { + return (StopBehaviorType)GetValue(StopBehaviorProperty); + } + else + { + return (StopBehaviorType)GetInternalStopBehaviorProperty(this); + } } set { - SetValue(StopBehaviorProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(StopBehaviorProperty, value); + } + else + { + SetInternalStopBehaviorProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -518,11 +606,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (bool)GetValue(RedrawInScalingDownProperty); + if (NUIApplication.IsUsingXaml) + { + return (bool)GetValue(RedrawInScalingDownProperty); + } + else + { + return (bool)GetInternalRedrawInScalingDownProperty(this); + } } set { - SetValue(RedrawInScalingDownProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(RedrawInScalingDownProperty, value); + } + else + { + SetInternalRedrawInScalingDownProperty(this, null, value); + } NotifyPropertyChanged(); } } @@ -554,11 +656,25 @@ namespace Tizen.NUI.BaseComponents { get { - return (bool)GetValue(EnableFrameCacheProperty); + if (NUIApplication.IsUsingXaml) + { + return (bool)GetValue(EnableFrameCacheProperty); + } + else + { + return (bool)GetInternalEnableFrameCacheProperty(this); + } } set { - SetValue(EnableFrameCacheProperty, value); + if (NUIApplication.IsUsingXaml) + { + SetValue(EnableFrameCacheProperty, value); + } + else + { + SetInternalEnableFrameCacheProperty(this, null, value); + } NotifyPropertyChanged(); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs index e0ffb3d..b82a95a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs @@ -26,126 +26,147 @@ namespace Tizen.NUI.BaseComponents /// URLProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty URLProperty = BindableProperty.Create(nameof(URL), typeof(string), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty URLProperty = null; + + internal static void SetInternalURLProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalURL = (string)newValue; } - }, - defaultValueCreator: (bindable) => + } + + internal static object GetInternalURLProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalURL; - }); + } /// /// CurrentFrameProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty CurrentFrameProperty = BindableProperty.Create(nameof(CurrentFrame), typeof(int), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), 0, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty CurrentFrameProperty = null; + + internal static void SetInternalCurrentFrameProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalCurrentFrame = (int)newValue; } - }, - defaultValueCreator: (bindable) => + } + + + internal static object GetInternalCurrentFrameProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalCurrentFrame; - }); + } /// /// LoopingModeProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty LoopingModeProperty = BindableProperty.Create(nameof(LoopingMode), typeof(LoopingModeType), typeof(LottieAnimationView), default(LoopingModeType), propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty LoopingModeProperty = null; + + internal static void SetInternalLoopingModeProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalLoopingMode = (Tizen.NUI.BaseComponents.LottieAnimationView.LoopingModeType)newValue; } - }, - defaultValueCreator: (bindable) => + } + internal static object GetInternalLoopingModeProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalLoopingMode; - }); + } /// /// LoopCountProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty LoopCountProperty = BindableProperty.Create(nameof(LoopCount), typeof(int), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), 0, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty LoopCountProperty = null; + + internal static void SetInternalLoopCountProperty(BindableObject bindable, object oldValue, object newValue) + { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalLoopCount = (int)newValue; } - }, - defaultValueCreator: (bindable) => + } + internal static object GetInternalLoopCountProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalLoopCount; - }); + } /// /// StopBehaviorProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty StopBehaviorProperty = BindableProperty.Create(nameof(StopBehavior), typeof(StopBehaviorType), typeof(LottieAnimationView), default(StopBehaviorType), propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty StopBehaviorProperty = null; + + internal static void SetInternalStopBehaviorProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalStopBehavior = (Tizen.NUI.BaseComponents.LottieAnimationView.StopBehaviorType)newValue; } - }, - defaultValueCreator: (bindable) => + } + + internal static object GetInternalStopBehaviorProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalStopBehavior; - }); + } /// /// RedrawInScalingDownProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty RedrawInScalingDownProperty = BindableProperty.Create(nameof(RedrawInScalingDown), typeof(bool), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), false, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty RedrawInScalingDownProperty = null; + + internal static void SetInternalRedrawInScalingDownProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalRedrawInScalingDown = (bool)newValue; } - }, - defaultValueCreator: (bindable) => + } + + internal static object GetInternalRedrawInScalingDownProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalRedrawInScalingDown; - }); + } /// /// EnableFrameCacheProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty EnableFrameCacheProperty = BindableProperty.Create(nameof(EnableFrameCache), typeof(bool), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), false, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty EnableFrameCacheProperty = null; + + internal static void SetInternalEnableFrameCacheProperty(BindableObject bindable, object oldValue, object newValue) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; if (newValue != null) { instance.InternalEnableFrameCache = (bool)newValue; } - }, - defaultValueCreator: (bindable) => + } + + internal static object GetInternalEnableFrameCacheProperty(BindableObject bindable) { var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalEnableFrameCache; - }); + } } } -- 2.7.4