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