[NUI] Fixed Svace issues
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Wearable / src / public / WearableList.cs
old mode 100644 (file)
new mode 100755 (executable)
index e7784a8..a7f4c32
@@ -1,4 +1,4 @@
-/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 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.
@@ -33,7 +33,6 @@ namespace Tizen.NUI.Wearable
         /// <summary>
         /// Default constructor.
         /// </summary>
-        /// <param name="adapter">Recycle adapter of List.</param>
         /// <since_tizen> 8 </since_tizen>
         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -41,17 +40,29 @@ namespace Tizen.NUI.Wearable
         {
             ScrollingDirection = ScrollableBase.Direction.Vertical;
 
-            ScrollDragStartEvent += OnScrollDragStart;
-            ScrollAnimationEndEvent += OnAnimationEnd;
+            ScrollDragStarted += OnScrollDragStarted;
+            ScrollAnimationEnded += OnAnimationEnded;
 
-            mContainer.PositionUsesPivotPoint = true;
-            mContainer.ParentOrigin = Tizen.NUI.ParentOrigin.Center;
-            mContainer.PivotPoint = Tizen.NUI.PivotPoint.TopCenter;
-            noticeAnimationEndBeforePosition = 50;
+            ContentContainer.PositionUsesPivotPoint = true;
+            ContentContainer.ParentOrigin = Tizen.NUI.ParentOrigin.Center;
+            ContentContainer.PivotPoint = Tizen.NUI.PivotPoint.TopCenter;
+            NoticeAnimationEndBeforePosition = 50;
 
-            ScrollAvailableArea = new Vector2( 0, mContainer.SizeHeight);
+            ScrollAvailableArea = new Vector2(0, ContentContainer.SizeHeight);
 
             SetFocus(0, false);
+
+            Scrollbar = new CircularScrollbar();
+            DecelerationThreshold = 60.0f;
+            DecelerationRate = 0.991f;
+        }
+
+        protected override void SetScrollbar()
+        {
+            if(LayoutManager != null)
+            {
+                Scrollbar.Initialize(ContentContainer.Size.Height, LayoutManager.StepSize, ContentContainer.CurrentPosition.Y, false);
+            }
         }
 
         public new RecycleAdapter Adapter
@@ -65,13 +76,13 @@ namespace Tizen.NUI.Wearable
             {
                 base.Adapter = value;
 
-                foreach (View child in mContainer.Children)
+                foreach (View child in Children)
                 {
                     child.PositionUsesPivotPoint = true;
                     child.ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter;
                 }
 
-                ScrollAvailableArea = new Vector2( 0, mContainer.SizeHeight );
+                ScrollAvailableArea = new Vector2( 0, ContentContainer.SizeHeight );
             }
         }
 
@@ -84,7 +95,12 @@ namespace Tizen.NUI.Wearable
         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
         public void SetFocus(int dataIndex, bool animated)
         {
-            foreach (RecycleItem item in mContainer.Children)
+            if (LayoutManager == null)
+            {
+                return;
+            }
+
+            foreach (RecycleItem item in Children)
             {
                 if (item.DataIndex == dataIndex)
                 {
@@ -93,12 +109,12 @@ namespace Tizen.NUI.Wearable
                     FocusedItem = item;
                     FocusedItem.OnFocusGained();
 
-                    ScrollTo(item.DataIndex * mLayoutManager.StepSize, animated);
+                    ScrollTo(item.DataIndex * LayoutManager.StepSize, animated);
                 }
             }
         }
 
-        private void OnAnimationEnd(object source, ScrollableBase.ScrollEventArgs args)
+        private void OnAnimationEnded(object source, ScrollEventArgs args)
         {
         }
 
@@ -110,11 +126,19 @@ namespace Tizen.NUI.Wearable
         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
         protected override void OnPreReachedTargetPosition(float targetPosition)
         {
-            int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / mLayoutManager.StepSize);
+            if (LayoutManager == null)
+            {
+                return;
+            }
+            int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / LayoutManager.StepSize);
 
-            for (int i = 0; i < mContainer.Children.Count; i++)
+            for (int i = 0; i < Children.Count; i++)
             {
-                RecycleItem item = mContainer.Children[i] as RecycleItem;
+                RecycleItem item = Children[i] as RecycleItem;
+                if (item == null)
+                {
+                    continue;
+                }
 
                 if (targetDataIndex == item.DataIndex)
                 {
@@ -125,7 +149,7 @@ namespace Tizen.NUI.Wearable
             }
         }
 
-        private void OnScrollDragStart(object source, ScrollableBase.ScrollEventArgs args)
+        private void OnScrollDragStarted(object source, ScrollEventArgs args)
         {
             RecycleItem prevFocusedItem = FocusedItem;
             prevFocusedItem?.OnFocusLost();