From: Eunki Hong Date: Tue, 14 Nov 2023 15:39:16 +0000 (+0900) Subject: [NUI] Remove old frame range if we set marker + Minor fix up when marker invalid X-Git-Tag: accepted/tizen/8.0/unified/20240613.065534~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a72833a18a410c982901ca592f08ff4fb665da9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Remove old frame range if we set marker + Minor fix up when marker invalid LottieAnimationView cache both frame range as int, and marker. But two API set same property - PlayRange. So if some code like below thing was not working well ``` // Let "marker" frame range is 10~20 lottieView.SetMinMaxFrame(30, 40); // play range become 30~40 lottieView.SetMinMaxFrameByMarker(marker); // play range become 10~20 lottieView.SetMinMaxFrame(30, 40); // play range need to be 30~40 again, but it didn't due to the cache. ``` To avoid like above case, let we clean cache explicit parameter. Also, Let we add some more error check if app use invalid marker (Lottie file not loaded, or marker is invalid.) In this case, let we just follow minMaxSetTypes.NotSetByUser logic then. Signed-off-by: Eunki Hong --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs index 1edac88..d285024 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs @@ -179,6 +179,7 @@ namespace Tizen.NUI.BaseComponents /// /// TotalFrame of animation. + /// If resouce is still not be loaded, or invalid resource, the value is 0. /// [EditorBrowsable(EditorBrowsableState.Never)] public new int TotalFrame @@ -318,6 +319,10 @@ namespace Tizen.NUI.BaseComponents maximumFrame = (maxFrame) > 0 ? maxFrame : 0; isMinMaxFrameSet = minMaxSetTypes.SetByMinAndMaxFrameMethod; + // Remove marker information. + minimumFrameMarker = null; + maximumFrameMarker = null; + if (minimumFrame > maximumFrame) { NUILog.Debug($" [{GetId()}] minimumFrame:{minimumFrame} > maximumFrame:{maximumFrame}) ]AnimatedVectorImageView END]"); @@ -332,6 +337,10 @@ namespace Tizen.NUI.BaseComponents /// Animation will play between the start frame and the end frame of the marker if one marker is specified. /// Or animation will play between the start frame of the first marker and the end frame of the second marker if two markers are specified. /// + /// + /// If we use invaliad markers, or we load image asynchronous and load is not finished yet, + /// CurrentFrame might not be matched with real value. + /// /// First marker /// Second marker [EditorBrowsable(EditorBrowsableState.Never)] @@ -343,6 +352,10 @@ namespace Tizen.NUI.BaseComponents maximumFrameMarker = marker2; isMinMaxFrameSet = minMaxSetTypes.SetByMinAndMaxFrameByMarkerMethod; + // Remove frame information. + minimumFrame = -1; + maximumFrame = -1; + NUILog.Debug($" [{GetId()}] minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker}) ]AnimatedVectorImageView END]"); } @@ -360,6 +373,10 @@ namespace Tizen.NUI.BaseComponents maximumFrame = (maxFrame) > 0 ? maxFrame : 0; isMinMaxFrameSet = minMaxSetTypes.SetByBaseSetMinMaxFrameMethod; + // Remove marker information. + minimumFrameMarker = null; + maximumFrameMarker = null; + if (minimumFrame >= totalFrameNum) { minimumFrame = totalFrameNum - 1; @@ -384,7 +401,15 @@ namespace Tizen.NUI.BaseComponents public new void SetMinMaxFrameByMarker(string marker1, string marker2 = null) { NUILog.Debug($"SetMinMaxFrameByMarker({marker1}, {marker2})"); + + minimumFrameMarker = marker1; + maximumFrameMarker = marker2; isMinMaxFrameSet = minMaxSetTypes.SetByMarker; + + // Remove frame information. + minimumFrame = -1; + maximumFrame = -1; + base.SetMinMaxFrameByMarker(marker1, marker2); } @@ -416,6 +441,12 @@ namespace Tizen.NUI.BaseComponents base.CurrentFrame = minimumFrame; innerCurrentFrame = minimumFrame; } + else + { + Tizen.Log.Error("NUI", $"[Warning] Play with invalid marker! Current frame become 0\n"); + base.CurrentFrame = 0; + innerCurrentFrame = 0; + } break; case minMaxSetTypes.SetByMinAndMaxFrameMethod: @@ -522,8 +553,28 @@ namespace Tizen.NUI.BaseComponents break; case minMaxSetTypes.SetByMinAndMaxFrameByMarkerMethod: - GetFrameValueFromMarkerInfo(); - goto case minMaxSetTypes.SetByMinAndMaxFrameMethod; + if (GetFrameValueFromMarkerInfo()) + { + goto case minMaxSetTypes.SetByMinAndMaxFrameMethod; + } + else + { + switch (endAction) + { + case EndActions.Cancel: + innerCurrentFrame = base.CurrentFrame; + break; + case EndActions.Discard: + Tizen.Log.Error("NUI", $"[Warning] Stop(Discard) with invalid marker! Current frame become 0\n"); + base.CurrentFrame = innerCurrentFrame = 0; + break; + case EndActions.StopFinal: + Tizen.Log.Error("NUI", $"[Warning] Stop(StopFinal) with invalid marker! Current frame become {totalFrameNum - 1}\n"); + base.CurrentFrame = innerCurrentFrame = totalFrameNum - 1; + break; + } + break; + } case minMaxSetTypes.SetByMinAndMaxFrameMethod: switch (endAction) @@ -630,7 +681,7 @@ namespace Tizen.NUI.BaseComponents { if (markerInfo.Item1 == minimumFrameMarker) { - if (maximumFrameMarker == null) + if (string.IsNullOrEmpty(maximumFrameMarker)) { minimumMarkerFoundSuccess = true; maximumMarkerFoundSuccess = true; @@ -662,16 +713,14 @@ namespace Tizen.NUI.BaseComponents } // Note : let we insure to get marker frame value only one time per each frame marker setter - minimumFrameMarker = maximumFrameMarker = null; + minimumFrameMarker = null; + maximumFrameMarker = null; isMinMaxFrameSet = minMaxSetTypes.SetByMinAndMaxFrameMethod; return true; } else { Tizen.Log.Error("NUI", $"Fail to get frame from marker = (minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker}). Maybe file is not loaded yet, or invalid marker used. url : {resourceUrl}\n"); - - minimumFrame = 0; - maximumFrame = totalFrameNum - 1; NUILog.Debug($" [{GetId()}] GetFrameValueFromMarkerInfo Failed! frame set as {minimumFrame} ~ {maximumFrame} : marker = (minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker})"); return false; } diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index d261e56..1ffaded 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -288,7 +288,8 @@ namespace Tizen.NUI.BaseComponents } /// - /// Get the number of total frames + /// Get the number of total frames. + /// If resouce is still not be loaded, or invalid resource, the value is 0. /// /// 7 public int TotalFrame @@ -552,6 +553,10 @@ namespace Tizen.NUI.BaseComponents currentStates.framePlayRangeMin = minFrame; currentStates.framePlayRangeMax = maxFrame; + // Remove marker information. + currentStates.mark1 = null; + currentStates.mark2 = null; + Interop.View.InternalUpdateVisualPropertyIntPair(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayRange, currentStates.framePlayRangeMin, currentStates.framePlayRangeMax); NUILog.Debug($" [{GetId()}] currentStates.min:({currentStates.framePlayRangeMin}, max:{currentStates.framePlayRangeMax})>"); @@ -714,7 +719,7 @@ namespace Tizen.NUI.BaseComponents /// /// A marker has its start frame and end frame. /// Animation will play between the start frame and the end frame of the marker if one marker is specified. - /// Or animation will play between the start frame of the first marker and the end frame of the second marker if two markers are specified. * + /// Or animation will play between the start frame of the first marker and the end frame of the second marker if two markers are specified. /// /// First marker /// Second marker @@ -722,14 +727,19 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetMinMaxFrameByMarker(string marker1, string marker2 = null) { - if (currentStates.mark1 != marker1 || currentStates.mark2 != marker2) + string marker1OrEmpty = marker1 ?? ""; // mark1 should not be null + if (currentStates.mark1 != marker1OrEmpty || currentStates.mark2 != marker2) { - NUILog.Debug($"< [{GetId()}] SetMinMaxFrameByMarker({marker1}, {marker2})"); + NUILog.Debug($"< [{GetId()}] SetMinMaxFrameByMarker({marker1OrEmpty}, {marker2})"); currentStates.changed = true; - currentStates.mark1 = marker1; + currentStates.mark1 = marker1OrEmpty; currentStates.mark2 = marker2; + // Remove frame information. + currentStates.framePlayRangeMin = -1; + currentStates.framePlayRangeMax = -1; + if (string.IsNullOrEmpty(currentStates.mark2)) { Interop.View.InternalUpdateVisualPropertyString(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayRange, currentStates.mark1);