[NUI] refactoring visual actions
authorseungho <sbsh.baek@samsung.com>
Mon, 18 Oct 2021 05:42:14 +0000 (14:42 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 1 Nov 2021 06:46:10 +0000 (15:46 +0900)
Signed-off-by: seungho <sbsh.baek@samsung.com>
src/Tizen.NUI.Components/Controls/Loading.cs
src/Tizen.NUI/src/internal/Interop/Interop.AnimatedImageView.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs
src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/Interop/Interop.Visual.cs
src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index 1d01a18..383e34a 100755 (executable)
@@ -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();
-        }
+
+        /// <summary>
+        /// Actions value to Play animated images.
+        /// </summary>
+        private static int ActionPlay = Interop.AnimatedImageView.AnimatedImageVisualActionPlayGet();
+
+        /// <summary>
+        /// Actions value to Pause animated images.
+        /// </summary>
+        private static int ActionPause = Interop.AnimatedImageView.AnimatedImageVisualActionPauseGet();
+
+        /// <summary>
+        /// Actions value to Stop animated images.
+        /// </summary>
+        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 (executable)
index 0000000..0573313
--- /dev/null
@@ -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();
+        }
+    }
+}
index 7455fd4..d482247 100755 (executable)
@@ -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 (executable)
index 0000000..09c5f39
--- /dev/null
@@ -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();
+        }
+    }
+}
index 89dcc19..324b724 100755 (executable)
@@ -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();
         }
     }
 }
index 27b1caa..8c3f805 100755 (executable)
@@ -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<string> resourceURLs = new List<string>();
+        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
         /// <summary>
         /// 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;
             }
         }
+
+        /// <summary>
+        /// Actions property value to Jump to the specified frame.
+        /// This property can be redefined by child class if it use different value.
+        /// </summary>
+        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<string> resourceURLs = new List<string>();
-        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
     }
 }
index d7001fc..5515ceb 100755 (executable)
@@ -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
             }
         }
 
+        /// <summary>
+        /// Actions property value for Reload image.
+        /// </summary>
+        private int ActionReload { get; set; } = Interop.ImageView.ImageVisualActionReloadGet();
+
+        /// <summary>
+        /// Actions property value to Play animated images.
+        /// This property can be redefined by child class if it use different value.
+        /// </summary>
+        protected internal int ActionPlay { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionPlayGet();
+
+        /// <summary>
+        /// Actions property value to Pause animated images.
+        /// This property can be redefined by child class if it use different value.
+        /// </summary>
+        protected internal int ActionPause { get; set; } = Interop.AnimatedImageView.AnimatedImageVisualActionPauseGet();
+
+        /// <summary>
+        /// Actions property value to Stop animated images.
+        /// This property can be redefined by child class if it use different value.
+        /// </summary>
+        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
index 74892df..02eed29 100755 (executable)
@@ -48,6 +48,10 @@ namespace Tizen.NUI.BaseComponents
         /// <since_tizen> 7 </since_tizen>
         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;
             }
         }
+
+
+        /// <summary>
+        /// Actions property value to Jump to the specified frame.
+        /// This property can be redefined by child class if it use different value.
+        /// </summary>
+        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