[NUI] Fix extents issue and unified style format (#1286)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / TabStyle.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     /// TabStyle is a class which saves Tab'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 TabStyle : ControlStyle
30     {
31         static TabStyle() { }
32
33         /// <summary>
34         /// Creates a new instance of a TabStyle.
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 TabStyle() : base()
40         {
41             ItemPadding = new Extents(0, 0, 0, 0);
42             UseTextNaturalSize = false;
43             ItemSpace = 0;
44
45             UnderLine = new ViewStyle();
46             Text = new TextLabelStyle();
47         }
48
49         /// <summary>
50         /// Creates a new instance of a TabStyle with style.
51         /// </summary>
52         /// <param name="style">Create TabStyle by style customized by user.</param>
53         /// <since_tizen> 6 </since_tizen>
54         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public TabStyle(TabStyle style) : base(style)
57         {
58             UnderLine = new ViewStyle();
59             Text = new TextLabelStyle();
60
61             if (null == style)
62             {
63                 return;
64             }
65
66             if (style.UnderLine != null)
67             {
68                 UnderLine.CopyFrom(style.UnderLine);
69             }
70
71             if (style.Text != null)
72             {
73                 Text.CopyFrom(style.Text);
74             }
75
76             if (style.ItemPadding != null)
77             {
78                 ItemPadding = new Extents(style.ItemPadding.Start, style.ItemPadding.End, style.ItemPadding.Top, style.ItemPadding.Bottom);
79             }
80             else
81             {
82                 ItemPadding = new Extents(0, 0, 0, 0);
83             }
84             ItemSpace = style.ItemSpace;
85             UseTextNaturalSize = style.UseTextNaturalSize;
86
87             if (null != style.UnderLine)
88             {
89                 UnderLine.CopyFrom(style.UnderLine);
90             }
91
92             if (null != style.Text)
93             {
94                 Text.CopyFrom(style.Text);
95             }
96         }
97
98         /// <summary>
99         /// UnderLine's attributes.
100         /// </summary>
101         /// <since_tizen> 6 </since_tizen>
102         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
103         [EditorBrowsable(EditorBrowsableState.Never)]
104         public ViewStyle UnderLine { get; set; }
105
106         /// <summary>
107         /// Text's attributes.
108         /// </summary>
109         /// <since_tizen> 6 </since_tizen>
110         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
111         [EditorBrowsable(EditorBrowsableState.Never)]
112         public TextLabelStyle Text { get; set; }
113
114         /// <summary>
115         /// Flag to decide if item is fill with item text's natural width.
116         /// </summary>
117         /// <since_tizen> 6 </since_tizen>
118         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
119         [EditorBrowsable(EditorBrowsableState.Never)]
120         public bool UseTextNaturalSize { get; set; }
121
122         /// <summary>
123         /// Gap between items.
124         /// </summary>
125         /// <since_tizen> 6 </since_tizen>
126         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         public int ItemSpace { get; set; }
129
130         /// <summary>
131         /// Space in Tab.
132         /// </summary>
133         /// <since_tizen> 6 </since_tizen>
134         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
135         [EditorBrowsable(EditorBrowsableState.Never)]
136         public Extents ItemPadding { get; set; }
137
138         /// <summary>
139         /// Attributes's clone function.
140         /// </summary>
141         /// <since_tizen> 6 </since_tizen>
142         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public override void CopyFrom(BindableObject bindableObject)
145         {
146             base.CopyFrom(bindableObject);
147             TabStyle tabStyle = bindableObject as TabStyle;
148
149             if (null != tabStyle)
150             {
151                 if (null != tabStyle.ItemPadding)
152                 {
153                     ItemPadding.CopyFrom(tabStyle.ItemPadding);
154                 }
155
156                 ItemSpace = tabStyle.ItemSpace;
157                 UseTextNaturalSize = tabStyle.UseTextNaturalSize;
158
159                 if (null != tabStyle.UnderLine)
160                 {
161                     UnderLine.CopyFrom(tabStyle.UnderLine);
162                 }
163
164                 if (null != tabStyle.Text)
165                 {
166                     Text.CopyFrom(tabStyle.Text);
167                 }
168             }
169         }
170     }
171 }