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