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