[NUI] Refactoring Theme and StyleManager (#1981)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / LoadingStyle.cs
index 08f757c..e6ce60b 100755 (executable)
@@ -26,6 +26,43 @@ namespace Tizen.NUI.Components
     /// <since_tizen> 8 </since_tizen>
     public class LoadingStyle : ControlStyle
     {
+        /// <summary>The FrameRateSelector bindable property.</summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty FrameRateSelectorProperty = BindableProperty.Create("FrameRateSelector", typeof(Selector<int?>), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            ((LoadingStyle)bindable).frameRate = ((Selector<int?>)newValue)?.Clone();
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            return ((LoadingStyle)bindable).frameRate;
+        });
+
+        /// <summary>The LoadingSize bindable property.</summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty LoadingSizeProperty = BindableProperty.Create(nameof(LoadingSize), typeof(Size), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            ((LoadingStyle)bindable).loadingSize = newValue == null ? null : new Size((Size)newValue);
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            return ((LoadingStyle)bindable).loadingSize;
+        });
+
+        /// <summary>The Images bindable property.</summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty ImagesProperty = BindableProperty.Create(nameof(Images), typeof(string[]), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            ((LoadingStyle)bindable).images = (string[])((string[])newValue)?.Clone();
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            return ((LoadingStyle)bindable).images;
+        });
+
+        private Selector<int?> frameRate;
+        private Size loadingSize;
+        private string[] images;
+
         static LoadingStyle() { }
 
         /// <summary>
@@ -41,30 +78,37 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         public LoadingStyle(LoadingStyle style) : base(style)
         {
-            if(null == style)
-            {
-                return;
-            }
-            this.CopyFrom(style);
         }
 
         /// <summary>
         /// Gets or sets loading image resources.
         /// </summary>
         /// <since_tizen> 8 </since_tizen>
-        public string[] Images { get; set; }
+        public string[] Images
+        {
+            get => (string[])GetValue(ImagesProperty);
+            set => SetValue(ImagesProperty, value);
+        }
 
         /// <summary>
         /// Gets or sets loading image size.
         /// </summary>
         /// <since_tizen> 8 </since_tizen>
-        public Size LoadingSize { get; set; }
+        public Size LoadingSize
+        {
+            get => (Size)GetValue(LoadingSizeProperty);
+            set => SetValue(LoadingSizeProperty, value);
+        }
 
         /// <summary>
         /// Gets or sets loading frame per second.
         /// </summary>
         /// <since_tizen> 8 </since_tizen>
-        public Selector<int?> FrameRate { get; set; } = new Selector<int?>();
+        public Selector<int?> FrameRate
+        {
+            get => (Selector<int?>)GetValue(FrameRateSelectorProperty);
+            set => SetValue(FrameRateSelectorProperty, value);
+        }
 
         /// <summary>
         /// Style's clone function.
@@ -74,24 +118,6 @@ namespace Tizen.NUI.Components
         public override void CopyFrom(BindableObject bindableObject)
         {
             base.CopyFrom(bindableObject);
-
-            LoadingStyle loadingStyle = bindableObject as LoadingStyle;
-
-            if (null != loadingStyle)
-            {
-                if (null != loadingStyle.FrameRate)
-                {
-                    FrameRate?.Clone(loadingStyle.FrameRate);
-                }
-                if (null != loadingStyle.LoadingSize)
-                {
-                    LoadingSize = loadingStyle.LoadingSize;
-                }
-                if (null != loadingStyle.Images)
-                {
-                    Images = loadingStyle.Images;
-                }
-            }
         }
     }
 }