2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #if !PROFILE_WEARABLE && !PROFILE_MOBILE
19 using System.Collections.Generic;
20 using System.Diagnostics.CodeAnalysis;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Binding;
24 namespace Tizen.NUI.Components
26 // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
27 internal class DefaultThemeCreator : IThemeCreator
29 private DefaultThemeCreator() { }
31 public static IThemeCreator Instance { get; set; } = new DefaultThemeCreator();
33 public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
35 ["ButtonBackgroundColorNormal"] = new Color(0.039f, 0.055f, 0.29f, 1),
36 ["ButtonBackgroundColorFocused"] = new Color(0, 0.2f, 0.545f, 1),
37 ["ButtonBackgroundColorPressed"] = new Color(0.106f, 0.412f, 0.792f, 1),
38 ["ButtonBackgroundColorDisabled"] = new Color(0.765f, 0.792f, 0.824f, 1),
39 ["ButtonTextColorNormal"] = Color.White,
40 ["ButtonTextColorPressed"] = Color.White,
41 ["ButtonTextColorDisabled"] = Color.White,
42 ["CheckBoxIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
43 ["CheckBoxIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
44 ["CheckBoxIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
45 ["CheckBoxIconImageResourceUrlPressed"] = "",
46 ["CheckBoxIconImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_s.png",
47 ["CheckBoxIconImageResourceUrlOther"] = "",
48 ["CheckBoxTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
49 ["CheckBoxTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
50 ["CheckBoxTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
51 ["DropDownBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
52 ["DropDownBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
53 ["DropDownIconImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_button_icon.png",
54 ["DropDownListBackgroundImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_list_bg.png",
55 ["DropDownDataItemBackgroundColorPressed"] = new Color(0.05f, 0.63f, 0.9f, 1),
56 ["DropDownDataItemBackgroundColorSelected"] = new Color(0.8f, 0.8f, 0.8f, 1),
57 ["DropDownDataItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
58 ["PopupBackgroundColor"] = new Color(0.9f, 0.9f, 0.9f, 1),
59 ["PopupImageShadowUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
60 ["PopupButtonBackgroundColorNormal"] = new Color(1, 1, 1, 1),
61 ["PopupButtonBackgroundColorPressed"] = new Color(1, 1, 1, 0.5f),
62 ["PopupButtonOverlayBackgroundColorNormal"] = new Color(1, 1, 1, 1),
63 ["PopupButtonOverlayBackgroundColorPressed"] = new Color(0, 0, 0, 0.1f),
64 ["PopupButtonOverlayBackgroundColorSelected"] = new Color(1, 1, 1, 1),
65 ["PopupButtonTextColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
66 ["ProgressTrackBackgroundColor"] = new Color(0, 0, 0, 0.1f),
67 ["ProgressBufferBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 0.3f),
68 ["ProgressProgressBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
69 ["RadioButtonIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_p.png",
70 ["RadioButtonIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_s.png",
71 ["RadioButtonIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_n.png",
72 ["RadioButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
73 ["RadioButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
74 ["RadioButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
75 ["SliderTrackColor"] = new Color(0, 0, 0, 0.1f),
76 ["SliderProgressColor"] = new Color(0.5f, 0.63f, 0.9f, 1),
77 ["SliderThumbImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
78 ["SliderThumbBackgroundImageNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
79 ["SliderThumbBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
80 ["SliderValueIndicatorImage"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_value_indicator.png",
81 ["SwitchTrackImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
82 ["SwitchTrackImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
83 ["SwitchTrackImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
84 ["SwitchTrackImageResourceUrlDisabledSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
85 ["SwitchThumbImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
86 ["SwitchThumbImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
87 ["SwitchThumbImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
88 ["SwitchTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
89 ["SwitchTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
90 ["SwitchTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
91 ["TabBackgroundColor"] = Color.Yellow,
92 ["TabUnderLineBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1.0f),
93 ["TabTextColorNormal"] = Color.Black,
94 ["TabTextColorSelected"] = new Color(0.05f, 0.63f, 0.9f, 1),
95 ["ToastBackgroundColor"] = new Color(0, 0, 0, 0.8f),
96 ["PaginationIndicatorImageUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
97 ["PaginationIndicatorImageUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
98 ["ScrollbarTrackColor"] = new Color(1, 1, 1, 0.15f),
99 ["ScrollbarThumbColor"] = new Color(0.6f, 0.6f, 0.6f, 1.0f),
102 public Theme Create() => Create(null);
104 [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
105 public Theme Create(IEnumerable<KeyValuePair<string, string>> changedResources)
107 var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
109 theme.SetChangedResources(changedResources);
110 theme.Resources = CreateThemeResource();
111 theme.OnThemeResourcesChanged();
113 theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
115 Size = new Size(339, 96),
117 BackgroundColor = new Selector<Color>()
119 Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
120 Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
121 Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
123 Text = new TextLabelStyle()
126 TextColor = new Selector<Color>()
128 Normal = (Color)theme.Resources["ButtonTextColorNormal"],
129 Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
130 Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
135 theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
137 Size = new Size(30, 30),
138 Icon = new ImageViewStyle()
140 Opacity = new Selector<float?>()
146 BackgroundImage = new Selector<string>()
148 Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
149 Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
150 Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
152 ResourceUrl = new Selector<string>()
154 Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
155 Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
156 Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
159 Text = new TextLabelStyle()
162 TextColor = new Selector<Color>()
164 Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
165 Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
166 Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
171 theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
173 Size = new Size(500, 280),
174 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
175 ImageShadow = new ImageShadow()
177 Url = (string)theme.Resources["PopupImageShadowUrl"],
178 Border = new Rectangle(24, 24, 24, 24),
179 Extents = new Vector2(48, 48)
181 Title = new TextLabelStyle()
184 Padding = new Extents(20, 20, 20, 20),
186 Buttons = new ButtonStyle()
188 Size = new Size(0, 80),
189 BackgroundColor = new Selector<Color>()
191 Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
192 Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
194 Overlay = new ImageViewStyle()
196 BackgroundColor = new Selector<Color>()
198 Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
199 Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
200 Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
203 Text = new TextLabelStyle()
205 TextColor = (Color)theme.Resources["PopupButtonTextColor"],
210 theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
212 Size = new Size(200, 5),
213 Track = new ImageViewStyle()
215 BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
217 Buffer = new ImageViewStyle()
219 BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
221 Progress = new ImageViewStyle()
223 BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
227 theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
229 Size = new Size(30, 30),
230 Icon = new ImageViewStyle()
232 Opacity = new Selector<float?>()
238 BackgroundImage = new Selector<string>()
240 Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
241 Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
242 Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
245 Text = new TextLabelStyle()
248 TextColor = new Selector<Color>()
250 Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
251 Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
252 Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
257 theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
259 Size = new Size(200, 50),
261 Track = new ImageViewStyle()
263 BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
265 Progress = new ImageViewStyle()
267 BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
269 Thumb = new ImageViewStyle()
271 Size = new Size(50, 50),
272 ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
273 BackgroundImage = new Selector<string>()
275 Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
276 Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
279 ValueIndicatorImage = new ImageViewStyle()
281 Size = new Size(83, 54),
282 ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
286 theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
288 Size = new Size(96, 60),
289 Track = new ImageViewStyle()
291 Size = new Size(96, 60),
292 ResourceUrl = new Selector<string>()
294 Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
295 Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
296 Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
297 DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
300 Thumb = new ImageViewStyle()
302 Size = new Size(60, 60),
303 ResourceUrl = new Selector<string>()
305 Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
306 Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
307 Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
310 Text = new TextLabelStyle()
313 TextColor = new Selector<Color>()
315 Normal = (Color)theme.Resources["SwitchTextColorNormal"],
316 Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
317 Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
322 theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
324 Size = new Size(480, 80),
325 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
326 UnderLine = new ViewStyle()
328 Size = new Size(0, 6),
329 BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
331 Text = new TextLabelStyle()
334 TextColor = new Selector<Color>()
336 Normal = (Color)theme.Resources["TabTextColorNormal"],
337 Selected = (Color)theme.Resources["TabTextColorSelected"],
342 theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
344 Size = new Size(480, 80),
345 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
346 Text = new TextLabelStyle()
348 Padding = new Extents(12, 12, 8, 8)
352 theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
354 LoadingSize = new Size(100, 100),
357 theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
359 IndicatorImageUrl = new Selector<string>()
361 Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
362 Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
366 theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
370 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
371 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],