2 * Copyright(c) 2020 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.
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 public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
31 ["ButtonBackgroundColorNormal"] = new Color(0.88f, 0.88f, 0.88f, 1),
32 ["ButtonBackgroundColorPressed"] = new Color(0.77f, 0.77f, 0.77f, 1),
33 ["ButtonBackgroundColorDisabled"] = new Color(0.88f, 0.88f, 0.88f, 1),
34 ["ButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
35 ["ButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
36 ["ButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
37 ["CheckBoxIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
38 ["CheckBoxIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
39 ["CheckBoxIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
40 ["CheckBoxIconImageResourceUrlPressed"] = "",
41 ["CheckBoxIconImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_s.png",
42 ["CheckBoxIconImageResourceUrlOther"] = "",
43 ["CheckBoxTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
44 ["CheckBoxTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
45 ["CheckBoxTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
46 ["DropDownBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
47 ["DropDownBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
48 ["DropDownIconImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_button_icon.png",
49 ["DropDownListBackgroundImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_list_bg.png",
50 ["DropDownDataItemBackgroundColorPressed"] = new Color(0.05f, 0.63f, 0.9f, 1),
51 ["DropDownDataItemBackgroundColorSelected"] = new Color(0.8f, 0.8f, 0.8f, 1),
52 ["DropDownDataItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
53 ["PopupBackgroundColor"] = new Color(0.9f, 0.9f, 0.9f, 1),
54 ["PopupImageShadowUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
55 ["PopupButtonBackgroundColorNormal"] = new Color(1, 1, 1, 1),
56 ["PopupButtonBackgroundColorPressed"] = new Color(1, 1, 1, 0.5f),
57 ["PopupButtonOverlayBackgroundColorNormal"] = new Color(1, 1, 1, 1),
58 ["PopupButtonOverlayBackgroundColorPressed"] = new Color(0, 0, 0, 0.1f),
59 ["PopupButtonOverlayBackgroundColorSelected"] = new Color(1, 1, 1, 1),
60 ["PopupButtonTextColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
61 ["ProgressTrackBackgroundColor"] = new Color(0, 0, 0, 0.1f),
62 ["ProgressBufferBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 0.3f),
63 ["ProgressProgressBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
64 ["RadioButtonIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_p.png",
65 ["RadioButtonIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_s.png",
66 ["RadioButtonIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_n.png",
67 ["RadioButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
68 ["RadioButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
69 ["RadioButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
70 ["SliderTrackColor"] = new Color(0, 0, 0, 0.1f),
71 ["SliderProgressColor"] = new Color(0.5f, 0.63f, 0.9f, 1),
72 ["SliderThumbImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
73 ["SliderThumbBackgroundImageNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
74 ["SliderThumbBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
75 ["SliderValueIndicatorImage"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_value_indicator.png",
76 ["SwitchTrackImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
77 ["SwitchTrackImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
78 ["SwitchTrackImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
79 ["SwitchTrackImageResourceUrlDisabledSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
80 ["SwitchThumbImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
81 ["SwitchThumbImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
82 ["SwitchThumbImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
83 ["SwitchTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
84 ["SwitchTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
85 ["SwitchTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
86 ["TabBackgroundColor"] = Color.Yellow,
87 ["TabUnderLineBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1.0f),
88 ["TabTextColorNormal"] = Color.Black,
89 ["TabTextColorSelected"] = new Color(0.05f, 0.63f, 0.9f, 1),
90 ["ToastBackgroundColor"] = new Color(0, 0, 0, 0.8f),
91 ["PaginationIndicatorImageUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
92 ["PaginationIndicatorImageUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
93 ["ScrollbarTrackColor"] = new Color(1, 1, 1, 0.15f),
94 ["ScrollbarThumbColor"] = new Color(0.6f, 0.6f, 0.6f, 1.0f),
97 public Theme Create() => Create(null);
99 [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
100 public Theme Create(IEnumerable<KeyValuePair<string, string>> changedResources)
102 var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
104 theme.SetChangedResources(changedResources);
105 theme.Resources = CreateThemeResource();
106 theme.OnThemeResourcesChanged();
108 theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
110 Size = new Size(100, 45),
111 BackgroundColor = new Selector<Color>()
113 Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
114 Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
115 Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
117 Text = new TextLabelStyle()
120 TextColor = new Selector<Color>()
122 Normal = (Color)theme.Resources["ButtonTextColorNormal"],
123 Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
124 Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
129 theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
131 Size = new Size(30, 30),
132 Icon = new ImageViewStyle()
134 Opacity = new Selector<float?>()
140 BackgroundImage = new Selector<string>()
142 Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
143 Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
144 Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
146 ResourceUrl = new Selector<string>()
148 Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
149 Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
150 Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
153 Text = new TextLabelStyle()
156 TextColor = new Selector<Color>()
158 Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
159 Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
160 Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
165 theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
167 Size = new Size(500, 280),
168 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
169 ImageShadow = new ImageShadow()
171 Url = (string)theme.Resources["PopupImageShadowUrl"],
172 Border = new Rectangle(24, 24, 24, 24),
173 Extents = new Vector2(48, 48)
175 Title = new TextLabelStyle()
178 Padding = new Extents(20, 20, 20, 20),
180 Buttons = new ButtonStyle()
182 Size = new Size(0, 80),
183 BackgroundColor = new Selector<Color>()
185 Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
186 Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
188 Overlay = new ImageViewStyle()
190 BackgroundColor = new Selector<Color>()
192 Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
193 Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
194 Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
197 Text = new TextLabelStyle()
199 TextColor = (Color)theme.Resources["PopupButtonTextColor"],
204 theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
206 Size = new Size(200, 5),
207 Track = new ImageViewStyle()
209 BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
211 Buffer = new ImageViewStyle()
213 BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
215 Progress = new ImageViewStyle()
217 BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
221 theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
223 Size = new Size(30, 30),
224 Icon = new ImageViewStyle()
226 Opacity = new Selector<float?>()
232 BackgroundImage = new Selector<string>()
234 Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
235 Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
236 Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
239 Text = new TextLabelStyle()
242 TextColor = new Selector<Color>()
244 Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
245 Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
246 Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
251 theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
253 Size = new Size(200, 50),
255 Track = new ImageViewStyle()
257 BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
259 Progress = new ImageViewStyle()
261 BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
263 Thumb = new ImageViewStyle()
265 Size = new Size(50, 50),
266 ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
267 BackgroundImage = new Selector<string>()
269 Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
270 Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
273 ValueIndicatorImage = new ImageViewStyle()
275 Size = new Size(83, 54),
276 ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
280 theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
282 Size = new Size(96, 60),
283 Track = new ImageViewStyle()
285 Size = new Size(96, 60),
286 ResourceUrl = new Selector<string>()
288 Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
289 Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
290 Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
291 DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
294 Thumb = new ImageViewStyle()
296 Size = new Size(60, 60),
297 ResourceUrl = new Selector<string>()
299 Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
300 Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
301 Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
304 Text = new TextLabelStyle()
307 TextColor = new Selector<Color>()
309 Normal = (Color)theme.Resources["SwitchTextColorNormal"],
310 Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
311 Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
316 theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
318 Size = new Size(480, 80),
319 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
320 UnderLine = new ViewStyle()
322 Size = new Size(0, 6),
323 BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
325 Text = new TextLabelStyle()
328 TextColor = new Selector<Color>()
330 Normal = (Color)theme.Resources["TabTextColorNormal"],
331 Selected = (Color)theme.Resources["TabTextColorSelected"],
336 theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
338 Size = new Size(480, 80),
339 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
340 Text = new TextLabelStyle()
342 Padding = new Extents(12, 12, 8, 8)
346 theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
348 LoadingSize = new Size(100, 100),
351 theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
353 IndicatorImageUrl = new Selector<string>()
355 Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
356 Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
360 theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
364 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
365 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],