Revert "[NUI] Refactoring Theme and StyleManager (#1981)" (#2013)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Popup.cs
index 3b66487..9a44d4a 100755 (executable)
@@ -35,9 +35,9 @@ namespace Tizen.NUI.Components
         public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Popup)bindable;
-            if (newValue != null && instance?.Style?.Buttons?.Size != null )
+            if (newValue != null && instance?.popupStyle?.Buttons?.Size != null )
             {
-                instance.Style.Buttons.Size.Height = (int)newValue;
+                instance.popupStyle.Buttons.Size.Height = (int)newValue;
                 instance.btGroup.Itemheight = (int)newValue;
                 instance.UpdateView();
             }
@@ -45,7 +45,7 @@ namespace Tizen.NUI.Components
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return (int)(instance.Style?.Buttons?.Size?.Height ?? 0);
+            return (int)(instance.popupStyle?.Buttons?.Size?.Height ?? 0);
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -55,9 +55,9 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                if (instance.Style?.Buttons?.Text != null)
+                if (instance.popupStyle?.Buttons?.Text != null)
                 {
-                    instance.Style.Buttons.Text.PointSize = (float)newValue;
+                    instance.popupStyle.Buttons.Text.PointSize = (float)newValue;
                 }
                 instance.btGroup.ItemPointSize = (float)newValue;
             }
@@ -65,7 +65,7 @@ namespace Tizen.NUI.Components
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0;
+            return instance.popupStyle?.Buttons?.Text?.PointSize?.All ?? 0;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -75,14 +75,14 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                instance.Style.Buttons.Text.FontFamily = (string)newValue;
+                instance.popupStyle.Buttons.Text.FontFamily = (string)newValue;
                 instance.btGroup.ItemFontFamily = (string)newValue;
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.Text?.FontFamily.All;
+            return instance.popupStyle?.Buttons?.Text?.FontFamily.All;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -92,9 +92,9 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {  
-                if (instance.Style?.Buttons?.Text != null)
+                if (instance.popupStyle?.Buttons?.Text != null)
                 {
-                    instance.Style.Buttons.Text.TextColor = (Color)newValue;
+                    instance.popupStyle.Buttons.Text.TextColor = (Color)newValue;
                 }
                 instance.btGroup.ItemTextColor = (Color)newValue;
             }
@@ -102,7 +102,7 @@ namespace Tizen.NUI.Components
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.Text?.TextColor?.All;
+            return instance.popupStyle?.Buttons?.Text?.TextColor?.All;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -112,14 +112,14 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
+                instance.popupStyle.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
                 instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.Overlay?.BackgroundColor;
+            return instance.popupStyle?.Buttons?.Overlay?.BackgroundColor;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -129,14 +129,14 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
+                instance.popupStyle.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
                 instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
+            return instance.popupStyle?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -146,18 +146,19 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                if (instance.Style.Buttons.BackgroundImage == null)
+                if (instance.popupStyle.Buttons.BackgroundImage == null)
                 {
-                    instance.Style.Buttons.BackgroundImage = new Selector<string>();
+                    instance.popupStyle.Buttons.BackgroundImage = new Selector<string>();
                 }
+                instance.popupStyle.Buttons.BackgroundColor = new Selector<Color>();
+                instance.popupStyle.Buttons.BackgroundImage = (string)newValue;
                 instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
-                instance.Style.Buttons.BackgroundImage = (string)newValue;
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.BackgroundImage?.All;
+            return instance.popupStyle?.Buttons?.BackgroundImage?.All;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -167,18 +168,18 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null)
             {
-                if (instance.Style.Buttons.BackgroundImageBorder == null)
+                if (instance.popupStyle.Buttons.BackgroundImageBorder == null)
                 {
-                    instance.Style.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
+                    instance.popupStyle.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
                 }
-                instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue;
+                instance.popupStyle.Buttons.BackgroundImageBorder = (Rectangle)newValue;
                 instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.BackgroundImageBorder?.All;
+            return instance.popupStyle?.Buttons?.BackgroundImageBorder?.All;
         });
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -188,15 +189,16 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             ImageShadow shadow = (ImageShadow)newValue;
             instance.btGroup.ItemImageShadow = new ImageShadow(shadow);
-            instance.Style.Buttons.ImageShadow = new ImageShadow(shadow);
+            instance.popupStyle.Buttons.ImageShadow = new ImageShadow(shadow);
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Popup)bindable;
-            return instance.Style?.Buttons?.ImageShadow?.All;
+            return instance.popupStyle?.Buttons?.ImageShadow?.All;
         });
 
 
+        private PopupStyle popupStyle => ViewStyle as PopupStyle;
         private TextLabel titleText;
         private ButtonGroup btGroup = null;
         private Window window = null;
@@ -266,10 +268,10 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void AddButton(string buttonText)
         {
-            if (Style.Buttons != null)
+            if (popupStyle.Buttons != null)
             {
-                Button btn = new Button(Style.Buttons);
-                btn.Style.Text.Text = buttonText;
+                Button btn = new Button(popupStyle.Buttons);
+                btn.Text = buttonText;
                 btn.ClickEvent += ButtonClickEvent;
                 btGroup.AddItem(btn);
                 UpdateView();
@@ -291,9 +293,9 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void AddButton(string buttonText, ButtonStyle style)
         {
-            if (Style.Buttons != null && style != null)
+            if (popupStyle.Buttons != null && style != null)
             {
-                Style.Buttons.CopyFrom(style);
+                popupStyle.Buttons.CopyFrom(style);
                 AddButton(buttonText);
             }
         }
@@ -334,7 +336,16 @@ namespace Tizen.NUI.Components
         /// Get style of popup.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public new PopupStyle Style => ViewStyle as PopupStyle;
+        public new PopupStyle Style
+        {
+            get
+            {
+                var result = new PopupStyle(popupStyle);
+                result.CopyPropertiesFromView(this);
+                result.Title.CopyPropertiesFromView(titleText);
+                return result;
+            }
+        }
 
         /// <summary>
         /// Popup Title.
@@ -366,15 +377,15 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Title?.Text?.All;
+                return popupStyle?.Title?.Text?.All;
             }
             set
             {
                 if (value != null)
                 {
-                    if (Style?.Title != null)
+                    if (popupStyle?.Title != null)
                     {
-                        Style.Title.Text = value;
+                        popupStyle.Title.Text = value;
                     }
                 }
             }
@@ -389,13 +400,13 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Title?.PointSize?.All ?? 0;
+                return popupStyle?.Title?.PointSize?.All ?? 0;
             }
             set
             {
-                if (Style?.Title != null)
+                if (popupStyle?.Title != null)
                 {
-                    Style.Title.PointSize = value;
+                    popupStyle.Title.PointSize = value;
                 }
             }
         }
@@ -409,13 +420,13 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Title?.TextColor?.All;
+                return popupStyle?.Title?.TextColor?.All;
             }
             set
             {
-                if (Style?.Title != null)
+                if (popupStyle?.Title != null)
                 {
-                    Style.Title.TextColor = value;
+                    popupStyle.Title.TextColor = value;
                 }
             }
         }
@@ -429,11 +440,11 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
+                return popupStyle?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
             }
             set
             {
-                Style.Title.HorizontalAlignment = value;
+                popupStyle.Title.HorizontalAlignment = value;
             }
         }
 
@@ -446,11 +457,11 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Title?.Position ?? new Position(0, 0, 0);
+                return popupStyle?.Title?.Position ?? new Position(0, 0, 0);
             }
             set
             {
-                Style.Title.Position = value;
+                popupStyle.Title.Position = value;
             }
         }
 
@@ -463,13 +474,13 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return (int)(Style?.Title?.Size?.Height ?? 0);
+                return (int)(popupStyle?.Title?.Size?.Height ?? 0);
             }
             set
             {
-                if (Style?.Title?.Size != null)
+                if (popupStyle?.Title?.Size != null)
                 {
-                     Style.Title.Size.Height = value;
+                    popupStyle.Title.Size.Height = value;
                 }
             }
         }
@@ -755,12 +766,10 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
         {
-            PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle;
-            if (popupStyle != null)
+            PopupStyle ppStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle;
+            if (ppStyle != null)
             {
-                string strSaveTitleText = TitleText;
-                Style.CopyFrom(popupStyle);
-                Style.Title.Text = strSaveTitleText;
+                ApplyStyle(ppStyle);
                 UpdateView();
             }
         }
@@ -790,7 +799,7 @@ namespace Tizen.NUI.Components
 
         private void UpdateView()
         {
-            btGroup.UpdateButton(Style.Buttons);
+            btGroup.UpdateButton(popupStyle.Buttons);
             UpdateContentView();
             UpdateTitle();
         }
@@ -816,7 +825,7 @@ namespace Tizen.NUI.Components
         {
             if (e.PropertyName.Equals("LayoutDirection"))
             {
-                btGroup.UpdateButton(Style.Buttons);
+                btGroup.UpdateButton(popupStyle.Buttons);
             }
         }
 
@@ -826,21 +835,21 @@ namespace Tizen.NUI.Components
             int titleY = 0;
             int titleH = 0;
             int buttonH = 0;
-            string strText = Style.Title.Text.All;
-            if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
+            string strText = Title.Text;
+            if (!string.IsNullOrEmpty(strText) && Title.Size != null)
             {
                 titleH = (int)titleText.Size.Height;
             }
 
-            if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
+            if (!string.IsNullOrEmpty(strText) && Title.Position != null)
             {
-                titleX = (int)Style.Title.Position.X;
-                titleY = (int)Style.Title.Position.Y;
+                titleX = (int)Title.Position.X;
+                titleY = (int)Title.Position.Y;
             }
 
-            if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
+            if (btGroup.Count != 0 && popupStyle?.Buttons?.Size != null )
             {
-                buttonH = (int)Style.Buttons.Size.Height;
+                buttonH = (int)popupStyle.Buttons.Size.Height;
             }
             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
             ContentView.Position = new Position(titleX, titleY + titleH);
@@ -849,7 +858,7 @@ namespace Tizen.NUI.Components
 
         private void UpdateTitle()
         {
-            if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
+            if (titleText != null && string.IsNullOrEmpty(popupStyle.Title.Text.All) && popupStyle.Title.Size != null)
             {
                 titleText.RaiseToTop();
             }