[NUI] Fix NUI svace issue (#1343)
[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 && instance?.Style?.Buttons?.Size != 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                 if (Style?.Title?.Size != null)
418                 {
419                      Style.Title.Size.Height = value;
420                 }
421             }
422         }
423
424         /// <summary>
425         /// Content view in Popup, only can be gotten.
426         /// </summary>
427         /// <since_tizen> 6 </since_tizen>
428         public View ContentView
429         {
430             get;
431             private set;
432         }
433
434         /// <summary>
435         /// Button count in Popup.
436         /// </summary>
437         /// <since_tizen> 6 </since_tizen>
438         public int ButtonCount
439         {
440             get;
441             set;
442         }
443
444         /// <summary>
445         /// Button height in Popup.
446         /// </summary>
447         /// <since_tizen> 6 </since_tizen>
448         public int ButtonHeight
449         {
450             get
451             {
452                 return (int)GetValue(ButtonHeightProperty);
453             }
454             set
455             {
456                 SetValue(ButtonHeightProperty, value);
457             }
458         }
459
460         /// <summary>
461         /// Button text point size in Popup.
462         /// </summary>
463         /// <since_tizen> 6 </since_tizen>
464         public float ButtonTextPointSize
465         {
466             get
467             {
468                 return (float)GetValue(ButtonTextPointSizeProperty);
469             }
470             set
471             {
472                 SetValue(ButtonTextPointSizeProperty, value);
473             }
474         }
475
476         /// <summary>
477         /// Button text font family in Popup.
478         /// </summary>
479         /// <since_tizen> 6 </since_tizen>
480         public string ButtonFontFamily
481         {
482             get
483             {           
484                 return (string)GetValue(ButtonFontFamilyProperty);
485             }
486             set
487             {
488                 SetValue(ButtonFontFamilyProperty, value);
489             }
490         }
491
492         /// <summary>
493         /// Button text color in Popup.
494         /// </summary>
495         /// <since_tizen> 6 </since_tizen>
496         public Color ButtonTextColor
497         {
498             get
499             {
500                 return (Color)GetValue(ButtonTextColorProperty);
501             }
502             set
503             {
504                 SetValue(ButtonTextColorProperty, value);
505             }
506         }
507
508         /// <summary>
509         /// Button overlay background color selector in Popup.
510         /// </summary>
511         /// <since_tizen> 6 </since_tizen>
512         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
513         [EditorBrowsable(EditorBrowsableState.Never)]
514         public Selector<Color> ButtonOverLayBackgroundColorSelector
515         {
516             get
517             {
518                 return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
519             }
520             set
521             {
522                 SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
523             }
524         }
525
526         /// <summary>
527         /// Button text horizontal alignment in Popup.
528         /// </summary>
529         /// <since_tizen> 6 </since_tizen>
530         public HorizontalAlignment ButtonTextAlignment
531         {
532             get
533             {   
534                 return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
535             }
536             set
537             {
538                 SetValue(ButtonTextAlignmentProperty, value);
539             }
540         }
541
542         /// <summary>
543         /// Button background image's resource url in Popup.
544         /// </summary>
545         /// <since_tizen> 6 </since_tizen>
546         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
547         [EditorBrowsable(EditorBrowsableState.Never)]
548         public string ButtonBackground
549         {
550             get
551             {     
552                 return (string)GetValue(ButtonBackgroundProperty);
553             }
554             set
555             {
556                 SetValue(ButtonBackgroundProperty, value);
557             }
558         }
559
560         /// <summary>
561         /// Button background image's border in Popup.
562         /// </summary>
563         /// <since_tizen> 6 </since_tizen>
564         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
565         [EditorBrowsable(EditorBrowsableState.Never)]
566         public Rectangle ButtonBackgroundBorder
567         {
568             get
569             {
570                 
571                 return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
572             }
573             set
574             {
575                 SetValue(ButtonBackgroundBorderProperty, value);
576             }
577         }
578
579         /// <summary>
580         /// Button's image shadow in Popup.
581         /// </summary>
582         /// <since_tizen> 6 </since_tizen>
583         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
584         [EditorBrowsable(EditorBrowsableState.Never)]
585         public ImageShadow ButtonImageShadow
586         {
587             get => (ImageShadow)GetValue(ButtonImageShadowProperty);
588             set => SetValue(ButtonImageShadowProperty, value);
589         }
590
591
592         /// <summary>
593         /// Set button text by index.
594         /// </summary>
595         /// <param name="index">Button index.</param>
596         /// <param name="text">Button text string.</param>
597         /// <since_tizen> 6 </since_tizen>
598         public void SetButtonText(int index, string text)
599         {
600             AddButton(text);
601         }
602
603         /// <summary>
604         /// Dispose Popup and all children on it.
605         /// </summary>
606         /// <param name="type">Dispose type.</param>
607         /// <since_tizen> 6 </since_tizen>
608         protected override void Dispose(DisposeTypes type)
609         {
610             if (disposed)
611             {
612                 return;
613             }
614
615             if (type == DisposeTypes.Explicit)
616             {
617                 if (titleText != null)
618                 {
619                     Remove(titleText);
620                     titleText.Dispose();
621                     titleText = null;
622                 }
623                 if (ContentView != null)
624                 {
625                     Remove(ContentView);
626                     ContentView.Dispose();
627                     ContentView = null;
628                 }
629
630                 if (btGroup != null)
631                 {
632                     btGroup.Dispose();
633                     btGroup = null;
634                 }
635             }
636
637             base.Dispose(type);
638         }
639
640         /// <summary>
641         /// Focus gained callback.
642         /// </summary>
643         /// <since_tizen> 6 </since_tizen>
644         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
645         [EditorBrowsable(EditorBrowsableState.Never)]
646         public override void OnFocusGained()
647         {
648             base.OnFocusGained();
649         }
650
651         /// <summary>
652         /// Focus lost callback.
653         /// </summary>
654         /// <since_tizen> 6 </since_tizen>
655         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
656         [EditorBrowsable(EditorBrowsableState.Never)]
657         public override void OnFocusLost()
658         {
659             base.OnFocusLost();
660         }
661
662         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
663         [EditorBrowsable(EditorBrowsableState.Never)]
664         public override void ApplyStyle(ViewStyle viewStyle)
665         {
666             base.ApplyStyle(viewStyle);
667             PopupStyle ppStyle = viewStyle as PopupStyle;
668             if (null != ppStyle)
669             {
670                 if (null == titleText)
671                 {
672                     titleText = new TextLabel();
673                     Add(titleText);
674                 }
675                 titleText.RaiseToTop();
676                 titleText.ApplyStyle(ppStyle.Title);
677             }
678         }
679
680         /// <summary>
681         /// Get Popup attribues.
682         /// </summary>
683         /// <since_tizen> 6 </since_tizen>
684         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
685         [EditorBrowsable(EditorBrowsableState.Never)]
686         protected override ViewStyle GetViewStyle()
687         {
688             return new PopupStyle();
689         }
690
691         /// <summary>
692         /// Theme change callback when theme is changed, this callback will be trigger.
693         /// </summary>
694         /// <since_tizen> 6 </since_tizen>
695         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
696         [EditorBrowsable(EditorBrowsableState.Never)]
697         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
698         {
699             PopupStyle tempAttributes = StyleManager.Instance.GetViewStyle(style) as PopupStyle;
700             if (tempAttributes != null)
701             {
702                 string strSaveTitleText = TitleText;
703                 Style.CopyFrom(tempAttributes);
704                 Style.Title.Text = strSaveTitleText;
705                 UpdateView();
706             }
707         }
708
709         private void Initialize()
710         {
711             LeaveRequired = true;
712             PropertyChanged += PopupAttributesPropertyChanged;
713
714             // ContentView
715             ContentView = new View()
716             {
717                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
718                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
719                 PositionUsesPivotPoint = true
720             };
721             Add(ContentView);
722             ContentView.RaiseToTop();
723
724             // Title
725             if (null == titleText)
726             {
727                 titleText = new TextLabel();
728                 titleText.RaiseToTop();
729                 Add(titleText);
730             }
731
732             // Button
733             btGroup = new ButtonGroup(this);
734         }
735
736         private void UpdateView()
737         {
738             btGroup.UpdateButton(Style.Buttons);
739             UpdateContentView();
740             UpdateTitle();
741         }
742
743         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
744         {
745             if (PopupButtonClickEvent != null && btGroup.Count > 0)
746             {
747                 Button button = sender as Button;
748                 for (int i = 0; i < btGroup.Count; i++)
749                 {
750                     if (button == GetButton(i))
751                     {
752                         ButtonClickEventArgs args = new ButtonClickEventArgs();
753                         args.ButtonIndex = i;
754                         PopupButtonClickEvent(this, args);
755                     }
756                 }
757             }
758         }
759
760         private void PopupAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
761         {
762             if (e.PropertyName.Equals("LayoutDirection"))
763             {
764                 btGroup.UpdateButton(Style.Buttons);
765             }
766         }
767
768         private void UpdateContentView()
769         {
770             int titleX = 0;
771             int titleY = 0;
772             int titleH = 0;
773             int buttonH = 0;
774             string strText = Style.Title.Text.All;
775             if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
776             {
777                 titleH = (int)titleText.Size.Height;
778             }
779
780             if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
781             {
782                 titleX = (int)Style.Title.Position.X;
783                 titleY = (int)Style.Title.Position.Y;
784             }
785
786             if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
787             {
788                 buttonH = (int)Style.Buttons.Size.Height;
789             }
790             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
791             ContentView.Position = new Position(titleX, titleY + titleH);
792             ContentView.RaiseToTop();
793         }
794
795         private void UpdateTitle()
796         {
797             if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
798             {
799                 titleText.RaiseToTop();
800             }
801         }
802         /// <summary>
803         /// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
804         /// </summary>
805         /// <since_tizen> 6 </since_tizen>
806         public class ButtonClickEventArgs : EventArgs
807         {
808             /// <summary> Button index which is clicked in Popup </summary>
809             /// <since_tizen> 6 </since_tizen>
810             public int ButtonIndex;
811         }
812     }
813 }