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