[NUI]Merge master#1199 to API6 (#1202)
[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         /// <summary>
32         /// Creates a new instance of a ToastStyle.
33         /// </summary>
34         /// <since_tizen> 6 </since_tizen>
35         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public ToastStyle() : base()
38         {
39             InitSubStyle();
40         }
41
42         /// <summary>
43         /// Creates a new instance of a ToastStyle with Style.
44         /// </summary>
45         /// <param name="Style">Create ToastStyle by Style customized by user.</param>
46         /// <since_tizen> 6 </since_tizen>
47         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
48         [EditorBrowsable(EditorBrowsableState.Never)]
49         public ToastStyle(ToastStyle style) : base(style)
50         {
51             InitSubStyle();
52             this.CopyFrom(style);
53         }
54
55         /// <summary>
56         /// Gets or sets toast show duration time.
57         /// </summary>
58         /// <since_tizen> 6 </since_tizen>
59         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public uint? Duration
62         {
63             get;
64             set;
65         }
66
67         /// <summary>
68         /// Text's Style.
69         /// </summary>
70         /// <since_tizen> 6 </since_tizen>
71         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public TextLabelStyle Text { get; set; }
74
75         /// <summary>
76         /// Style's clone function.
77         /// </summary>
78         /// <since_tizen> 6 </since_tizen>
79         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
80         [EditorBrowsable(EditorBrowsableState.Never)]
81         public override void CopyFrom(BindableObject bindableObject)
82         {
83             base.CopyFrom(bindableObject);
84             ToastStyle toastStyle = bindableObject as ToastStyle;
85             if (toastStyle != null)
86             {
87                 if (null != toastStyle.Text)
88                 {
89                     Text.CopyFrom(toastStyle.Text);
90                 }
91                 Duration = toastStyle.Duration;
92             }
93         }
94
95         private void InitSubStyle()
96         {
97             Text = new TextLabelStyle()
98             {
99                 PositionUsesPivotPoint = true,
100                 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
101                 PivotPoint = Tizen.NUI.PivotPoint.Center,
102                 WidthResizePolicy = ResizePolicyType.FillToParent,
103                 HeightResizePolicy = ResizePolicyType.FillToParent,
104                 HorizontalAlignment = HorizontalAlignment.Center,
105                 VerticalAlignment = VerticalAlignment.Center,
106                 TextColor = Color.White
107             };
108         }
109     }
110 }