[EditorBrowsable(EditorBrowsableState.Never)]
public ControlStyle Style => (ControlStyle)ViewStyle.Clone();
- static Control() { }
+ static Control()
+ {
+ ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+ }
/// <summary>
/// Construct an empty Control.
/// <summary>
/// Create an empty Scrollbar.
/// </summary>
- public Scrollbar() : base()
+ public Scrollbar()
{
}
#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)]
/// 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;
/// <summary>
/// Create an empty ScrollbarBase.
/// </summary>
- public ScrollbarBase() : base(CustomViewBehaviour.ViewBehaviourDefault)
+ protected ScrollbarBase()
{
}
/// 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)
{
}
* limitations under the License.
*
*/
-using System.Collections.Generic;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
namespace Tizen.NUI.Components
{
private bool isDisposeQueued = false;
- static ControlStyle() { }
+ static ControlStyle()
+ {
+ ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+ }
/// <summary>
/// Creates a new instance of a ControlStyle.
/// ScrollbarStyle is a class which saves Scrollbar's style data.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ScrollbarStyle : ViewStyle
+ public class ScrollbarStyle : ControlStyle
{
#region Fields
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
</ItemGroup>
<ItemGroup>
- <None Update="res\**">
+ <None Update="res\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
{
get
{
- return ThemeManager.CurrentTheme?.Id;
+ return ThemeManager.CurrentTheme?.Id ?? ThemeManager.DefaultTheme.Id;
}
set
{
</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" />
</ItemGroup>
<ItemGroup>
- <None Update="res\**">
+ <None Update="res\*.png;res\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
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.
#region Constructors
- static CircularProgress() { }
+ static CircularProgress()
+ {
+ ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+ }
+
/// <summary>
/// The constructor of CircularProgress.
/// Basically, CircularProgress is for full screen. (360 x 360)
/// </summary>
static CircularScrollbar()
{
+ ThemeManager.AddPackageTheme(new DefaultThemeCreator());
}
#endregion Constructors
#region Constructors
- static CircularSlider() { }
+ static CircularSlider()
+ {
+ ThemeManager.AddPackageTheme(new DefaultThemeCreator());
+ }
+
/// <summary>
/// The constructor of CircularSlider.
/// </summary>
</ItemGroup>
</Target>
- <ItemGroup>
- <None Update="res\**">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
-
</Project>
\ No newline at end of file
static public void PreLoad()
{
Interop.Application.PreInitialize();
- ThemeManager.EnsureDefaultTheme();
isPreLoad = true;
}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
[EditorBrowsable(EditorBrowsableState.Never)]
public void Merge(string xamlFile)
{
- Merge(new Theme(xamlFile));
+ MergeWithoutClone(new Theme(xamlFile));
}
/// <summary>Merge other Theme into this.</summary>
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)
}
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;
}
}
}
* 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>
/// 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",
"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)"/>.
internal static Theme CurrentTheme
{
- get => currentTheme ?? (currentTheme = DefaultTheme);
+ get => currentTheme;
set
{
currentTheme = value;
}
}
+ /// <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.
if (!ThemeApplied) return null;
- return (CurrentTheme.GetStyle(styleName) ?? DefaultTheme.GetStyle(styleName))?.Clone();
+ return (CurrentTheme?.GetStyle(styleName) ?? DefaultTheme.GetStyle(styleName))?.Clone();
}
/// <summary>
if (!ThemeApplied) return null;
- return (CurrentTheme.GetStyle(viewType) ?? DefaultTheme.GetStyle(viewType))?.Clone();
+ return (CurrentTheme?.GetStyle(viewType) ?? DefaultTheme.GetStyle(viewType))?.Clone();
}
/// <summary>
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)
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;
}