[NUI] Add default components styles and etc (#1396) (#1400)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / ToastStyle.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     /// ToastStyle is a class which saves Toast'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 ToastStyle : ControlStyle
30     {
31         static ToastStyle() { }
32
33         /// <summary>
34         /// Creates a new instance of a ToastStyle.
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 ToastStyle() : base()
40         {
41             InitSubStyle();
42         }
43
44         /// <summary>
45         /// Creates a new instance of a ToastStyle with Style.
46         /// </summary>
47         /// <param name="style">Create ToastStyle 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 ToastStyle(ToastStyle style) : base(style)
52         {
53             InitSubStyle();
54             this.CopyFrom(style);
55         }
56
57         /// <summary>
58         /// Gets or sets toast show duration time.
59         /// </summary>
60         /// <since_tizen> 6 </since_tizen>
61         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         public uint? Duration { get; set; }
64
65         /// <summary>
66         /// Text's Style.
67         /// </summary>
68         /// <since_tizen> 6 </since_tizen>
69         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
70         [EditorBrowsable(EditorBrowsableState.Never)]
71         public TextLabelStyle Text { get; set; }
72
73         /// <summary>
74         /// Style's clone function.
75         /// </summary>
76         /// <since_tizen> 6 </since_tizen>
77         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public override void CopyFrom(BindableObject bindableObject)
80         {
81             base.CopyFrom(bindableObject);
82             ToastStyle toastStyle = bindableObject as ToastStyle;
83             if (toastStyle != null)
84             {
85                 if (null != toastStyle.Text)
86                 {
87                     Text.CopyFrom(toastStyle.Text);
88                 }
89                 Duration = toastStyle.Duration;
90             }
91         }
92
93         private void InitSubStyle()
94         {
95             Text = new TextLabelStyle()
96             {
97                 PositionUsesPivotPoint = true,
98                 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
99                 PivotPoint = Tizen.NUI.PivotPoint.Center,
100                 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
101                 HeightResizePolicy = ResizePolicyType.UseNaturalSize,
102                 HorizontalAlignment = HorizontalAlignment.Center,
103                 VerticalAlignment = VerticalAlignment.Center,
104                 TextColor = Color.White
105             };
106         }
107     }
108 }