[NUI.Components] Fix svace issues (#1309)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Popup.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;
18 using System.Collections.Generic;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using System.ComponentModel;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// Popup is one kind of common component, it can be used as popup window.
27     /// User can handle Popup button count, head title and content area.
28     /// </summary>
29     /// <since_tizen> 6 </since_tizen>
30     public class Popup : Control
31     {
32         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33         [EditorBrowsable(EditorBrowsableState.Never)]
34         public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
35         {
36             var instance = (Popup)bindable;
37             if (newValue != null)
38             {
39                 instance.Style.Buttons.Size.Height = (int)newValue;
40                 instance.btGroup.Itemheight = (int)newValue;
41                 instance.UpdateView();
42             }
43         },
44         defaultValueCreator: (bindable) =>
45         {
46             var instance = (Popup)bindable;
47             return (int)(instance.Style?.Buttons?.Size?.Height ?? 0);
48         });
49
50         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public static readonly BindableProperty ButtonTextPointSizeProperty = BindableProperty.Create(nameof(ButtonTextPointSize), typeof(float), typeof(Popup), default(float), propertyChanged: (bindable, oldValue, newValue) =>
53         {
54             var instance = (Popup)bindable;
55             if (newValue != null)
56             {
57                 if (instance.Style?.Buttons?.Text != null)
58                 {
59                     instance.Style.Buttons.Text.PointSize = (float)newValue;
60                 }
61                 instance.btGroup.ItemPointSize = (float)newValue;
62             }
63         },
64         defaultValueCreator: (bindable) =>
65         {
66             var instance = (Popup)bindable;
67             return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0;
68         });
69
70         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         public static readonly BindableProperty ButtonFontFamilyProperty = BindableProperty.Create(nameof(ButtonFontFamily), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
73         {
74             var instance = (Popup)bindable;
75             if (newValue != null)
76             {
77                 instance.Style.Buttons.Text.FontFamily = (string)newValue;
78                 instance.btGroup.ItemFontFamily = (string)newValue;
79             }
80         },
81         defaultValueCreator: (bindable) =>
82         {
83             var instance = (Popup)bindable;
84             return instance.Style?.Buttons?.Text?.FontFamily.All;
85         });
86
87         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public static readonly BindableProperty ButtonTextColorProperty = BindableProperty.Create(nameof(ButtonTextColor), typeof(Color), typeof(Popup), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
90         {
91             var instance = (Popup)bindable;
92             if (newValue != null)
93             {  
94                 if (instance.Style?.Buttons?.Text != null)
95                 {
96                     instance.Style.Buttons.Text.TextColor = (Color)newValue;
97                 }
98                 instance.btGroup.ItemTextColor = (Color)newValue;
99             }
100         },
101         defaultValueCreator: (bindable) =>
102         {
103             var instance = (Popup)bindable;
104             return instance.Style?.Buttons?.Text?.TextColor?.All;
105         });
106
107         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public static readonly BindableProperty ButtonOverLayBackgroundColorSelectorProperty = BindableProperty.Create(nameof(ButtonOverLayBackgroundColorSelector), typeof(Selector<Color>), typeof(Popup), new Selector<Color>(), propertyChanged: (bindable, oldValue, newValue) =>
110         {
111             var instance = (Popup)bindable;
112             if (newValue != null)
113             {
114                 instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
115                 instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
116             }
117         },
118         defaultValueCreator: (bindable) =>
119         {
120             var instance = (Popup)bindable;
121             return instance.Style?.Buttons?.Overlay?.BackgroundColor;
122         });
123
124         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
125         [EditorBrowsable(EditorBrowsableState.Never)]
126         public static readonly BindableProperty ButtonTextAlignmentProperty = BindableProperty.Create(nameof(ButtonTextAlignment), typeof(HorizontalAlignment), typeof(Popup), new HorizontalAlignment(), propertyChanged: (bindable, oldValue, newValue) =>
127         {
128             var instance = (Popup)bindable;
129             if (newValue != null)
130             {
131                 instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
132                 instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
133             }
134         },
135         defaultValueCreator: (bindable) =>
136         {
137             var instance = (Popup)bindable;
138             return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
139         });
140
141         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public static readonly BindableProperty ButtonBackgroundProperty = BindableProperty.Create(nameof(ButtonBackground), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
144         {
145             var instance = (Popup)bindable;
146             if (newValue != null)
147             {
148                 if (instance.Style.Buttons.BackgroundImage == null)
149                 {
150                     instance.Style.Buttons.BackgroundImage = new Selector<string>();
151                 }
152                 instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
153                 instance.Style.Buttons.BackgroundImage = (string)newValue;
154             }
155         },
156         defaultValueCreator: (bindable) =>
157         {
158             var instance = (Popup)bindable;
159             return instance.Style?.Buttons?.BackgroundImage?.All;
160         });
161
162         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
163         [EditorBrowsable(EditorBrowsableState.Never)]
164         public static readonly BindableProperty ButtonBackgroundBorderProperty = BindableProperty.Create(nameof(ButtonBackgroundBorder), typeof(Rectangle), typeof(Popup), new Rectangle(0, 0, 0, 0), propertyChanged: (bindable, oldValue, newValue) =>
165         {
166             var instance = (Popup)bindable;
167             if (newValue != null)
168             {
169                 if (instance.Style.Buttons.BackgroundImageBorder == null)
170                 {
171                     instance.Style.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
172                 }
173                 instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue;
174                 instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
175             }
176         },
177         defaultValueCreator: (bindable) =>
178         {
179             var instance = (Popup)bindable;
180             return instance.Style?.Buttons?.BackgroundImageBorder?.All;
181         });
182
183         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
184         [EditorBrowsable(EditorBrowsableState.Never)]
185         public static readonly BindableProperty ButtonImageShadowProperty = BindableProperty.Create(nameof(ButtonImageShadow), typeof(ImageShadow), typeof(Popup), null, propertyChanged: (bindable, oldValue, newValue) =>
186         {
187             var instance = (Popup)bindable;
188             ImageShadow shadow = (ImageShadow)newValue;
189             instance.btGroup.ItemImageShadow = (ImageShadow)ImageShadow.Clone(shadow);
190             instance.Style.Buttons.ImageShadow = (ImageShadow)ImageShadow.Clone(shadow);
191         },
192         defaultValueCreator: (bindable) =>
193         {
194             var instance = (Popup)bindable;
195             return instance.Style?.Buttons?.ImageShadow?.All;
196         });
197
198
199         private TextLabel titleText;
200         private ButtonGroup btGroup = null;
201         private Window window = null;
202         static Popup() { }
203
204         /// <summary>
205         /// Creates a new instance of a Popup.
206         /// </summary>
207         /// <since_tizen> 6 </since_tizen>
208         public Popup() : base()
209         {
210             Initialize();
211         }
212
213         /// <summary>
214         /// Creates a new instance of a Popup with style.
215         /// </summary>
216         /// <param name="style">Create Popup by special style defined in UX.</param>
217         /// <since_tizen> 6 </since_tizen>
218         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
219         [EditorBrowsable(EditorBrowsableState.Never)]
220         public Popup(string style) : base(style)
221         {
222             Initialize();
223         }
224
225         /// <summary>
226         /// Creates a new instance of a Popup with attributes.
227         /// </summary>
228         /// <param name="attributes">Create Popup by attributes customized by user.</param>
229         /// <since_tizen> 6 </since_tizen>
230         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
231         [EditorBrowsable(EditorBrowsableState.Never)]
232         public Popup(PopupStyle attributes) : base(attributes)
233         {
234             Initialize();
235         }
236
237         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
238         [EditorBrowsable(EditorBrowsableState.Never)]
239         public void Post(Window win)
240         {
241             if (null == win) return;
242             window = win;
243             window.Add(this);
244         }
245
246         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
247         [EditorBrowsable(EditorBrowsableState.Never)]
248         public void AddButton(string buttonText)
249         {
250             if (Style.Buttons != null)
251             {
252                 Button btn = new Button(Style.Buttons);
253                 btn.Style.Text.Text = buttonText;
254                 btn.ClickEvent += ButtonClickEvent;
255                 btGroup.AddItem(btn);
256                 UpdateView();
257             }
258         }
259
260         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
261         [EditorBrowsable(EditorBrowsableState.Never)]
262         public void AddButton(string buttonText, string style)
263         {
264             AddButton(buttonText);
265         }
266
267         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
268         [EditorBrowsable(EditorBrowsableState.Never)]
269         public void AddButton(string buttonText, ButtonStyle style)
270         {
271             if (Style.Buttons != null && style != null)
272             {
273                 Style.Buttons.CopyFrom(style);
274                 AddButton(buttonText);
275             }
276         }
277
278         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
279         [EditorBrowsable(EditorBrowsableState.Never)]
280         public Button GetButton(int index)
281         {
282             return btGroup.GetItem(index);
283         }
284
285         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
286         [EditorBrowsable(EditorBrowsableState.Never)]
287         public void RemoveButton(int index)
288         {
289             btGroup.RemoveItem(index);
290         }
291
292         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
293         [EditorBrowsable(EditorBrowsableState.Never)]
294         public void AddContentText(View childView)
295         {
296             if (null != ContentView)
297             {
298                 ContentView.Add(childView);
299             }
300             UpdateView();
301         }
302
303         /// <summary>
304         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
305         /// </summary>
306         /// <since_tizen> 6 </since_tizen>
307         public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
308
309         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
310         [EditorBrowsable(EditorBrowsableState.Never)]
311         public new PopupStyle Style => ViewStyle as PopupStyle;
312
313         /// <summary>
314         /// Title text string in Popup.
315         /// </summary>
316         /// <since_tizen> 6 </since_tizen>
317         public string TitleText
318         {
319             get
320             {
321                 return Style?.Title?.Text?.All;
322             }
323             set
324             {
325                 if (value != null)
326                 {
327                     if (Style?.Title != null)
328                     {
329                         Style.Title.Text = value;
330                     }
331                 }
332             }
333         }
334
335         /// <summary>
336         /// Title text point size in Popup.
337         /// </summary>
338         /// <since_tizen> 6 </since_tizen>
339         public float TitlePointSize
340         {
341             get
342             {
343                 return Style?.Title?.PointSize?.All ?? 0;
344             }
345             set
346             {
347                 if (Style?.Title != null)
348                 {
349                     Style.Title.PointSize = value;
350                 }
351             }
352         }
353
354         /// <summary>
355         /// Title text color in Popup.
356         /// </summary>
357         /// <since_tizen> 6 </since_tizen>
358         public Color TitleTextColor
359         {
360             get
361             {
362                 return Style?.Title?.TextColor?.All;
363             }
364             set
365             {
366                 if (Style?.Title != null)
367                 {
368                     Style.Title.TextColor = value;
369                 }
370             }
371         }
372
373         /// <summary>
374         /// Title text horizontal alignment in Popup.
375         /// </summary>
376         /// <since_tizen> 6 </since_tizen>
377         public HorizontalAlignment TitleTextHorizontalAlignment
378         {
379             get
380             {
381                 return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
382             }
383             set
384             {
385                 Style.Title.HorizontalAlignment = value;
386             }
387         }
388
389         /// <summary>
390         /// Title text's position in Popup.
391         /// </summary>
392         /// <since_tizen> 6 </since_tizen>
393         public Position TitleTextPosition
394         {
395             get
396             {
397                 return Style?.Title?.Position ?? new Position(0, 0, 0);
398             }
399             set
400             {
401                 Style.Title.Position = value;
402             }
403         }
404
405         /// <summary>
406         /// Title text's height in Popup.
407         /// </summary>
408         /// <since_tizen> 6 </since_tizen>
409         public int TitleHeight
410         {
411             get
412             {
413                 return (int)(Style?.Title?.Size?.Height ?? 0);
414             }
415             set
416             {
417                 Style.Title.Size.Height = value;
418             }
419         }
420
421         /// <summary>
422         /// Content view in Popup, only can be gotten.
423         /// </summary>
424         /// <since_tizen> 6 </since_tizen>
425         public View ContentView
426         {
427             get;
428             private set;
429         }
430
431         /// <summary>
432         /// Button count in Popup.
433         /// </summary>
434         /// <since_tizen> 6 </since_tizen>
435         public int ButtonCount
436         {
437             get;
438             set;
439         }
440
441         /// <summary>
442         /// Button height in Popup.
443         /// </summary>
444         /// <since_tizen> 6 </since_tizen>
445         public int ButtonHeight
446         {
447             get
448             {
449                 return (int)GetValue(ButtonHeightProperty);
450             }
451             set
452             {
453                 SetValue(ButtonHeightProperty, value);
454             }
455         }
456
457         /// <summary>
458         /// Button text point size in Popup.
459         /// </summary>
460         /// <since_tizen> 6 </since_tizen>
461         public float ButtonTextPointSize
462         {
463             get
464             {
465                 return (float)GetValue(ButtonTextPointSizeProperty);
466             }
467             set
468             {
469                 SetValue(ButtonTextPointSizeProperty, value);
470             }
471         }
472
473         /// <summary>
474         /// Button text font family in Popup.
475         /// </summary>
476         /// <since_tizen> 6 </since_tizen>
477         public string ButtonFontFamily
478         {
479             get
480             {           
481                 return (string)GetValue(ButtonFontFamilyProperty);
482             }
483             set
484             {
485                 SetValue(ButtonFontFamilyProperty, value);
486             }
487         }
488
489         /// <summary>
490         /// Button text color in Popup.
491         /// </summary>
492         /// <since_tizen> 6 </since_tizen>
493         public Color ButtonTextColor
494         {
495             get
496             {
497                 return (Color)GetValue(ButtonTextColorProperty);
498             }
499             set
500             {
501                 SetValue(ButtonTextColorProperty, value);
502             }
503         }
504
505         /// <summary>
506         /// Button overlay background color selector in Popup.
507         /// </summary>
508         /// <since_tizen> 6 </since_tizen>
509         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
510         [EditorBrowsable(EditorBrowsableState.Never)]
511         public Selector<Color> ButtonOverLayBackgroundColorSelector
512         {
513             get
514             {
515                 return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
516             }
517             set
518             {
519                 SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
520             }
521         }
522
523         /// <summary>
524         /// Button text horizontal alignment in Popup.
525         /// </summary>
526         /// <since_tizen> 6 </since_tizen>
527         public HorizontalAlignment ButtonTextAlignment
528         {
529             get
530             {   
531                 return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
532             }
533             set
534             {
535                 SetValue(ButtonTextAlignmentProperty, value);
536             }
537         }
538
539         /// <summary>
540         /// Button background image's resource url in Popup.
541         /// </summary>
542         /// <since_tizen> 6 </since_tizen>
543         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
544         [EditorBrowsable(EditorBrowsableState.Never)]
545         public string ButtonBackground
546         {
547             get
548             {     
549                 return (string)GetValue(ButtonBackgroundProperty);
550             }
551             set
552             {
553                 SetValue(ButtonBackgroundProperty, value);
554             }
555         }
556
557         /// <summary>
558         /// Button background image's border in Popup.
559         /// </summary>
560         /// <since_tizen> 6 </since_tizen>
561         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
562         [EditorBrowsable(EditorBrowsableState.Never)]
563         public Rectangle ButtonBackgroundBorder
564         {
565             get
566             {
567                 
568                 return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
569             }
570             set
571             {
572                 SetValue(ButtonBackgroundBorderProperty, value);
573             }
574         }
575
576         /// <summary>
577         /// Button's image shadow in Popup.
578         /// </summary>
579         /// <since_tizen> 6 </since_tizen>
580         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
581         [EditorBrowsable(EditorBrowsableState.Never)]
582         public ImageShadow ButtonImageShadow
583         {
584             get => (ImageShadow)GetValue(ButtonImageShadowProperty);
585             set => SetValue(ButtonImageShadowProperty, value);
586         }
587
588
589         /// <summary>
590         /// Set button text by index.
591         /// </summary>
592         /// <param name="index">Button index.</param>
593         /// <param name="text">Button text string.</param>
594         /// <since_tizen> 6 </since_tizen>
595         public void SetButtonText(int index, string text)
596         {
597             AddButton(text);
598         }
599
600         /// <summary>
601         /// Dispose Popup and all children on it.
602         /// </summary>
603         /// <param name="type">Dispose type.</param>
604         /// <since_tizen> 6 </since_tizen>
605         protected override void Dispose(DisposeTypes type)
606         {
607             if (disposed)
608             {
609                 return;
610             }
611
612             if (type == DisposeTypes.Explicit)
613             {
614                 if (titleText != null)
615                 {
616                     Remove(titleText);
617                     titleText.Dispose();
618                     titleText = null;
619                 }
620                 if (ContentView != null)
621                 {
622                     Remove(ContentView);
623                     ContentView.Dispose();
624                     ContentView = null;
625                 }
626
627                 if (btGroup != null)
628                 {
629                     btGroup.Dispose();
630                     btGroup = null;
631                 }
632             }
633
634             base.Dispose(type);
635         }
636
637         /// <summary>
638         /// Focus gained callback.
639         /// </summary>
640         /// <since_tizen> 6 </since_tizen>
641         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
642         [EditorBrowsable(EditorBrowsableState.Never)]
643         public override void OnFocusGained()
644         {
645             base.OnFocusGained();
646         }
647
648         /// <summary>
649         /// Focus lost callback.
650         /// </summary>
651         /// <since_tizen> 6 </since_tizen>
652         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
653         [EditorBrowsable(EditorBrowsableState.Never)]
654         public override void OnFocusLost()
655         {
656             base.OnFocusLost();
657         }
658
659         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
660         [EditorBrowsable(EditorBrowsableState.Never)]
661         public override void ApplyStyle(ViewStyle viewStyle)
662         {
663             base.ApplyStyle(viewStyle);
664             PopupStyle ppStyle = viewStyle as PopupStyle;
665             if (null != ppStyle)
666             {
667                 if (null == titleText)
668                 {
669                     titleText = new TextLabel();
670                     Add(titleText);
671                 }
672                 titleText.RaiseToTop();
673                 titleText.ApplyStyle(ppStyle.Title);
674             }
675         }
676
677         /// <summary>
678         /// Get Popup attribues.
679         /// </summary>
680         /// <since_tizen> 6 </since_tizen>
681         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
682         [EditorBrowsable(EditorBrowsableState.Never)]
683         protected override ViewStyle GetViewStyle()
684         {
685             return new PopupStyle();
686         }
687
688         /// <summary>
689         /// Theme change callback when theme is changed, this callback will be trigger.
690         /// </summary>
691         /// <since_tizen> 6 </since_tizen>
692         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
693         [EditorBrowsable(EditorBrowsableState.Never)]
694         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
695         {
696             PopupStyle tempAttributes = StyleManager.Instance.GetViewStyle(style) as PopupStyle;
697             if (tempAttributes != null)
698             {
699                 string strSaveTitleText = TitleText;
700                 Style.CopyFrom(tempAttributes);
701                 Style.Title.Text = strSaveTitleText;
702                 UpdateView();
703             }
704         }
705
706         private void Initialize()
707         {
708             LeaveRequired = true;
709             PropertyChanged += PopupAttributesPropertyChanged;
710
711             // ContentView
712             ContentView = new View()
713             {
714                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
715                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
716                 PositionUsesPivotPoint = true
717             };
718             Add(ContentView);
719             ContentView.RaiseToTop();
720
721             // Title
722             if (null == titleText)
723             {
724                 titleText = new TextLabel();
725                 titleText.RaiseToTop();
726                 Add(titleText);
727             }
728
729             // Button
730             btGroup = new ButtonGroup(this);
731         }
732
733         private void UpdateView()
734         {
735             btGroup.UpdateButton(Style.Buttons);
736             UpdateContentView();
737             UpdateTitle();
738         }
739
740         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
741         {
742             if (PopupButtonClickEvent != null && btGroup.Count > 0)
743             {
744                 Button button = sender as Button;
745                 for (int i = 0; i < btGroup.Count; i++)
746                 {
747                     if (button == GetButton(i))
748                     {
749                         ButtonClickEventArgs args = new ButtonClickEventArgs();
750                         args.ButtonIndex = i;
751                         PopupButtonClickEvent(this, args);
752                     }
753                 }
754             }
755         }
756
757         private void PopupAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
758         {
759             if (e.PropertyName.Equals("LayoutDirection"))
760             {
761                 btGroup.UpdateButton(Style.Buttons);
762             }
763         }
764
765         private void UpdateContentView()
766         {
767             int titleX = 0;
768             int titleY = 0;
769             int titleH = 0;
770             int buttonH = 0;
771             string strText = Style.Title.Text.All;
772             if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
773             {
774                 titleH = (int)titleText.Size.Height;
775             }
776
777             if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
778             {
779                 titleX = (int)Style.Title.Position.X;
780                 titleY = (int)Style.Title.Position.Y;
781             }
782
783             if (btGroup.Count != 0)
784             {
785                 buttonH = (int)Style.Buttons.Size.Height;
786             }
787             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
788             ContentView.Position = new Position(titleX, titleY + titleH);
789             ContentView.RaiseToTop();
790         }
791
792         private void UpdateTitle()
793         {
794             if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
795             {
796                 titleText.RaiseToTop();
797             }
798         }
799         /// <summary>
800         /// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
801         /// </summary>
802         /// <since_tizen> 6 </since_tizen>
803         public class ButtonClickEventArgs : EventArgs
804         {
805             /// <summary> Button index which is clicked in Popup </summary>
806             /// <since_tizen> 6 </since_tizen>
807             public int ButtonIndex;
808         }
809     }
810 }