3a1f3a85d063a17573de9aed10c77c0930e1c2c8
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / PopupStyle.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     /// PopupStyle is a class which saves Popup'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 PopupStyle : ControlStyle
30     {
31         /// <summary>
32         /// Creates a new instance of a PopupStyle.
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 PopupStyle() : base()
38         {
39             InitSubStyle();
40         }
41
42         /// <summary>
43         /// Creates a new instance of a PopupStyle with style.
44         /// </summary>
45         /// <param name="style">Create PopupStyle 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 PopupStyle(PopupStyle style) : base(style)
50         {
51             InitSubStyle();
52             this.CopyFrom(style);
53         }
54
55         /// <summary>
56         /// Title Text's Style.
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 TextLabelStyle Title
62         {
63             get;
64             set;
65         }
66
67         /// <summary>
68         /// Shadow offset.
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 Vector4 ShadowOffset
74         {
75             get;
76             set;
77         }
78
79         /// <summary>
80         /// Popup button's attributes.
81         /// </summary>
82         /// <since_tizen> 6 </since_tizen>
83         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public ButtonStyle Buttons
86         {
87             get;
88             set;
89         }
90
91         /// <summary>
92         /// Attributes's clone function.
93         /// </summary>
94         /// <since_tizen> 6 </since_tizen>
95         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
96         [EditorBrowsable(EditorBrowsableState.Never)]
97         public override void CopyFrom(BindableObject bindableObject)
98         {
99             base.CopyFrom(bindableObject);
100
101             PopupStyle popupAttributes = bindableObject as PopupStyle;
102             if (popupAttributes != null)
103             {
104                 if (popupAttributes.Shadow != null)
105                 {
106                     Shadow.CopyFrom(popupAttributes.Shadow);
107                 }
108
109                 if (popupAttributes.Title != null)
110                 {
111                     Title.CopyFrom(popupAttributes.Title);
112                 }
113
114                 if (popupAttributes.Buttons != null)
115                 {
116                     Buttons.CopyFrom(popupAttributes.Buttons);
117                 }
118
119                 if (popupAttributes.ShadowOffset != null)
120                 {
121                     ShadowOffset = new Vector4(popupAttributes.ShadowOffset.W, popupAttributes.ShadowOffset.X, popupAttributes.ShadowOffset.Y, popupAttributes.ShadowOffset.Z);
122                 }
123             }
124         }
125
126         private void InitSubStyle()
127         {
128             Shadow = new ImageViewStyle()
129             {
130                 PositionUsesPivotPoint = true,
131                 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
132                 PivotPoint = Tizen.NUI.PivotPoint.Center
133             };
134
135             Title = new TextLabelStyle()
136             {
137                 Size = new Size(0, 0),
138                 PositionUsesPivotPoint = true,
139                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
140                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
141                 HorizontalAlignment = HorizontalAlignment.Begin,
142                 VerticalAlignment = VerticalAlignment.Bottom
143             };
144
145             Buttons = new ButtonStyle()
146             {
147                 Size = new Size(0, 0),
148                 PositionUsesPivotPoint = true,
149                 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
150                 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
151                 Text = new TextLabelStyle
152                 {
153                     PositionUsesPivotPoint = true,
154                     ParentOrigin = Tizen.NUI.ParentOrigin.Center,
155                     PivotPoint = Tizen.NUI.PivotPoint.Center,
156                     HorizontalAlignment = HorizontalAlignment.Center,
157                     VerticalAlignment = VerticalAlignment.Center
158                 }
159             };
160         }
161     }
162 }