[NUI] Fix CircularPagination bugs (#1744)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Wearable / src / public / WearableStyle / CircularPaginationStyle.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.Components;
21
22 namespace Tizen.NUI.Wearable
23 {
24     /// <summary>
25     /// CircularPaginationStyle used to config the circularPagination represent.
26     /// </summary>
27     /// <since_tizen> 8 </since_tizen>
28     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class CircularPaginationStyle : ControlStyle
31     {
32         static CircularPaginationStyle() { }
33
34         /// <summary>
35         /// Creates a new instance of a CircularPaginationStyle.
36         /// </summary>
37         /// <since_tizen> 8 </since_tizen>
38         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
39         [EditorBrowsable(EditorBrowsableState.Never)]
40         public CircularPaginationStyle() : base()
41         {
42             Initialize();
43         }
44
45         /// <summary>
46         /// Creates a new instance of a CircularPaginationStyle using style.
47         /// </summary>
48         /// <since_tizen> 8 </since_tizen>
49         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         public CircularPaginationStyle(CircularPaginationStyle style) : base(style)
52         {
53             if (null == style) return;
54
55             this.CopyFrom(style);
56         }
57
58         /// <summary>
59         /// Gets or sets the size of the indicator.
60         /// </summary>
61         /// <since_tizen> 8 </since_tizen>
62         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
63         [EditorBrowsable(EditorBrowsableState.Never)]
64         public Size IndicatorSize { get; set; }
65
66         /// <summary>
67         /// Gets or sets the resource of indicator.
68         /// </summary>
69         /// <since_tizen> 8 </since_tizen>
70         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         public Selector<string> IndicatorImageURL { get; set; } = new Selector<string>();
73
74         /// <summary>
75         /// Gets or sets the resource of the center indicator.
76         /// </summary>
77         /// <since_tizen> 8 </since_tizen>
78         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public Selector<string> CenterIndicatorImageURL { get; set; } = new Selector<string>();
81
82         /// <summary>
83         /// Retrieves a copy of CircularPaginationStyle.
84         /// </summary>
85         /// <since_tizen> 8 </since_tizen>
86         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
87         [EditorBrowsable(EditorBrowsableState.Never)]
88         public override void CopyFrom(BindableObject bindableObject)
89         {
90             base.CopyFrom(bindableObject);
91
92             CircularPaginationStyle circularPaginationStyle = bindableObject as CircularPaginationStyle;
93             if (null != circularPaginationStyle)
94             {
95                 if (null != circularPaginationStyle.IndicatorSize)
96                 {
97                     IndicatorSize = new Size(circularPaginationStyle.IndicatorSize.Width, circularPaginationStyle.IndicatorSize.Height);
98                 }
99                 if (null != circularPaginationStyle.IndicatorImageURL)
100                 {
101                     IndicatorImageURL?.Clone(circularPaginationStyle.IndicatorImageURL);
102                 }
103                 if (null != circularPaginationStyle.CenterIndicatorImageURL)
104                 {
105                     CenterIndicatorImageURL?.Clone(circularPaginationStyle.CenterIndicatorImageURL);
106                 }
107             }
108         }
109
110         private void Initialize()
111         {
112             IndicatorSize = new Size(10, 10);
113             IndicatorImageURL = new Selector<string>()
114             {
115                 Normal = "/usr/share/dotnet.tizen/framework/res/" + "nui_component_default_pagination_normal_dot.png",
116                 Selected = "/usr/share/dotnet.tizen/framework/res/" + "nui_component_default_pagination_focus_dot.png",
117             };
118             CenterIndicatorImageURL = new Selector<string>()
119             {
120                 Normal = "/usr/share/dotnet.tizen/framework/res/" + "nui_wearable_circular_pagination_center_normal_dot.png",
121                 Selected = "/usr/share/dotnet.tizen/framework/res/" + "nui_wearable_circular_pagination_center_focus_dot.png",
122             };
123         }
124     }
125 }