[NUI] Improve Theme load
authorJiyun Yang <ji.yang@samsung.com>
Mon, 7 Dec 2020 04:19:40 +0000 (13:19 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Dec 2020 06:33:59 +0000 (15:33 +0900)
* Provide default theme in C#: Xaml file IO and parsing time reduced
* Provide on demand theme loading for packages: This enables to avoid unnecessary package load

Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
22 files changed:
src/Tizen.NUI.Components/Controls/Control.cs
src/Tizen.NUI.Components/Controls/Scrollbar.cs
src/Tizen.NUI.Components/Controls/ScrollbarBase.cs
src/Tizen.NUI.Components/Style/ControlStyle.cs
src/Tizen.NUI.Components/Style/ScrollbarStyle.cs
src/Tizen.NUI.Components/Theme/DefaultTheme.cs [new file with mode: 0644]
src/Tizen.NUI.Components/Theme/DefaultThemeWearable.cs [new file with mode: 0644]
src/Tizen.NUI.Components/Tizen.NUI.Components.csproj
src/Tizen.NUI.Components/Utils/StyleManager.cs
src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml
src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj
src/Tizen.NUI.Wearable/src/internal/Theme/DefaultTheme.cs [new file with mode: 0644]
src/Tizen.NUI.Wearable/src/public/CircularPagination.cs
src/Tizen.NUI.Wearable/src/public/CircularProgress.cs
src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs
src/Tizen.NUI.Wearable/src/public/CircularSlider.cs
src/Tizen.NUI/Tizen.NUI.csproj
src/Tizen.NUI/src/public/NUIApplication.cs
src/Tizen.NUI/src/public/Theme/DefaultTheme.cs [new file with mode: 0644]
src/Tizen.NUI/src/public/Theme/DefaultThemeWearable.cs [new file with mode: 0644]
src/Tizen.NUI/src/public/Theme/Theme.cs
src/Tizen.NUI/src/public/Theme/ThemeManager.cs

index 06ba3c2..e6c121d 100755 (executable)
@@ -52,7 +52,10 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public ControlStyle Style => (ControlStyle)ViewStyle.Clone();
 
-        static Control() { }
+        static Control()
+        {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+        }
 
         /// <summary>
         /// Construct an empty Control.
index ffa7417..be66340 100755 (executable)
@@ -122,7 +122,7 @@ namespace Tizen.NUI.Components
         /// <summary>
         /// Create an empty Scrollbar.
         /// </summary>
-        public Scrollbar() : base()
+        public Scrollbar()
         {
         }
 
@@ -160,24 +160,6 @@ namespace Tizen.NUI.Components
         #region Properties
 
         /// <summary>
-        /// Return a copied Style instance of Scrollbar
-        /// </summary>
-        /// <remarks>
-        /// It returns copied Style instance and changing it does not effect to the Scrollbar.
-        /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
-        /// </remarks>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public new ScrollbarStyle Style
-        {
-            get
-            {
-                var result = new ScrollbarStyle(scrollbarStyle);
-                result.CopyPropertiesFromView(this);
-                return result;
-            }
-        }
-
-        /// <summary>
         /// The thickness of the track.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index f7acb4d..988651c 100755 (executable)
@@ -25,7 +25,7 @@ namespace Tizen.NUI.Components
     /// This only contains non-graphical functionalities of basic scrollbar.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public abstract class ScrollbarBase : VisualView
+    public abstract class ScrollbarBase : Control
     {
         private bool mScrollEnabled = true;
 
@@ -34,7 +34,7 @@ namespace Tizen.NUI.Components
         /// <summary>
         /// Create an empty ScrollbarBase.
         /// </summary>
-        public ScrollbarBase() : base(CustomViewBehaviour.ViewBehaviourDefault)
+        protected ScrollbarBase()
         {
         }
 
@@ -42,7 +42,7 @@ namespace Tizen.NUI.Components
         /// Create an empty Scrollbar with a ViewStyle instance to set style properties.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public ScrollbarBase(ViewStyle style) : base(CustomViewBehaviour.ViewBehaviourDefault, style)
+        protected ScrollbarBase(ControlStyle style) : base(style)
         {
         }
 
index 8e215fe..3500759 100755 (executable)
  * limitations under the License.
  *
  */
-using System.Collections.Generic;
 using System.ComponentModel;
 using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
 
 namespace Tizen.NUI.Components
 {
@@ -37,7 +35,10 @@ namespace Tizen.NUI.Components
 
         private bool isDisposeQueued = false;
 
-        static ControlStyle() { }
+        static ControlStyle()
+        {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+        }
 
         /// <summary>
         /// Creates a new instance of a ControlStyle.
index 0e04010..5077566 100644 (file)
@@ -24,7 +24,7 @@ namespace Tizen.NUI.Components
     /// ScrollbarStyle is a class which saves Scrollbar's style data.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public class ScrollbarStyle : ViewStyle
+    public class ScrollbarStyle : ControlStyle
     {
         #region Fields
 
diff --git a/src/Tizen.NUI.Components/Theme/DefaultTheme.cs b/src/Tizen.NUI.Components/Theme/DefaultTheme.cs
new file mode 100644 (file)
index 0000000..6ba08b3
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#if !PROFILE_WEARABLE
+
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Components
+{
+    // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
+    internal class DefaultThemeCreator : IThemeCreator
+    {
+        public Theme Create()
+        {
+            var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
+            {
+                Size = new Size(100, 45),
+                BackgroundColor = new Selector<Color>()
+                {
+                    Normal = new Color(0.88f, 0.88f, 0.88f, 1),
+                    Pressed = new Color(0.77f, 0.77f, 0.77f, 1),
+                    Disabled = new Color(0.88f, 0.88f, 0.88f, 1),
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 12,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = new Color(0.22f, 0.22f, 0.22f, 1),
+                        Pressed = new Color(0.11f, 0.11f, 0.11f, 1),
+                        Disabled = new Color(0.66f, 0.66f, 0.66f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
+            {
+                Size = new Size(30, 30),
+                Icon = new ImageViewStyle()
+                {
+                    Opacity = new Selector<float?>()
+                    {
+                        Normal = 1.0f,
+                        Disabled = 0.4f,
+                        Selected = 1.0f,
+                    },
+                    BackgroundImage = new Selector<string>()
+                    {
+                        Pressed = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
+                        Selected = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
+                        Other = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
+                    },
+                    ResourceUrl = new Selector<string>()
+                    {
+                        Pressed = "",
+                        Selected = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_s.png",
+                        Other = "",
+                    },
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 12,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = new Color(0.22f, 0.22f, 0.22f, 1),
+                        Pressed = new Color(0.11f, 0.11f, 0.11f, 1),
+                        Disabled = new Color(0.66f, 0.66f, 0.66f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
+            {
+                Size = new Size(500, 280),
+                BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1),
+                ImageShadow = new ImageShadow()
+                {
+                    Url = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
+                    Border = new Rectangle(24, 24, 24, 24),
+                    Extents = new Vector2(48, 48)
+                },
+                Title = new TextLabelStyle()
+                {
+                    PointSize = 16,
+                    Padding = new Extents(20, 20, 20, 20),
+                },
+                Buttons = new ButtonStyle()
+                {
+                    Size = new Size(0, 80),
+                    BackgroundColor = new Selector<Color>()
+                    {
+                        Normal = new Color(1, 1, 1, 1),
+                        Pressed = new Color(1, 1, 1, 0.5f),
+                    },
+                    Overlay = new ImageViewStyle()
+                    {
+                        BackgroundColor = new Selector<Color>()
+                        {
+                            Pressed = new Color(0, 0, 0, 0.1f),
+                            Other = new Color(1, 1, 1, 1),
+                        },
+                    },
+                    Text = new TextLabelStyle()
+                    {
+                        TextColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
+            {
+                Size = new Size(200, 5),
+                Track = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0, 0, 0, 0.1f),
+                },
+                Buffer = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 0.3f),
+                },
+                Progress = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
+            {
+                Size = new Size(30, 30),
+                Icon = new ImageViewStyle()
+                {
+                    Opacity = new Selector<float?>()
+                    {
+                        Normal = 1.0f,
+                        Disabled = 0.4f,
+                        Selected = 1.0f,
+                    },
+                    BackgroundImage = new Selector<string>()
+                    {
+                        Pressed = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_p.png",
+                        Selected = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_s.png",
+                        Other = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_n.png",
+                    }
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 12,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = new Color(0.22f, 0.22f, 0.22f, 1),
+                        Pressed = new Color(0.11f, 0.11f, 0.11f, 1),
+                        Disabled = new Color(0.66f, 0.66f, 0.66f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
+            {
+                Size = new Size(200, 50),
+                TrackThickness = 5,
+                Track = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0, 0, 0, 0.1f),
+                },
+                Progress = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+                Thumb = new ImageViewStyle()
+                {
+                    Size = new Size(50, 50),
+                    ResourceUrl = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
+                    BackgroundImage = new Selector<string>()
+                    {
+                        Normal = "",
+                        Pressed = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
+                    }
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
+            {
+                Size = new Size(96, 60),
+                Track = new ImageViewStyle()
+                {
+                    Size = new Size(96, 60),
+                    ResourceUrl = new Selector<string>()
+                    {
+                        Normal = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
+                        Selected = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
+                        Disabled = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
+                        DisabledSelected = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
+                    }
+                },
+                Thumb = new ImageViewStyle()
+                {
+                    Size = new Size(60, 60),
+                    ResourceUrl = new Selector<string>()
+                    {
+                        Normal = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
+                        Disabled = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
+                        Selected = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
+                    }
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 12,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = new Color(0.22f, 0.22f, 0.22f, 1),
+                        Pressed = new Color(0.11f, 0.11f, 0.11f, 1),
+                        Disabled = new Color(0.66f, 0.66f, 0.66f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
+            {
+                Size = new Size(480, 80),
+                BackgroundColor = Color.Yellow,
+                UnderLine = new ViewStyle()
+                {
+                    Size = new Size(0, 6),
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 16,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = Color.Black,
+                        Selected = new Color(0.05f, 0.63f, 0.9f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
+            {
+                Size = new Size(480, 80),
+                BackgroundColor = new Color(0, 0, 0, 0.8f),
+                Text = new TextLabelStyle()
+                {
+                    Padding = new Extents(12, 12, 8, 8)
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
+            {
+                LoadingSize = new Size(100, 100),
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
+            {
+                IndicatorImageUrl = new Selector<string>()
+                {
+                    Normal = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
+                    Selected = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
+            {
+                TrackThickness = 6,
+                ThumbThickness = 6,
+                TrackColor = new Color(1, 1, 1, 0.15f),
+                ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1),
+                TrackPadding = 4
+            });
+
+            return theme;
+        }
+    }
+}
+
+#endif
diff --git a/src/Tizen.NUI.Components/Theme/DefaultThemeWearable.cs b/src/Tizen.NUI.Components/Theme/DefaultThemeWearable.cs
new file mode 100644 (file)
index 0000000..7decf98
--- /dev/null
@@ -0,0 +1,247 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#if PROFILE_WEARABLE
+
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components.Extension;
+
+namespace Tizen.NUI.Components
+{
+    // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml
+    internal class DefaultThemeCreator : IThemeCreator
+    {
+        public Theme Create()
+        {
+            var theme = new Theme() { Id = "Tizen.NUI.Theme.Wearable" };
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
+            {
+                Size = new Size(500, 280),
+                BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1),
+                ImageShadow = new ImageShadow()
+                {
+                    Url = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
+                    Border = new Rectangle(24, 24, 24, 24),
+                    Extents = new Vector2(48, 48)
+                },
+                Title = new TextLabelStyle()
+                {
+                    PointSize = 16,
+                    Padding = new Extents(20, 20, 20, 20),
+                },
+                Buttons = new ButtonStyle()
+                {
+                    Size = new Size(0, 80),
+                    BackgroundColor = new Selector<Color>()
+                    {
+                        Normal = new Color(1, 1, 1, 1),
+                        Pressed = new Color(1, 1, 1, 0.5f),
+                    },
+                    Overlay = new ImageViewStyle()
+                    {
+                        BackgroundColor = new Selector<Color>()
+                        {
+                            Pressed = new Color(0, 0, 0, 0.1f),
+                            Other = new Color(1, 1, 1, 1),
+                        },
+                    },
+                    Text = new TextLabelStyle()
+                    {
+                        TextColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
+            {
+                Size = new Size(200, 5),
+                Track = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0, 0, 0, 0.1f),
+                },
+                Buffer = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 0.3f),
+                },
+                Progress = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
+            {
+                Size = new Size(200, 50),
+                TrackThickness = 5,
+                Track = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0, 0, 0, 0.1f),
+                },
+                Progress = new ImageViewStyle()
+                {
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+                Thumb = new ImageViewStyle()
+                {
+                    Size = new Size(50, 50),
+                    ResourceUrl = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
+                    BackgroundImage = new Selector<string>()
+                    {
+                        Normal = "",
+                        Pressed = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
+                    }
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
+            {
+                Size = new Size(480, 80),
+                BackgroundColor = Color.Yellow,
+                UnderLine = new ViewStyle()
+                {
+                    Size = new Size(0, 6),
+                    BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
+                },
+                Text = new TextLabelStyle()
+                {
+                    PointSize = 16,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = Color.Black,
+                        Selected = new Color(0.05f, 0.63f, 0.9f, 1),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
+            {
+                Size = new Size(480, 80),
+                BackgroundColor = new Color(0, 0, 0, 0.8f),
+                Text = new TextLabelStyle()
+                {
+                    Padding = new Extents(12, 12, 8, 8)
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
+            {
+                IndicatorImageUrl = new Selector<string>()
+                {
+                    Normal = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
+                    Selected = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
+            {
+                TrackThickness = 6,
+                ThumbThickness = 6,
+                TrackColor = new Color(1, 1, 1, 0.15f),
+                ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1),
+                TrackPadding = 4
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
+            {
+                Size = new Size(210, 72),
+                CornerRadius = 36,
+                BackgroundColor = new Selector<Color>()
+                {
+                    Normal = new Color(0, 0.1647f, 0.3019f, 0.85f),
+                    Pressed = new Color(0, 0.2475f, 0.5019f, 0.85f),
+                    Disabled = new Color(0.2392f, 0.2392f, 0.2392f, 0.85f),
+                },
+                Opacity = new Selector<float?>()
+                {
+                    Other = 1.0f,
+                    Disabled = 0.3f,
+                },
+                Text = new TextLabelStyle()
+                {
+                    FontFamily = "SamsungOne 700",
+                    PixelSize = 28,
+                    Padding = new Extents(20, 20, 0, 0),
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    TextColor = new Selector<Color>()
+                    {
+                        Normal = new Color(0.2196f, 0.6131f, 0.9882f, 1),
+                        Disabled = new Color(1, 1, 1, 0.35f),
+                    }
+                }
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new LottieButtonStyle()
+            {
+                LottieUrl = FrameworkInformation.ResourcePath + "nui_wearable_checkbox_icon.png",
+                PlayRange = new Selector<LottieFrameInfo>()
+                {
+                    Selected = new LottieFrameInfo(19, 36),
+                    Normal = new LottieFrameInfo(0, 18)
+                },
+                Opacity = new Selector<float?>()
+                {
+                    Other = 1.0f,
+                    Pressed = 0.6f,
+                    Disabled = 0.3f,
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new LottieButtonStyle()
+            {
+                LottieUrl = FrameworkInformation.ResourcePath + "nui_wearable_radiobutton_icon.png",
+                PlayRange = new Selector<LottieFrameInfo>()
+                {
+                    Selected = new LottieFrameInfo(0, 12),
+                    Normal = new LottieFrameInfo(13, 25)
+                },
+                Opacity = new Selector<float?>()
+                {
+                    Other = 1.0f,
+                    Pressed = 0.6f,
+                    Disabled = 0.3f,
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new LottieSwitchStyle()
+            {
+                LottieUrl = FrameworkInformation.ResourcePath + "nui_wearable_switch_icon.png",
+                PlayRange = new Selector<LottieFrameInfo>()
+                {
+                    Selected = new LottieFrameInfo(0, 18),
+                    Normal = new LottieFrameInfo(19, 36)
+                },
+                Opacity = new Selector<float?>()
+                {
+                    Other = 1.0f,
+                    Pressed = 0.6f,
+                    Disabled = 0.3f,
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
+            {
+                LoadingSize = new Size(360, 360),
+            });
+
+            return theme;
+        }
+    }
+}
+
+#endif
index f4bd4d6..7c42b25 100755 (executable)
@@ -13,7 +13,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <None Update="res\**">
+    <None Update="res\*.png">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
index f1ddb1c..23e6ccf 100755 (executable)
@@ -55,7 +55,7 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return ThemeManager.CurrentTheme?.Id;
+                return ThemeManager.CurrentTheme?.Id ?? ThemeManager.DefaultTheme.Id;
             }
             set
             {
index f4476bb..812f2d1 100644 (file)
   </cx:LottieButtonStyle>
 
   <!--Switch-->
-  <cx:LottieButtonStyle x:Key="Tizen.NUI.Components.Switch" LottieUrl="NUIResourcePath nui_wearable_switch_icon.json">
-    <cx:LottieButtonStyle.PlayRange>
+  <cx:LottieSwitchStyle x:Key="Tizen.NUI.Components.Switch" LottieUrl="NUIResourcePath nui_wearable_switch_icon.json">
+    <cx:LottieSwitchStyle.PlayRange>
       <Selector x:TypeArguments="LottieFrameInfo" Selected="0, 18" Normal="19, 36"/>
-    </cx:LottieButtonStyle.PlayRange>
-    <cx:LottieButtonStyle.Opacity>
+    </cx:LottieSwitchStyle.PlayRange>
+    <cx:LottieSwitchStyle.Opacity>
       <Selector x:TypeArguments="x:Single?" Other="1" Pressed="0.6" Disabled="0.3"/>
-    </cx:LottieButtonStyle.Opacity>
-  </cx:LottieButtonStyle>
+    </cx:LottieSwitchStyle.Opacity>
+  </cx:LottieSwitchStyle>
 
   <!--Loading-->
   <c:LoadingStyle x:Key="Tizen.NUI.Components.Loading" LoadingSize="360, 360" />
index 28d46df..420ef76 100755 (executable)
@@ -17,7 +17,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <None Update="res\**">
+    <None Update="res\*.png;res\*.json">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
diff --git a/src/Tizen.NUI.Wearable/src/internal/Theme/DefaultTheme.cs b/src/Tizen.NUI.Wearable/src/internal/Theme/DefaultTheme.cs
new file mode 100644 (file)
index 0000000..3a2560f
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Wearable
+{
+    internal class DefaultThemeCreator : IThemeCreator
+    {
+        public Theme Create()
+        {
+            var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Wearable.CircularPagination", new CircularPaginationStyle()
+            {
+                IndicatorSize = new Size(10, 10),
+                IndicatorImageURL = new Selector<string>()
+                {
+                    Normal = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
+                    Selected = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
+                },
+                CenterIndicatorImageURL = new Selector<string>()
+                {
+                    Normal = FrameworkInformation.ResourcePath + "nui_wearable_circular_pagination_center_normal_dot.png",
+                    Selected = FrameworkInformation.ResourcePath + "nui_wearable_circular_pagination_center_focus_dot.png",
+                },
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Wearable.CircularProgress", new CircularProgressStyle()
+            {
+                Thickness = 6,
+                MaxValue = 100,
+                MinValue = 0, 
+                CurrentValue = 0,
+                TrackColor = new Color(0, 0.16f, 0.3f, 1),
+                ProgressColor = new Color(0, 0.55f, 1, 1)
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Wearable.CircularScrollbar", new CircularScrollbarStyle()
+            {
+                Thickness = 10,
+                TrackSweepAngle = 60,
+                TrackColor = new Color(1, 1, 1, 0.15f),
+                ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1)
+            });
+
+            theme.AddStyleWithoutClone("Tizen.NUI.Wearable.CircularSlider", new CircularSliderStyle()
+            {
+                Thickness = 6,
+                MaxValue = 100,
+                MinValue = 0,
+                CurrentValue = 0,
+                TrackColor = new Color(0, 0.16f, 0.3f, 1),
+                ProgressColor = new Color(0, 0.55f, 1, 1),
+                ThumbSize = new Size(19, 19),
+                ThumbColor = new Color(0, 0.55f, 1, 1)
+            });
+
+            return theme;
+        }
+    }
+}
index c9e0436..923ea7e 100755 (executable)
@@ -62,7 +62,10 @@ namespace Tizen.NUI.Wearable
                                                    new Position2D(237, 14), new Position2D(253, 22), new Position2D(269, 31), new Position2D(283, 41),
                                                    new Position2D(297, 53), new Position2D(309, 67) };
 
-        static CircularPagination() { }
+        static CircularPagination()
+        {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+        }
 
         /// <summary>
         /// Creates a new instance of a CircularPagination.
index 61873ae..855d63d 100755 (executable)
@@ -158,7 +158,11 @@ namespace Tizen.NUI.Wearable
 
         #region Constructors
 
-        static CircularProgress() { }
+        static CircularProgress()
+        {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+        }
+
         /// <summary>
         /// The constructor of CircularProgress.
         /// Basically, CircularProgress is for full screen. (360 x 360)
index 6bb32a1..a44d367 100755 (executable)
@@ -137,6 +137,7 @@ namespace Tizen.NUI.Wearable
         /// </summary>
         static CircularScrollbar()
         {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
         }
 
         #endregion Constructors
index 5a1c7f1..39499bd 100755 (executable)
@@ -213,7 +213,11 @@ namespace Tizen.NUI.Wearable
 
         #region Constructors
 
-        static CircularSlider() { }
+        static CircularSlider()
+        {
+            ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+        }
+
         /// <summary>
         /// The constructor of CircularSlider.
         /// </summary>
index 212e21f..bcffc90 100644 (file)
     </ItemGroup>
   </Target>
 
-  <ItemGroup>
-    <None Update="res\**">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
-
 </Project>
\ No newline at end of file
index 2326ced..5629d0d 100755 (executable)
@@ -386,7 +386,6 @@ namespace Tizen.NUI
         static public void PreLoad()
         {
             Interop.Application.PreInitialize();
-            ThemeManager.EnsureDefaultTheme();
             isPreLoad = true;
         }
 
diff --git a/src/Tizen.NUI/src/public/Theme/DefaultTheme.cs b/src/Tizen.NUI/src/public/Theme/DefaultTheme.cs
new file mode 100644 (file)
index 0000000..6787990
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#if !PROFILE_WEARABLE
+
+namespace Tizen.NUI
+{
+    internal class DefaultThemeCreator : IThemeCreator
+    {
+        public Theme Create()
+        {
+            return new Theme() { Id = "Tizen.NUI.Theme.Common" };
+        }
+    }
+}
+
+#endif
diff --git a/src/Tizen.NUI/src/public/Theme/DefaultThemeWearable.cs b/src/Tizen.NUI/src/public/Theme/DefaultThemeWearable.cs
new file mode 100644 (file)
index 0000000..6ebce9b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#if PROFILE_WEARABLE
+
+namespace Tizen.NUI
+{
+    internal class DefaultThemeCreator : IThemeCreator
+    {
+        public Theme Create()
+        {
+            return new Theme() { Id = "Tizen.NUI.Theme.Wearable" };
+        }
+    }
+}
+
+#endif
index 436362c..136ef0e 100755 (executable)
@@ -271,7 +271,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void Merge(string xamlFile)
         {
-            Merge(new Theme(xamlFile));
+            MergeWithoutClone(new Theme(xamlFile));
         }
 
         /// <summary>Merge other Theme into this.</summary>
@@ -284,6 +284,32 @@ namespace Tizen.NUI
 
             this.xamlFile = theme.xamlFile;
 
+            if (Id == null) Id = theme.Id;
+
+            foreach (var item in theme)
+            {
+                if (item.Value == null)
+                {
+                    map[item.Key] = null;
+                }
+                else if (map.ContainsKey(item.Key) && !item.Value.SolidNull)
+                {
+                    map[item.Key].Merge(item.Value);
+                }
+                else
+                {
+                    map[item.Key] = item.Value.Clone();
+                }
+            }
+        }
+
+        internal void MergeWithoutClone(Theme theme)
+        {
+            if (theme == null)
+                throw new ArgumentNullException(nameof(theme));
+
+            if (Id == null) Id = theme.Id;
+
             foreach (var item in theme)
             {
                 if (item.Value == null)
@@ -292,11 +318,11 @@ namespace Tizen.NUI
                 }
                 else if (map.ContainsKey(item.Key) && !item.Value.SolidNull)
                 {
-                    map[item.Key].Merge(theme.GetStyle(item.Key));
+                    map[item.Key].Merge(item.Value);
                 }
                 else
                 {
-                    map[item.Key] = theme.GetStyle(item.Key).Clone();
+                    map[item.Key] = item.Value;
                 }
             }
         }
index 061056b..6ef43b6 100755 (executable)
  * limitations under the License.
  *
  */
-extern alias TizenSystemInformation;
-using TizenSystemInformation.Tizen.System;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
-using System.IO;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 
 namespace Tizen.NUI
 {
+    internal interface IThemeCreator
+    {
+        Theme Create();
+    }
+
     /// <summary>
     /// This static module provides methods that can manage NUI <seealso cref="Theme"/>.
     /// </summary>
@@ -35,17 +37,10 @@ namespace Tizen.NUI
     /// ThemeManager.ApplyTheme(customTheme);
     /// </code>
     /// </example>
+    /// <summary></summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
     public static class ThemeManager
     {
-        private enum Profile
-        {
-            Common = 0,
-            Mobile = 1,
-            TV = 2,
-            Wearable = 3
-        }
-
         private static readonly string[] nuiThemeProjects =
         {
             "Tizen.NUI",
@@ -53,26 +48,17 @@ namespace Tizen.NUI
             "Tizen.NUI.Wearable"
         };
 
-        /// <summary>
-        /// Table that indicates default theme id by device profile.
-        /// Note that, the fallback of null value is Common value.
-        /// </summary>
-        private static readonly string[] profileDefaultTheme =
-        {
-            /* Common   */ "Tizen.NUI.Theme.Common",
-            /* Mobile   */ "Tizen.NUI.Theme.Common",
-            /* TV       */ null,
-            /* Wearable */ "Tizen.NUI.Theme.Wearable",
-        };
-
         private static Theme currentTheme;
         private static Theme defaultTheme;
-        private static bool isLoadingDefault = false;
-        private static Profile? currentProfile;
         private static readonly List<Theme> builtinThemes = new List<Theme>(); // Themes provided by framework.
-        internal static List<Theme> customThemes = new List<Theme>(); // Themes registered by user.
+        private static readonly List<Theme> customThemes = new List<Theme>(); // Themes registered by user. (Legacy support)
+        private static readonly List<string> packages = new List<string>();
 
-        static ThemeManager() { }
+        static ThemeManager()
+        {
+            defaultTheme = new DefaultThemeCreator().Create();
+            builtinThemes.Add(defaultTheme);
+        }
 
         /// <summary>
         /// An event invoked after the theme has changed by <seealso cref="ApplyTheme(Theme)"/>.
@@ -87,7 +73,7 @@ namespace Tizen.NUI
 
         internal static Theme CurrentTheme
         {
-            get => currentTheme ?? (currentTheme = DefaultTheme);
+            get => currentTheme;
             set
             {
                 currentTheme = value;
@@ -95,58 +81,16 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// The fallback theme that depends on the device profile.
+        /// </summary>
         internal static Theme DefaultTheme
         {
-            get
-            {
-                EnsureDefaultTheme();
-                return defaultTheme;
-            }
+            get => defaultTheme;
             set => defaultTheme = (Theme)value?.Clone();
         }
 
-        internal static bool ThemeApplied => (CurrentTheme.Count > 0 || DefaultTheme.Count > 0);
-
-        private static Profile CurrentProfile
-        {
-            get
-            {
-                if (currentProfile == null)
-                {
-                    currentProfile = Profile.Common;
-                    string profileString = "";
-
-                    try
-                    {
-                        Information.TryGetValue<string>("tizen.org/feature/profile", out profileString);
-                        Tizen.Log.Info("NUI", "Profile for initial theme found : " + profileString);
-                    }
-                    catch
-                    {
-                        // Note
-                        // Do not rethrow exception.
-                        // In some machine, profile may not exits.
-                        Tizen.Log.Info("NUI", "Unknown device profile\n");
-                    }
-                    finally
-                    {
-                        if (string.Equals(profileString, "mobile"))
-                        {
-                            currentProfile = Profile.Mobile;
-                        }
-                        else if (string.Equals(profileString, "tv"))
-                        {
-                            currentProfile = Profile.TV;
-                        }
-                        else if (string.Equals(profileString, "wearable"))
-                        {
-                            currentProfile = Profile.Wearable;
-                        }
-                    }
-                }
-                return (Profile)currentProfile;
-            }
-        }
+        internal static bool ThemeApplied => DefaultTheme.Count > 0 || (currentTheme != null && currentTheme.Count > 0);
 
         /// <summary>
         /// Set a theme to be used as fallback.
@@ -255,7 +199,7 @@ namespace Tizen.NUI
 
             if (!ThemeApplied) return null;
 
-            return (CurrentTheme.GetStyle(styleName) ?? DefaultTheme.GetStyle(styleName))?.Clone();
+            return (CurrentTheme?.GetStyle(styleName) ?? DefaultTheme.GetStyle(styleName))?.Clone();
         }
 
         /// <summary>
@@ -270,7 +214,7 @@ namespace Tizen.NUI
 
             if (!ThemeApplied) return null;
 
-            return (CurrentTheme.GetStyle(viewType) ?? DefaultTheme.GetStyle(viewType))?.Clone();
+            return (CurrentTheme?.GetStyle(viewType) ?? DefaultTheme.GetStyle(viewType))?.Clone();
         }
 
         /// <summary>
@@ -298,14 +242,15 @@ namespace Tizen.NUI
             return (Theme)result?.Clone();
         }
 
-        internal static void EnsureDefaultTheme()
+        internal static void AddPackageTheme(IThemeCreator themeCreator)
         {
-            if (defaultTheme == null && !isLoadingDefault)
+            string name = themeCreator.GetType().FullName;
+            if (packages.FindIndex(x => string.Equals(x, name)) >= 0)
             {
-                isLoadingDefault = true;
-                defaultTheme = LoadBuiltinTheme(profileDefaultTheme[(int)CurrentProfile]);
-                isLoadingDefault = false;
+                return;
             }
+            packages.Add(name);
+            DefaultTheme.MergeWithoutClone(themeCreator.Create());
         }
 
         private static Theme LoadBuiltinTheme(string id)
@@ -317,28 +262,7 @@ namespace Tizen.NUI
 
             if (string.IsNullOrEmpty(id)) return loaded;
 
-            foreach (var project in nuiThemeProjects)
-            {
-                string path = FrameworkInformation.ResourcePath + "/Theme/" + project + "_" + id + ".xaml";
-
-                if (!File.Exists(path))
-                {
-                    Tizen.Log.Info("NUI", $"\"{path}\" is not found in this profile.\n");
-                    continue;
-                }
-
-                try
-                {
-                    loaded.Merge(path);
-                    loaded.Id = id;
-                    Tizen.Log.Info("NUI", $"Done to load \"{path}\".\n");
-                }
-                catch (Exception e)
-                {
-                    Tizen.Log.Debug("NUI", $"Could not load \"{path}\"\n");
-                    Tizen.Log.Debug("NUI", "Message: " + e + "\n");
-                }
-            }
+            // TODO
 
             return loaded;
         }