[NUI] Fix extents issue and unified style format (#1287)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / ProgressStyle.cs
1 /*
2  * Copyright(c) 2019 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
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// ProgressStyle is a class which saves Progress's ux data.
25     /// </summary>
26     /// <since_tizen> 6 </since_tizen>
27     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class ProgressStyle : ControlStyle
30     {
31         static ProgressStyle() { }
32
33         /// <summary>
34         /// Creates a new instance of a ProgressStyle.
35         /// </summary>
36         /// <since_tizen> 6 </since_tizen>
37         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public ProgressStyle() : base()
40         {
41             InitSubStyle();
42         }
43
44         /// <summary>
45         /// Creates a new instance of a ProgressStyle with style.
46         /// </summary>
47         /// <param name="style">Create ProgressStyle by style customized by user.</param>
48         /// <since_tizen> 6 </since_tizen>
49         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         public ProgressStyle(ProgressStyle style) : base(style)
52         {
53             if (null == style) return;
54
55             InitSubStyle();
56
57             this.CopyFrom(style);
58         }
59
60         /// <summary>
61         /// Get or set track image.
62         /// </summary>
63         /// <since_tizen> 6 </since_tizen>
64         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public ImageViewStyle Track { get; set; }
67
68         /// <summary>
69         /// Get or set progress image.
70         /// </summary>
71         /// <since_tizen> 6 </since_tizen>
72         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public ImageViewStyle Progress { get; set; }
75
76         /// <summary>
77         /// Get or set buffer image.
78         /// </summary>
79         /// <since_tizen> 6 </since_tizen>
80         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public ImageViewStyle Buffer { get; set; }
83
84         /// <summary>
85         /// Clone function.
86         /// </summary>
87         /// <since_tizen> 6 </since_tizen>
88         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
89         [EditorBrowsable(EditorBrowsableState.Never)]
90         public override void CopyFrom(BindableObject bindableObject)
91         {
92             base.CopyFrom(bindableObject);
93
94             ProgressStyle progressStyle = bindableObject as ProgressStyle;
95
96             if (null != progressStyle)
97             {
98                 if (null != progressStyle.Track)
99                 {
100                     Track.CopyFrom(progressStyle.Track);
101                 }
102
103                 if (null != progressStyle.Progress)
104                 {
105                     Progress.CopyFrom(progressStyle.Progress);
106                 }
107
108                 if (null != progressStyle.Buffer)
109                 {
110                     Buffer.CopyFrom(progressStyle.Buffer);
111                 }
112             }
113         }
114
115         private void InitSubStyle()
116         {
117             Track = new ImageViewStyle()
118             {
119                 WidthResizePolicy = ResizePolicyType.FillToParent,
120                 HeightResizePolicy = ResizePolicyType.FillToParent,
121                 PositionUsesPivotPoint = true,
122                 ParentOrigin = NUI.ParentOrigin.TopLeft,
123                 PivotPoint = NUI.PivotPoint.TopLeft
124             };
125
126             Progress = new ImageViewStyle()
127             {
128                 WidthResizePolicy = ResizePolicyType.FillToParent,
129                 HeightResizePolicy = ResizePolicyType.FillToParent,
130                 PositionUsesPivotPoint = true,
131                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
132                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft
133             };
134
135             Buffer = new ImageViewStyle()
136             {
137                 WidthResizePolicy = ResizePolicyType.FillToParent,
138                 HeightResizePolicy = ResizePolicyType.FillToParent,
139                 PositionUsesPivotPoint = true,
140                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
141                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft
142             };
143         }
144     }
145 }