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