[ACR-564] deprecate unused API
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Wearable / src / public / WearableList.cs
1 /* Copyright (c) 2020 Samsung Electronics Co., Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  */
16 using System;
17 using Tizen.NUI.BaseComponents;
18 using Tizen.NUI.Components;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI.Wearable
22 {
23     /// <summary>
24     /// [Draft] This class provides a list view styled by wearable ux.
25     /// List will lay out all items with Fish-Eye layout manager.
26     /// </summary>
27     [Obsolete("This has been deprecated in API12")]
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class WearableList : RecyclerView
30     {
31         private RecycleItem FocusedItem = null;
32
33         /// <summary>
34         /// Default constructor.
35         /// </summary>
36         /// <since_tizen> 8 </since_tizen>
37         [Obsolete("This has been deprecated in API12")]
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public WearableList() : base(new RecycleAdapter(), new FishEyeLayoutManager())
40         {
41             ScrollingDirection = ScrollableBase.Direction.Vertical;
42
43             ScrollDragStarted += OnScrollDragStarted;
44             ScrollAnimationEnded += OnAnimationEnded;
45
46             ContentContainer.PositionUsesPivotPoint = true;
47             ContentContainer.ParentOrigin = Tizen.NUI.ParentOrigin.Center;
48             ContentContainer.PivotPoint = Tizen.NUI.PivotPoint.TopCenter;
49             NoticeAnimationEndBeforePosition = 50;
50
51             ScrollAvailableArea = new Vector2(0, ContentContainer.SizeHeight);
52
53             SetFocus(0, false);
54
55             Scrollbar = new CircularScrollbar();
56             DecelerationThreshold = 60.0f;
57             DecelerationRate = 0.991f;
58         }
59
60         /// <inheritdoc/>
61         [Obsolete("This has been deprecated in API12")]
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         protected override void SetScrollbar()
64         {
65             if(LayoutManager != null)
66             {
67                 Scrollbar.Initialize(ContentContainer.Size.Height, LayoutManager.StepSize, ContentContainer.CurrentPosition.Y, false);
68             }
69         }
70
71         /// <inheritdoc/>
72         [Obsolete("This has been deprecated in API12")]
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public new RecycleAdapter Adapter
75         {
76             get
77             {
78                 return base.Adapter;
79             }
80
81             set
82             {
83                 base.Adapter = value;
84
85                 foreach (View child in Children)
86                 {
87                     child.PositionUsesPivotPoint = true;
88                     child.ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter;
89                 }
90
91                 ScrollAvailableArea = new Vector2( 0, ContentContainer.SizeHeight );
92             }
93         }
94
95         /// <summary>
96         /// Set focus to item which has specific data index.
97         /// </summary>
98         /// <param name="dataIndex">Data index of item.</param>
99         /// <param name="animated">If set true, scroll to item using animation.</param>
100         /// <since_tizen> 8 </since_tizen>
101         [Obsolete("This has been deprecated in API12")]
102         public void SetFocus(int dataIndex, bool animated)
103         {
104             if (LayoutManager == null)
105             {
106                 return;
107             }
108
109             foreach (RecycleItem item in Children)
110             {
111                 if (item.DataIndex == dataIndex)
112                 {
113                     RecycleItem prevFocusedItem = FocusedItem;
114                     prevFocusedItem?.OnFocusLost();
115                     FocusedItem = item;
116                     FocusedItem.OnFocusGained();
117
118                     ScrollTo(item.DataIndex * LayoutManager.StepSize, animated);
119                 }
120             }
121         }
122
123         private void OnAnimationEnded(object source, ScrollEventArgs args)
124         {
125         }
126
127         /// <summary>
128         /// This helps developer who wants to know before scroll is reaching target position.
129         /// </summary>
130         /// <param name="targetPosition">Index of item.</param>
131         /// <since_tizen> 8 </since_tizen>
132         [Obsolete("This has been deprecated in API12")]
133         protected override void OnPreReachedTargetPosition(float targetPosition)
134         {
135             if (LayoutManager == null)
136             {
137                 return;
138             }
139             int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / LayoutManager.StepSize);
140
141             for (int i = 0; i < Children.Count; i++)
142             {
143                 RecycleItem item = Children[i] as RecycleItem;
144                 if (item == null)
145                 {
146                     continue;
147                 }
148
149                 if (targetDataIndex == item.DataIndex)
150                 {
151                     FocusedItem = item;
152                     item.OnFocusGained();
153                     break;
154                 }
155             }
156         }
157
158         private void OnScrollDragStarted(object source, ScrollEventArgs args)
159         {
160             RecycleItem prevFocusedItem = FocusedItem;
161             prevFocusedItem?.OnFocusLost();
162         }
163     }
164 }