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