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 ["SwitchTrackImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
76 ["SwitchTrackImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
77 ["SwitchTrackImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
78 ["SwitchTrackImageResourceUrlDisabledSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
79 ["SwitchThumbImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
80 ["SwitchThumbImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
81 ["SwitchThumbImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
82 ["SwitchTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
83 ["SwitchTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
84 ["SwitchTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
85 ["TabBackgroundColor"] = Color.Yellow,
86 ["TabUnderLineBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1.0f),
87 ["TabTextColorNormal"] = Color.Black,
88 ["TabTextColorSelected"] = new Color(0.05f, 0.63f, 0.9f, 1),
89 ["ToastBackgroundColor"] = new Color(0, 0, 0, 0.8f),
90 ["PaginationIndicatorImageUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
91 ["PaginationIndicatorImageUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
92 ["ScrollbarTrackColor"] = new Color(1, 1, 1, 0.15f),
93 ["ScrollbarThumbColor"] = new Color(0.6f, 0.6f, 0.6f, 1.0f),
96 public Theme Create() => Create(null);
98 [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
99 public Theme Create(IEnumerable<KeyValuePair<string, string>> changedResources)
101 var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
103 theme.SetChangedResources(changedResources);
104 theme.Resources = CreateThemeResource();
105 theme.OnThemeResourcesChanged();
107 theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
109 Size = new Size(100, 45),
110 BackgroundColor = new Selector<Color>()
112 Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
113 Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
114 Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
116 Text = new TextLabelStyle()
119 TextColor = new Selector<Color>()
121 Normal = (Color)theme.Resources["ButtonTextColorNormal"],
122 Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
123 Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
128 theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
130 Size = new Size(30, 30),
131 Icon = new ImageViewStyle()
133 Opacity = new Selector<float?>()
139 BackgroundImage = new Selector<string>()
141 Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
142 Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
143 Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
145 ResourceUrl = new Selector<string>()
147 Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
148 Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
149 Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
152 Text = new TextLabelStyle()
155 TextColor = new Selector<Color>()
157 Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
158 Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
159 Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
164 theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
166 Size = new Size(500, 280),
167 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
168 ImageShadow = new ImageShadow()
170 Url = (string)theme.Resources["PopupImageShadowUrl"],
171 Border = new Rectangle(24, 24, 24, 24),
172 Extents = new Vector2(48, 48)
174 Title = new TextLabelStyle()
177 Padding = new Extents(20, 20, 20, 20),
179 Buttons = new ButtonStyle()
181 Size = new Size(0, 80),
182 BackgroundColor = new Selector<Color>()
184 Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
185 Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
187 Overlay = new ImageViewStyle()
189 BackgroundColor = new Selector<Color>()
191 Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
192 Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
193 Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
196 Text = new TextLabelStyle()
198 TextColor = (Color)theme.Resources["PopupButtonTextColor"],
203 theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
205 Size = new Size(200, 5),
206 Track = new ImageViewStyle()
208 BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
210 Buffer = new ImageViewStyle()
212 BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
214 Progress = new ImageViewStyle()
216 BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
220 theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
222 Size = new Size(30, 30),
223 Icon = new ImageViewStyle()
225 Opacity = new Selector<float?>()
231 BackgroundImage = new Selector<string>()
233 Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
234 Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
235 Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
238 Text = new TextLabelStyle()
241 TextColor = new Selector<Color>()
243 Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
244 Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
245 Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
250 theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
252 Size = new Size(200, 50),
254 Track = new ImageViewStyle()
256 BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
258 Progress = new ImageViewStyle()
260 BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
262 Thumb = new ImageViewStyle()
264 Size = new Size(50, 50),
265 ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
266 BackgroundImage = new Selector<string>()
268 Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
269 Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
274 theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
276 Size = new Size(96, 60),
277 Track = new ImageViewStyle()
279 Size = new Size(96, 60),
280 ResourceUrl = new Selector<string>()
282 Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
283 Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
284 Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
285 DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
288 Thumb = new ImageViewStyle()
290 Size = new Size(60, 60),
291 ResourceUrl = new Selector<string>()
293 Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
294 Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
295 Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
298 Text = new TextLabelStyle()
301 TextColor = new Selector<Color>()
303 Normal = (Color)theme.Resources["SwitchTextColorNormal"],
304 Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
305 Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
310 theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
312 Size = new Size(480, 80),
313 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
314 UnderLine = new ViewStyle()
316 Size = new Size(0, 6),
317 BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
319 Text = new TextLabelStyle()
322 TextColor = new Selector<Color>()
324 Normal = (Color)theme.Resources["TabTextColorNormal"],
325 Selected = (Color)theme.Resources["TabTextColorSelected"],
330 theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
332 Size = new Size(480, 80),
333 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
334 Text = new TextLabelStyle()
336 Padding = new Extents(12, 12, 8, 8)
340 theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
342 LoadingSize = new Size(100, 100),
345 theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
347 IndicatorImageUrl = new Selector<string>()
349 Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
350 Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
354 theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
358 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
359 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],