[NUI] Add Value Indicator of Slider (#2533)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Theme / DefaultTheme.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 #if !PROFILE_WEARABLE
18
19 using System.Collections.Generic;
20 using System.Diagnostics.CodeAnalysis;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Binding;
23
24 namespace Tizen.NUI.Components
25 {
26     // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
27     internal class DefaultThemeCreator : IThemeCreator
28     {
29         public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
30         {
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),
95         };
96
97         public Theme Create() => Create(null);
98
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)
101         {
102             var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
103
104             theme.SetChangedResources(changedResources);
105             theme.Resources = CreateThemeResource();
106             theme.OnThemeResourcesChanged();
107
108             theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
109             {
110                 Size = new Size(100, 45),
111                 BackgroundColor = new Selector<Color>()
112                 {
113                     Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
114                     Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
115                     Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
116                 },
117                 Text = new TextLabelStyle()
118                 {
119                     PointSize = 12,
120                     TextColor = new Selector<Color>()
121                     {
122                         Normal = (Color)theme.Resources["ButtonTextColorNormal"],
123                         Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
124                         Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
125                     }
126                 }
127             });
128
129             theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
130             {
131                 Size = new Size(30, 30),
132                 Icon = new ImageViewStyle()
133                 {
134                     Opacity = new Selector<float?>()
135                     {
136                         Normal = 1.0f,
137                         Disabled = 0.4f,
138                         Selected = 1.0f,
139                     },
140                     BackgroundImage = new Selector<string>()
141                     {
142                         Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
143                         Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
144                         Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
145                     },
146                     ResourceUrl = new Selector<string>()
147                     {
148                         Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
149                         Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
150                         Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
151                     },
152                 },
153                 Text = new TextLabelStyle()
154                 {
155                     PointSize = 12,
156                     TextColor = new Selector<Color>()
157                     {
158                         Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
159                         Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
160                         Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
161                     }
162                 }
163             });
164
165             theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
166             {
167                 Size = new Size(500, 280),
168                 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
169                 ImageShadow = new ImageShadow()
170                 {
171                     Url = (string)theme.Resources["PopupImageShadowUrl"],
172                     Border = new Rectangle(24, 24, 24, 24),
173                     Extents = new Vector2(48, 48)
174                 },
175                 Title = new TextLabelStyle()
176                 {
177                     PointSize = 16,
178                     Padding = new Extents(20, 20, 20, 20),
179                 },
180                 Buttons = new ButtonStyle()
181                 {
182                     Size = new Size(0, 80),
183                     BackgroundColor = new Selector<Color>()
184                     {
185                         Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
186                         Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
187                     },
188                     Overlay = new ImageViewStyle()
189                     {
190                         BackgroundColor = new Selector<Color>()
191                         {
192                             Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
193                             Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
194                             Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
195                         },
196                     },
197                     Text = new TextLabelStyle()
198                     {
199                         TextColor = (Color)theme.Resources["PopupButtonTextColor"],
200                     }
201                 }
202             });
203
204             theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
205             {
206                 Size = new Size(200, 5),
207                 Track = new ImageViewStyle()
208                 {
209                     BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
210                 },
211                 Buffer = new ImageViewStyle()
212                 {
213                     BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
214                 },
215                 Progress = new ImageViewStyle()
216                 {
217                     BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
218                 },
219             });
220
221             theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
222             {
223                 Size = new Size(30, 30),
224                 Icon = new ImageViewStyle()
225                 {
226                     Opacity = new Selector<float?>()
227                     {
228                         Normal = 1.0f,
229                         Disabled = 0.4f,
230                         Selected = 1.0f,
231                     },
232                     BackgroundImage = new Selector<string>()
233                     {
234                         Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
235                         Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
236                         Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
237                     }
238                 },
239                 Text = new TextLabelStyle()
240                 {
241                     PointSize = 12,
242                     TextColor = new Selector<Color>()
243                     {
244                         Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
245                         Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
246                         Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
247                     }
248                 }
249             });
250
251             theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
252             {
253                 Size = new Size(200, 50),
254                 TrackThickness = 5,
255                 Track = new ImageViewStyle()
256                 {
257                     BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
258                 },
259                 Progress = new ImageViewStyle()
260                 {
261                     BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
262                 },
263                 Thumb = new ImageViewStyle()
264                 {
265                     Size = new Size(50, 50),
266                     ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
267                     BackgroundImage = new Selector<string>()
268                     {
269                         Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
270                         Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
271                     }
272                 },
273                 ValueIndicatorImage = new ImageViewStyle()
274                 {
275                     Size = new Size(83, 54),
276                     ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
277                 },
278             });
279
280             theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
281             {
282                 Size = new Size(96, 60),
283                 Track = new ImageViewStyle()
284                 {
285                     Size = new Size(96, 60),
286                     ResourceUrl = new Selector<string>()
287                     {
288                         Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
289                         Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
290                         Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
291                         DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
292                     }
293                 },
294                 Thumb = new ImageViewStyle()
295                 {
296                     Size = new Size(60, 60),
297                     ResourceUrl = new Selector<string>()
298                     {
299                         Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
300                         Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
301                         Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
302                     }
303                 },
304                 Text = new TextLabelStyle()
305                 {
306                     PointSize = 12,
307                     TextColor = new Selector<Color>()
308                     {
309                         Normal = (Color)theme.Resources["SwitchTextColorNormal"],
310                         Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
311                         Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
312                     }
313                 }
314             });
315
316             theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
317             {
318                 Size = new Size(480, 80),
319                 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
320                 UnderLine = new ViewStyle()
321                 {
322                     Size = new Size(0, 6),
323                     BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
324                 },
325                 Text = new TextLabelStyle()
326                 {
327                     PointSize = 16,
328                     TextColor = new Selector<Color>()
329                     {
330                         Normal = (Color)theme.Resources["TabTextColorNormal"],
331                         Selected = (Color)theme.Resources["TabTextColorSelected"],
332                     }
333                 }
334             });
335
336             theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
337             {
338                 Size = new Size(480, 80),
339                 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
340                 Text = new TextLabelStyle()
341                 {
342                     Padding = new Extents(12, 12, 8, 8)
343                 }
344             });
345
346             theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
347             {
348                 LoadingSize = new Size(100, 100),
349             });
350
351             theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
352             {
353                 IndicatorImageUrl = new Selector<string>()
354                 {
355                     Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
356                     Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
357                 }
358             });
359
360             theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
361             {
362                 TrackThickness = 6,
363                 ThumbThickness = 6,
364                 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
365                 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],
366                 TrackPadding = 4
367             });
368
369             return theme;
370         }
371     }
372 }
373
374 #endif