From 3b1ddc955372f181957bd55ddbebf52dcb91a3da Mon Sep 17 00:00:00 2001 From: seungho Date: Mon, 18 Oct 2021 14:42:14 +0900 Subject: [PATCH] [NUI] refactoring visual actions Signed-off-by: seungho --- src/Tizen.NUI.Components/Controls/Loading.cs | 27 ++++++++---- .../internal/Interop/Interop.AnimatedImageView.cs | 36 +++++++++++++++ .../src/internal/Interop/Interop.ImageView.cs | 32 +------------- .../Interop/Interop.LottieAnimationView.cs | 36 +++++++++++++++ .../src/internal/Interop/Interop.Visual.cs | 3 ++ .../src/public/BaseComponents/AnimatedImageView.cs | 51 +++++++++++----------- .../src/public/BaseComponents/ImageView.cs | 35 +++++++++++---- .../public/BaseComponents/LottieAnimationView.cs | 34 ++++++++------- 8 files changed, 165 insertions(+), 89 deletions(-) create mode 100755 src/Tizen.NUI/src/internal/Interop/Interop.AnimatedImageView.cs create mode 100755 src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs diff --git a/src/Tizen.NUI.Components/Controls/Loading.cs b/src/Tizen.NUI.Components/Controls/Loading.cs index 1d01a18..383e34a 100755 --- a/src/Tizen.NUI.Components/Controls/Loading.cs +++ b/src/Tizen.NUI.Components/Controls/Loading.cs @@ -81,12 +81,21 @@ namespace Tizen.NUI.Components private AnimatedImageVisual imageVisual = null; private int frameRate = (int)(1000 / 16.6f); - internal new class Property - { - internal static readonly int ActionPlay = Interop.ImageView.ImageVisualActionPlayGet(); - internal static readonly int ActionPause = Interop.ImageView.ImageVisualActionPauseGet(); - internal static readonly int ActionStop = Interop.ImageView.ImageVisualActionStopGet(); - } + + /// + /// Actions value to Play animated images. + /// + private static int ActionPlay = Interop.AnimatedImageView.AnimatedImageVisualActionPlayGet(); + + /// + /// Actions value to Pause animated images. + /// + private static int ActionPause = Interop.AnimatedImageView.AnimatedImageVisualActionPauseGet(); + + /// + /// Actions value to Stop animated images. + /// + private static int ActionStop = Interop.AnimatedImageView.AnimatedImageVisualActionStopGet(); static Loading() { } @@ -270,7 +279,7 @@ namespace Tizen.NUI.Components public void Play() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(imageVisual.VisualIndex, Property.ActionPlay, attributes); + this.DoAction(imageVisual.VisualIndex, ActionPlay, attributes); attributes.Dispose(); } @@ -282,7 +291,7 @@ namespace Tizen.NUI.Components public void Pause() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(imageVisual.VisualIndex, Property.ActionPause, attributes); + this.DoAction(imageVisual.VisualIndex, ActionPause, attributes); attributes.Dispose(); } @@ -294,7 +303,7 @@ namespace Tizen.NUI.Components public void Stop() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(imageVisual.VisualIndex, Property.ActionStop, attributes); + this.DoAction(imageVisual.VisualIndex, ActionStop, attributes); attributes.Dispose(); } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.AnimatedImageView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.AnimatedImageView.cs new file mode 100755 index 0000000..0573313 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.AnimatedImageView.cs @@ -0,0 +1,36 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class AnimatedImageView + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedImageVisual_Actions_PLAY_get")] + public static extern int AnimatedImageVisualActionPlayGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedImageVisual_Actions_PAUSE_get")] + public static extern int AnimatedImageVisualActionPauseGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedImageVisual_Actions_STOP_get")] + public static extern int AnimatedImageVisualActionStopGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedImageVisual_Actions_JUMP_TO_get")] + public static extern int AnimatedImageVisualActionJumpToGet(); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs index 7455fd4..d482247 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs @@ -77,18 +77,9 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_SWIGUpcast")] public static extern global::System.IntPtr Upcast(global::System.IntPtr jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_RELOAD_get")] + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageVisual_Actions_RELOAD_get")] public static extern int ImageVisualActionReloadGet(); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_PLAY_get")] - public static extern int ImageVisualActionPlayGet(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_PAUSE_get")] - public static extern int ImageVisualActionPauseGet(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_STOP_get")] - public static extern int ImageVisualActionStopGet(); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_New__SWIG_0")] public static extern global::System.IntPtr ImageView_New__SWIG_0(); @@ -109,27 +100,6 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_ImageView")] public static extern void delete_ImageView(global::System.Runtime.InteropServices.HandleRef jarg1); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_IMAGE_get")] - public static extern int ImageView_Property_IMAGE_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_PRE_MULTIPLIED_ALPHA_get")] - public static extern int ImageView_Property_PRE_MULTIPLIED_ALPHA_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_PIXEL_AREA_get")] - public static extern int ImageView_Property_PIXEL_AREA_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_RELOAD_get")] - public static extern int ImageView_IMAGE_VISUAL_ACTION_RELOAD_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_PLAY_get")] - public static extern int ImageView_IMAGE_VISUAL_ACTION_PLAY_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_PAUSE_get")] - public static extern int ImageView_IMAGE_VISUAL_ACTION_PAUSE_get(); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_STOP_get")] - public static extern int ImageView_IMAGE_VISUAL_ACTION_STOP_get(); } } } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs new file mode 100755 index 0000000..09c5f39 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs @@ -0,0 +1,36 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class LottieAnimationView + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_PLAY_get")] + public static extern int AnimatedVectorImageVisualActionPlayGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_PAUSE_get")] + public static extern int AnimatedVectorImageVisualActionPauseGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_STOP_get")] + public static extern int AnimatedVectorImageVisualActionStopGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_JUMP_TO_get")] + public static extern int AnimatedVectorImageVisualActionJumpToGet(); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Visual.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Visual.cs index 89dcc19..324b724 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Visual.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Visual.cs @@ -32,6 +32,9 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Image_Visual_BORDER_get")] public static extern int ImageVisualBorderGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Visual_Actions_UPDATE_PROPERTY_get")] + public static extern int GetActionUpdateProperty(); } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs index 27b1caa..8c3f805 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs @@ -27,6 +27,21 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public class AnimatedImageView : ImageView { + #region Internal + #endregion Internal + + #region Private + private string url = ""; + private List resourceURLs = new List(); + private int batchSize = 1; + private int cacheSize = 1; + private int frameDelay = 0; + private int loopCount = -1; + private bool dirtyFlag = false; + private StopBehaviorType stopBehavior; + private PropertyMap propertyMap; + #endregion Private + #region Constructor, Destructor, Dispose /// /// Construct AnimatedImageView @@ -35,6 +50,10 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public AnimatedImageView() : base() { + ActionPlay = Interop.AnimatedImageView.AnimatedImageVisualActionPlayGet(); + ActionPause = Interop.AnimatedImageView.AnimatedImageVisualActionPauseGet(); + ActionStop = Interop.AnimatedImageView.AnimatedImageVisualActionStopGet(); + dirtyFlag = true; } @@ -225,7 +244,7 @@ namespace Tizen.NUI.BaseComponents { set { - DoAction(ImageView.Property.IMAGE, (int)ActionType.jumpTo, new PropertyValue(value)); + DoAction(ImageView.Property.IMAGE, ActionJumpTo, new PropertyValue(value)); } get { @@ -245,6 +264,12 @@ namespace Tizen.NUI.BaseComponents return ret; } } + + /// + /// Actions property value to Jump to the specified frame. + /// This property can be redefined by child class if it use different value. + /// + protected internal int ActionJumpTo { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionJumpToGet(); #endregion Property #region Method @@ -375,30 +400,6 @@ namespace Tizen.NUI.BaseComponents MaximumFrame } - private enum ActionType - { - play, - pause, - stop, - jumpTo, - }; #endregion Event, Enum, Struct, ETC - - - #region Internal - #endregion Internal - - - #region Private - private string url = ""; - private List resourceURLs = new List(); - private int batchSize = 1; - private int cacheSize = 1; - private int frameDelay = 0; - private int loopCount = -1; - private bool dirtyFlag = false; - private StopBehaviorType stopBehavior; - private PropertyMap propertyMap; - #endregion Private } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index d7001fc..5515ceb 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -768,7 +768,7 @@ namespace Tizen.NUI.BaseComponents public void Reload() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(ImageView.Property.IMAGE, Property.ActionReload, attributes); + this.DoAction(ImageView.Property.IMAGE, ActionReload, attributes); attributes?.Dispose(); } @@ -779,7 +779,7 @@ namespace Tizen.NUI.BaseComponents public void Play() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(ImageView.Property.IMAGE, Property.ActionPlay, attributes); + this.DoAction(ImageView.Property.IMAGE, ActionPlay, attributes); attributes?.Dispose(); } @@ -790,7 +790,7 @@ namespace Tizen.NUI.BaseComponents public void Pause() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(ImageView.Property.IMAGE, Property.ActionPause, attributes); + this.DoAction(ImageView.Property.IMAGE, ActionPause, attributes); attributes?.Dispose(); } @@ -801,7 +801,7 @@ namespace Tizen.NUI.BaseComponents public void Stop() { PropertyValue attributes = new PropertyValue(0); - this.DoAction(ImageView.Property.IMAGE, Property.ActionStop, attributes); + this.DoAction(ImageView.Property.IMAGE, ActionStop, attributes); attributes?.Dispose(); } @@ -874,6 +874,29 @@ namespace Tizen.NUI.BaseComponents } } + /// + /// Actions property value for Reload image. + /// + private int ActionReload { get; set; } = Interop.ImageView.ImageVisualActionReloadGet(); + + /// + /// Actions property value to Play animated images. + /// This property can be redefined by child class if it use different value. + /// + protected internal int ActionPlay { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionPlayGet(); + + /// + /// Actions property value to Pause animated images. + /// This property can be redefined by child class if it use different value. + /// + protected internal int ActionPause { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionPauseGet(); + + /// + /// Actions property value to Stop animated images. + /// This property can be redefined by child class if it use different value. + /// + protected internal int ActionStop { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionStopGet(); + internal VisualFittingModeType ConvertFittingModetoVisualFittingMode(FittingModeType value) { switch (value) @@ -1492,10 +1515,6 @@ namespace Tizen.NUI.BaseComponents internal static readonly int IMAGE = Interop.ImageView.ImageGet(); internal static readonly int PreMultipliedAlpha = Interop.ImageView.PreMultipliedAlphaGet(); internal static readonly int PixelArea = Interop.ImageView.PixelAreaGet(); - internal static readonly int ActionReload = Interop.ImageView.ImageVisualActionReloadGet(); - internal static readonly int ActionPlay = Interop.ImageView.ImageVisualActionPlayGet(); - internal static readonly int ActionPause = Interop.ImageView.ImageVisualActionPauseGet(); - internal static readonly int ActionStop = Interop.ImageView.ImageVisualActionStopGet(); } private enum ImageType diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 74892df..02eed29 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -48,6 +48,10 @@ namespace Tizen.NUI.BaseComponents /// 7 public LottieAnimationView(float scale = 1.0f, bool shown = true) : base() { + ActionPlay = Interop.LottieAnimationView.AnimatedVectorImageVisualActionPlayGet(); + ActionPause = Interop.LottieAnimationView.AnimatedVectorImageVisualActionPauseGet(); + ActionStop = Interop.LottieAnimationView.AnimatedVectorImageVisualActionStopGet(); + NUILog.Debug($"< constructor GetId={GetId()} >"); currentStates.url = ""; currentStates.frame = -1; @@ -231,7 +235,7 @@ namespace Tizen.NUI.BaseComponents { currentStates.frame = value; NUILog.Debug($"<[{GetId()}]SET frame={currentStates.frame}>"); - DoAction(ImageView.Property.IMAGE, (int)actionType.jumpTo, new PropertyValue(currentStates.frame)); + DoAction(ImageView.Property.IMAGE, ActionJumpTo, new PropertyValue(currentStates.frame)); } get { @@ -268,7 +272,7 @@ namespace Tizen.NUI.BaseComponents NUILog.Debug($"<[{GetId()}] SET loopMode={currentStates.loopMode}>"); PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); } get { @@ -325,7 +329,7 @@ namespace Tizen.NUI.BaseComponents NUILog.Debug($"<[{GetId()}]SET currentStates.loopCount={currentStates.loopCount}>"); PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); } get { @@ -368,7 +372,7 @@ namespace Tizen.NUI.BaseComponents NUILog.Debug($"<[{GetId()}]SET val={currentStates.stopEndAction}>"); PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); } get { @@ -414,7 +418,7 @@ namespace Tizen.NUI.BaseComponents NUILog.Debug($"<[{GetId()}]SET currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>"); PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); } get { @@ -440,6 +444,13 @@ namespace Tizen.NUI.BaseComponents return currentStates.redrawInScalingDown; } } + + + /// + /// Actions property value to Jump to the specified frame. + /// This property can be redefined by child class if it use different value. + /// + protected internal int ActionJumpTo { get; set; } = Interop.LottieAnimationView.AnimatedVectorImageVisualActionJumpToGet(); #endregion Property @@ -464,7 +475,7 @@ namespace Tizen.NUI.BaseComponents PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.PlayRange, new PropertyValue(array)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); NUILog.Debug($" [{GetId()}] currentStates.min:({currentStates.framePlayRangeMin}, max:{currentStates.framePlayRangeMax})>"); } @@ -578,7 +589,7 @@ namespace Tizen.NUI.BaseComponents PropertyMap map = new PropertyMap(); map.Add(ImageVisualProperty.PlayRange, new PropertyValue(array)); - DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map)); + DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map)); NUILog.Debug($" [{GetId()}] currentStates.mark1:{currentStates.mark1}, mark2:{currentStates.mark2} >"); } @@ -804,15 +815,6 @@ namespace Tizen.NUI.BaseComponents }; private states currentStates; - private enum actionType - { - play, - pause, - stop, - jumpTo, - updateProperty, - }; - private struct DevelVisual { internal enum Type -- 2.7.4