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