6193ec617ad38d15a6fb731a70a2c159f769f5a3
[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 Extents ShadowExtents
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.Title != null)
105                 {
106                     Title.CopyFrom(popupAttributes.Title);
107                 }
108
109                 if (popupAttributes.Buttons != null)
110                 {
111                     Buttons.CopyFrom(popupAttributes.Buttons);
112                 }
113
114                 if (popupAttributes.ShadowExtents != null)
115                 {
116                     ShadowExtents = new Extents(popupAttributes.ShadowExtents.Start, popupAttributes.ShadowExtents.End, popupAttributes.ShadowExtents.Top, popupAttributes.ShadowExtents.Bottom);
117                 }
118             }
119         }
120
121         private void InitSubStyle()
122         {
123             ShadowExtents = new Extents(24, 24, 24, 24);
124             Title = new TextLabelStyle()
125             {
126                 Size = new Size(0, 0),
127                 PositionUsesPivotPoint = true,
128                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
129                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
130                 HorizontalAlignment = HorizontalAlignment.Begin,
131                 VerticalAlignment = VerticalAlignment.Bottom
132             };
133
134             Buttons = new ButtonStyle()
135             {
136                 Size = new Size(0, 0),
137                 PositionUsesPivotPoint = true,
138                 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
139                 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
140                 Overlay = new ImageViewStyle()
141                 {
142                     PositionUsesPivotPoint = true,
143                     ParentOrigin = Tizen.NUI.ParentOrigin.Center,
144                     PivotPoint = Tizen.NUI.PivotPoint.Center,
145                     WidthResizePolicy = ResizePolicyType.FillToParent,
146                     HeightResizePolicy = ResizePolicyType.FillToParent
147                 },
148
149                 Text = new TextLabelStyle()
150                 {
151                     PositionUsesPivotPoint = true,
152                     ParentOrigin = Tizen.NUI.ParentOrigin.Center,
153                     PivotPoint = Tizen.NUI.PivotPoint.Center,
154                     WidthResizePolicy = ResizePolicyType.FillToParent,
155                     HeightResizePolicy = ResizePolicyType.FillToParent,
156                     HorizontalAlignment = HorizontalAlignment.Center,
157                     VerticalAlignment = VerticalAlignment.Center
158                 }
159             };
160         }
161     }
162 }