[NUI] Provide APIs to access sub-components (#1624)
[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 = new ImageShadow(shadow);
190             instance.Style.Buttons.ImageShadow = new ImageShadow(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         private Layer container = new Layer();
203         static Popup() { }
204
205         /// <summary>
206         /// Creates a new instance of a Popup.
207         /// </summary>
208         /// <since_tizen> 6 </since_tizen>
209         public Popup() : base()
210         {
211             Initialize();
212         }
213
214         /// <summary>
215         /// Creates a new instance of a Popup with style.
216         /// </summary>
217         /// <param name="style">Create Popup by special style defined in UX.</param>
218         /// <since_tizen> 8 </since_tizen>
219         public Popup(string style) : base(style)
220         {
221             Initialize();
222         }
223
224         /// <summary>
225         /// Creates a new instance of a Popup with style.
226         /// </summary>
227         /// <param name="popupStyle">Create Popup by style customized by user.</param>
228         /// <since_tizen> 8 </since_tizen>
229         public Popup(PopupStyle popupStyle) : base(popupStyle)
230         {
231             Initialize();
232         }
233
234         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
235         [EditorBrowsable(EditorBrowsableState.Never)]
236         public virtual void Post(Window targetWindow)
237         {
238             if (targetWindow == null)
239             {
240                 return;
241             }
242
243             window = targetWindow;
244             window.AddLayer(container);
245             container.RaiseToTop();
246         }
247
248         /// <summary>
249         /// Dismiss the dialog
250         /// </summary>
251         [EditorBrowsable(EditorBrowsableState.Never)]
252         public virtual void Dismiss()
253         {
254             if (window == null)
255             {
256                 return;
257             }
258
259             window.RemoveLayer(container);
260             window = null;
261         }
262
263         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
264         [EditorBrowsable(EditorBrowsableState.Never)]
265         public void AddButton(string buttonText)
266         {
267             if (Style.Buttons != null)
268             {
269                 Button btn = new Button(Style.Buttons);
270                 btn.Style.Text.Text = buttonText;
271                 btn.ClickEvent += ButtonClickEvent;
272                 btGroup.AddItem(btn);
273                 UpdateView();
274             }
275         }
276
277         /// <summary>
278         /// Add button by style's name.
279         /// </summary>
280         /// <since_tizen> 8 </since_tizen>
281         public void AddButton(string buttonText, string style)
282         {
283             AddButton(buttonText);
284         }
285
286         /// <summary>
287         /// Add button by style.
288         /// </summary>
289         /// <since_tizen> 8 </since_tizen>
290         public void AddButton(string buttonText, ButtonStyle style)
291         {
292             if (Style.Buttons != null && style != null)
293             {
294                 Style.Buttons.CopyFrom(style);
295                 AddButton(buttonText);
296             }
297         }
298
299         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
300         [EditorBrowsable(EditorBrowsableState.Never)]
301         public Button GetButton(int index)
302         {
303             return btGroup.GetItem(index);
304         }
305
306         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
307         [EditorBrowsable(EditorBrowsableState.Never)]
308         public void RemoveButton(int index)
309         {
310             btGroup.RemoveItem(index);
311         }
312
313         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
314         [EditorBrowsable(EditorBrowsableState.Never)]
315         public void AddContentText(View childView)
316         {
317             if (null != ContentView)
318             {
319                 ContentView.Add(childView);
320             }
321             UpdateView();
322         }
323
324         /// <summary>
325         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
326         /// </summary>
327         /// <since_tizen> 6 </since_tizen>
328         public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
329
330         /// <summary>
331         /// Get style of popup.
332         /// </summary>
333         /// <since_tizen> 8 </since_tizen>
334         public new PopupStyle Style => ViewStyle as PopupStyle;
335
336         /// <summary>
337         /// Popup Title.
338         /// </summary>
339         [EditorBrowsable(EditorBrowsableState.Never)]
340         public TextLabel Title
341         {
342             get
343             {
344                 if (null == titleText)
345                 {
346                     titleText = new TextLabel();
347                     Add(titleText);
348                 }
349                 return titleText;
350             }
351             internal set
352             {
353                 titleText = value;
354             }
355         }
356
357         /// <summary>
358         /// Title text string in Popup.
359         /// </summary>
360         /// <since_tizen> 6 </since_tizen>
361         public string TitleText
362         {
363             get
364             {
365                 return Style?.Title?.Text?.All;
366             }
367             set
368             {
369                 if (value != null)
370                 {
371                     if (Style?.Title != null)
372                     {
373                         Style.Title.Text = value;
374                     }
375                 }
376             }
377         }
378
379         /// <summary>
380         /// Title text point size in Popup.
381         /// </summary>
382         /// <since_tizen> 6 </since_tizen>
383         public float TitlePointSize
384         {
385             get
386             {
387                 return Style?.Title?.PointSize?.All ?? 0;
388             }
389             set
390             {
391                 if (Style?.Title != null)
392                 {
393                     Style.Title.PointSize = value;
394                 }
395             }
396         }
397
398         /// <summary>
399         /// Title text color in Popup.
400         /// </summary>
401         /// <since_tizen> 6 </since_tizen>
402         public Color TitleTextColor
403         {
404             get
405             {
406                 return Style?.Title?.TextColor?.All;
407             }
408             set
409             {
410                 if (Style?.Title != null)
411                 {
412                     Style.Title.TextColor = value;
413                 }
414             }
415         }
416
417         /// <summary>
418         /// Title text horizontal alignment in Popup.
419         /// </summary>
420         /// <since_tizen> 6 </since_tizen>
421         public HorizontalAlignment TitleTextHorizontalAlignment
422         {
423             get
424             {
425                 return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
426             }
427             set
428             {
429                 Style.Title.HorizontalAlignment = value;
430             }
431         }
432
433         /// <summary>
434         /// Title text's position in Popup.
435         /// </summary>
436         /// <since_tizen> 6 </since_tizen>
437         public Position TitleTextPosition
438         {
439             get
440             {
441                 return Style?.Title?.Position ?? new Position(0, 0, 0);
442             }
443             set
444             {
445                 Style.Title.Position = value;
446             }
447         }
448
449         /// <summary>
450         /// Title text's height in Popup.
451         /// </summary>
452         /// <since_tizen> 6 </since_tizen>
453         public int TitleHeight
454         {
455             get
456             {
457                 return (int)(Style?.Title?.Size?.Height ?? 0);
458             }
459             set
460             {
461                 if (Style?.Title?.Size != null)
462                 {
463                      Style.Title.Size.Height = value;
464                 }
465             }
466         }
467
468         /// <summary>
469         /// Content view in Popup, only can be gotten.
470         /// </summary>
471         /// <since_tizen> 6 </since_tizen>
472         public View ContentView
473         {
474             get;
475             private set;
476         }
477
478         /// <summary>
479         /// Button count in Popup.
480         /// </summary>
481         /// <since_tizen> 6 </since_tizen>
482         public int ButtonCount
483         {
484             get;
485             set;
486         }
487
488         /// <summary>
489         /// Button height in Popup.
490         /// </summary>
491         /// <since_tizen> 6 </since_tizen>
492         public int ButtonHeight
493         {
494             get
495             {
496                 return (int)GetValue(ButtonHeightProperty);
497             }
498             set
499             {
500                 SetValue(ButtonHeightProperty, value);
501             }
502         }
503
504         /// <summary>
505         /// Button text point size in Popup.
506         /// </summary>
507         /// <since_tizen> 6 </since_tizen>
508         public float ButtonTextPointSize
509         {
510             get
511             {
512                 return (float)GetValue(ButtonTextPointSizeProperty);
513             }
514             set
515             {
516                 SetValue(ButtonTextPointSizeProperty, value);
517             }
518         }
519
520         /// <summary>
521         /// Button text font family in Popup.
522         /// </summary>
523         /// <since_tizen> 6 </since_tizen>
524         public string ButtonFontFamily
525         {
526             get
527             {           
528                 return (string)GetValue(ButtonFontFamilyProperty);
529             }
530             set
531             {
532                 SetValue(ButtonFontFamilyProperty, value);
533             }
534         }
535
536         /// <summary>
537         /// Button text color in Popup.
538         /// </summary>
539         /// <since_tizen> 6 </since_tizen>
540         public Color ButtonTextColor
541         {
542             get
543             {
544                 return (Color)GetValue(ButtonTextColorProperty);
545             }
546             set
547             {
548                 SetValue(ButtonTextColorProperty, value);
549             }
550         }
551
552         /// <summary>
553         /// Button overlay background color selector in Popup.
554         /// </summary>
555         /// <since_tizen> 6 </since_tizen>
556         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
557         [EditorBrowsable(EditorBrowsableState.Never)]
558         public Selector<Color> ButtonOverLayBackgroundColorSelector
559         {
560             get
561             {
562                 return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
563             }
564             set
565             {
566                 SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
567             }
568         }
569
570         /// <summary>
571         /// Button text horizontal alignment in Popup.
572         /// </summary>
573         /// <since_tizen> 6 </since_tizen>
574         public HorizontalAlignment ButtonTextAlignment
575         {
576             get
577             {   
578                 return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
579             }
580             set
581             {
582                 SetValue(ButtonTextAlignmentProperty, value);
583             }
584         }
585
586         /// <summary>
587         /// Button background image's resource url in Popup.
588         /// </summary>
589         /// <since_tizen> 6 </since_tizen>
590         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
591         [EditorBrowsable(EditorBrowsableState.Never)]
592         public string ButtonBackground
593         {
594             get
595             {     
596                 return (string)GetValue(ButtonBackgroundProperty);
597             }
598             set
599             {
600                 SetValue(ButtonBackgroundProperty, value);
601             }
602         }
603
604         /// <summary>
605         /// Button background image's border in Popup.
606         /// </summary>
607         /// <since_tizen> 6 </since_tizen>
608         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
609         [EditorBrowsable(EditorBrowsableState.Never)]
610         public Rectangle ButtonBackgroundBorder
611         {
612             get
613             {
614                 
615                 return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
616             }
617             set
618             {
619                 SetValue(ButtonBackgroundBorderProperty, value);
620             }
621         }
622
623         /// <summary>
624         /// Button's image shadow in Popup.
625         /// </summary>
626         /// <since_tizen> 6 </since_tizen>
627         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
628         [EditorBrowsable(EditorBrowsableState.Never)]
629         public ImageShadow ButtonImageShadow
630         {
631             get => (ImageShadow)GetValue(ButtonImageShadowProperty);
632             set => SetValue(ButtonImageShadowProperty, value);
633         }
634
635
636         /// <summary>
637         /// Set button text by index.
638         /// </summary>
639         /// <param name="index">Button index.</param>
640         /// <param name="text">Button text string.</param>
641         /// <since_tizen> 6 </since_tizen>
642         public void SetButtonText(int index, string text)
643         {
644             AddButton(text);
645         }
646
647         /// <summary>
648         /// Dispose Popup and all children on it.
649         /// </summary>
650         /// <param name="type">Dispose type.</param>
651         /// <since_tizen> 6 </since_tizen>
652         protected override void Dispose(DisposeTypes type)
653         {
654             if (disposed)
655             {
656                 return;
657             }
658
659             if (type == DisposeTypes.Explicit)
660             {
661                 if (titleText != null)
662                 {
663                     Remove(titleText);
664                     titleText.Dispose();
665                     titleText = null;
666                 }
667                 if (ContentView != null)
668                 {
669                     Remove(ContentView);
670                     ContentView.Dispose();
671                     ContentView = null;
672                 }
673
674                 if (btGroup != null)
675                 {
676                     btGroup.Dispose();
677                     btGroup = null;
678                 }
679             }
680
681             base.Dispose(type);
682         }
683
684         /// <summary>
685         /// Focus gained callback.
686         /// </summary>
687         /// <since_tizen> 6 </since_tizen>
688         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
689         [EditorBrowsable(EditorBrowsableState.Never)]
690         public override void OnFocusGained()
691         {
692             base.OnFocusGained();
693         }
694
695         /// <summary>
696         /// Focus lost callback.
697         /// </summary>
698         /// <since_tizen> 6 </since_tizen>
699         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
700         [EditorBrowsable(EditorBrowsableState.Never)]
701         public override void OnFocusLost()
702         {
703             base.OnFocusLost();
704         }
705
706         /// <summary>
707         /// Apply style to popup.
708         /// </summary>
709         /// <param name="viewStyle">The style to apply.</param>
710         /// <since_tizen> 8 </since_tizen>
711         public override void ApplyStyle(ViewStyle viewStyle)
712         {
713             base.ApplyStyle(viewStyle);
714             PopupStyle ppStyle = viewStyle as PopupStyle;
715             if (null != ppStyle)
716             {
717                 Title.ApplyStyle(ppStyle.Title);
718                 Title.RaiseToTop();
719             }
720         }
721
722         /// <summary>
723         /// Get Popup style.
724         /// </summary>
725         /// <returns>The default popup style.</returns>
726         /// <since_tizen> 8 </since_tizen>
727         protected override ViewStyle GetViewStyle()
728         {
729             return new PopupStyle();
730         }
731
732         /// <summary>
733         /// Theme change callback when theme is changed, this callback will be trigger.
734         /// </summary>
735         /// <param name="sender">The sender</param>
736         /// <param name="e">The event data</param>
737         /// <since_tizen> 8 </since_tizen>
738         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
739         {
740             PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(style) as PopupStyle;
741             if (popupStyle != null)
742             {
743                 string strSaveTitleText = TitleText;
744                 Style.CopyFrom(popupStyle);
745                 Style.Title.Text = strSaveTitleText;
746                 UpdateView();
747             }
748         }
749
750         private void Initialize()
751         {
752             container.Add(this);
753             container.SetTouchConsumed(true);
754             container.SetHoverConsumed(true);
755
756             LeaveRequired = true;
757             PropertyChanged += PopupStylePropertyChanged;
758
759             // ContentView
760             ContentView = new View()
761             {
762                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
763                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
764                 PositionUsesPivotPoint = true
765             };
766             Add(ContentView);
767             ContentView.RaiseToTop();
768
769             // Button
770             btGroup = new ButtonGroup(this);
771         }
772
773         private void UpdateView()
774         {
775             btGroup.UpdateButton(Style.Buttons);
776             UpdateContentView();
777             UpdateTitle();
778         }
779
780         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
781         {
782             if (PopupButtonClickEvent != null && btGroup.Count > 0)
783             {
784                 Button button = sender as Button;
785                 for (int i = 0; i < btGroup.Count; i++)
786                 {
787                     if (button == GetButton(i))
788                     {
789                         ButtonClickEventArgs args = new ButtonClickEventArgs();
790                         args.ButtonIndex = i;
791                         PopupButtonClickEvent(this, args);
792                     }
793                 }
794             }
795         }
796
797         private void PopupStylePropertyChanged(object sender, PropertyChangedEventArgs e)
798         {
799             if (e.PropertyName.Equals("LayoutDirection"))
800             {
801                 btGroup.UpdateButton(Style.Buttons);
802             }
803         }
804
805         private void UpdateContentView()
806         {
807             int titleX = 0;
808             int titleY = 0;
809             int titleH = 0;
810             int buttonH = 0;
811             string strText = Style.Title.Text.All;
812             if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
813             {
814                 titleH = (int)titleText.Size.Height;
815             }
816
817             if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
818             {
819                 titleX = (int)Style.Title.Position.X;
820                 titleY = (int)Style.Title.Position.Y;
821             }
822
823             if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
824             {
825                 buttonH = (int)Style.Buttons.Size.Height;
826             }
827             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
828             ContentView.Position = new Position(titleX, titleY + titleH);
829             ContentView.RaiseToTop();
830         }
831
832         private void UpdateTitle()
833         {
834             if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
835             {
836                 titleText.RaiseToTop();
837             }
838         }
839         /// <summary>
840         /// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
841         /// </summary>
842         /// <since_tizen> 6 </since_tizen>
843         public class ButtonClickEventArgs : EventArgs
844         {
845             /// <summary> Button index which is clicked in Popup </summary>
846             /// <since_tizen> 6 </since_tizen>
847             public int ButtonIndex;
848         }
849     }
850 }