[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Elementary.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18 using System.ComponentModel;
19 using System.IO;
20
21 namespace ElmSharp
22 {
23     /// <summary>
24     /// Focus Autoscroll mode.
25     /// </summary>
26     /// <since_tizen> preview </since_tizen>
27     public enum FocusAutoScrollMode
28     {
29         /// <summary>
30         /// Directly show the focused region or item automatically.
31         /// </summary>
32         Show,
33
34         /// <summary>
35         /// Do not show the focused region or item automatically.
36         /// </summary>
37         None,
38
39         /// <summary>
40         /// Bring in the focused region or item automatically, which might involve the scrolling.
41         /// </summary>
42         BringIn
43     }
44
45     /// <summary>
46     /// The Elementary is a general elementary, a VERY SIMPLE toolkit.
47     /// </summary>
48     /// <since_tizen> preview </since_tizen>
49     public static class Elementary
50     {
51         private const string _themeFilePath = "/usr/share/elm-sharp/elm-sharp-theme.edj";
52
53         /// <summary>
54         /// EvasObjectRealized will be triggered when the EvasObject is realized.
55         /// </summary>
56         /// <since_tizen> preview </since_tizen>
57         public static event EventHandler EvasObjectRealized;
58
59         /// <summary>
60         /// ItemObjectRealized will be triggered when the ItemObject is realized.
61         /// </summary>
62         /// <since_tizen> preview </since_tizen>
63         public static event EventHandler ItemObjectRealized;
64
65         internal static void SendEvasObjectRealized(EvasObject obj)
66         {
67             EvasObjectRealized?.Invoke(obj, EventArgs.Empty);
68         }
69
70         internal static void SendItemObjectRealized(ItemObject obj)
71         {
72             ItemObjectRealized?.Invoke(obj, EventArgs.Empty);
73         }
74
75         /// <summary>
76         /// Gets or sets the configured finger size.
77         /// </summary>
78         /// <since_tizen> preview </since_tizen>
79         public static int FingerSize
80         {
81             get
82             {
83                 return Interop.Elementary.elm_config_finger_size_get();
84             }
85             set
86             {
87                 Interop.Elementary.elm_config_finger_size_set(value);
88             }
89         }
90
91         /// <summary>
92         /// Gets or sets the enable status of the focus highlight animation.
93         /// </summary>
94         /// <since_tizen> preview </since_tizen>
95         public static bool IsFocusHighlightAnimation
96         {
97             get
98             {
99                 return Interop.Elementary.elm_config_focus_highlight_animate_get();
100             }
101             set
102             {
103                 Interop.Elementary.elm_config_focus_highlight_animate_set(value);
104             }
105         }
106
107         /// <summary>
108         /// Gets or sets the system mirrored mode.
109         /// This determines the default mirrored mode of widgets.
110         /// </summary>
111         /// <since_tizen> preview </since_tizen>
112         public static bool IsMirrored
113         {
114             get
115             {
116                 return Interop.Elementary.elm_config_mirrored_get();
117             }
118             set
119             {
120                 Interop.Elementary.elm_config_mirrored_set(value);
121             }
122         }
123
124         /// <summary>
125         /// Gets or sets the enable status of the focus highlight.
126         /// </summary>
127         /// <since_tizen> preview </since_tizen>
128         public static bool CanFocusHighlight
129         {
130             get
131             {
132                 return Interop.Elementary.elm_config_focus_highlight_enabled_get();
133             }
134             set
135             {
136                 Interop.Elementary.elm_config_focus_highlight_enabled_set(value);
137             }
138         }
139
140         /// <summary>
141         /// Gets or sets the base scale of the application.
142         /// </summary>
143         /// <since_tizen> preview </since_tizen>
144         public static double AppBaseScale
145         {
146             get
147             {
148                 return Interop.Elementary.elm_app_base_scale_get();
149             }
150             set
151             {
152                 Interop.Elementary.elm_app_base_scale_set(value);
153             }
154         }
155
156         /// <summary>
157         /// Gets or sets the global scaling factor.
158         /// </summary>
159         /// <since_tizen> preview </since_tizen>
160         public static double Scale
161         {
162             get
163             {
164                 return Interop.Elementary.elm_config_scale_get();
165             }
166             set
167             {
168                 Interop.Elementary.elm_config_scale_set(value);
169             }
170         }
171
172         /// <summary>
173         /// Gets or sets the amount of inertia, a scroller imposes during a region to bring animations.
174         /// </summary>
175         /// <since_tizen> preview </since_tizen>
176         public static double BringInScrollFriction
177         {
178             get
179             {
180                 return Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_get();
181             }
182             set
183             {
184                 Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_set(value);
185             }
186         }
187
188         /// <summary>
189         /// Gets or sets the focus on autoscroll mode.
190         /// </summary>
191         /// <since_tizen> preview </since_tizen>
192         public static FocusAutoScrollMode FocusAutoScrollMode
193         {
194             get
195             {
196                 return (FocusAutoScrollMode)Interop.Elementary.elm_config_focus_autoscroll_mode_get();
197             }
198             set
199             {
200                 Interop.Elementary.elm_config_focus_autoscroll_mode_set((Interop.Elementary.Elm_Focus_Autoscroll_Mode)value);
201             }
202         }
203
204         /// <summary>
205         /// Initializes Elementary.
206         /// </summary>
207         /// <since_tizen> preview </since_tizen>
208         public static void Initialize()
209         {
210             Interop.Elementary.elm_init(0, null);
211         }
212
213         /// <summary>
214         /// Shuts down Elementary.
215         /// </summary>
216         /// <since_tizen> preview </since_tizen>
217         public static void Shutdown()
218         {
219             Interop.Elementary.elm_shutdown();
220         }
221
222         /// <summary>
223         /// Runs the elementary's main loop.
224         /// </summary>
225         /// <since_tizen> preview </since_tizen>
226         public static void Run()
227         {
228             Interop.Elementary.elm_run();
229         }
230
231         /// <summary>
232         /// Prepends a theme overlay to the list of overlays.
233         /// </summary>
234         /// <since_tizen> preview </since_tizen>
235         [EditorBrowsable(EditorBrowsableState.Never)]
236         public static void ThemeOverlay()
237         {
238             if (File.Exists(_themeFilePath))
239             {
240                 AddThemeOverlay(_themeFilePath);
241             }
242         }
243
244         /// <summary>
245         /// Prepends a theme overlay to the list of overlays.
246         /// </summary>
247         /// <param name="filePath">The edje file path to be used.</param>
248         /// <since_tizen> preview </since_tizen>
249         public static void AddThemeOverlay(string filePath)
250         {
251             Interop.Elementary.elm_theme_overlay_add(IntPtr.Zero, filePath);
252         }
253
254         /// <summary>
255         /// Deletes a theme overlay from the list of overlays.
256         /// </summary>
257         /// <param name="filePath">The name of the theme overlay.</param>
258         /// <since_tizen> preview </since_tizen>
259         public static void DeleteThemeOverlay(string filePath)
260         {
261             Interop.Elementary.elm_theme_overlay_del(IntPtr.Zero, filePath);
262         }
263
264         /// <summary>
265         /// Frees a theme.
266         /// </summary>
267         /// <since_tizen> preview </since_tizen>
268         public static void FreeTheme()
269         {
270             Interop.Elementary.elm_theme_free(IntPtr.Zero);
271         }
272
273         /// <summary>
274         /// Sets the theme search order for the given theme.
275         /// </summary>
276         /// <param name="theme">Theme search string.</param>
277         /// <remarks>This sets the search string for the theme in path-notation from the first theme to search, to last, delimited by the : character. For example, "shiny:/path/to/file.edj:default".</remarks>
278         /// <since_tizen> preview </since_tizen>
279         public static void SetTheme(string theme)
280         {
281             Interop.Elementary.elm_theme_set(IntPtr.Zero, theme);
282         }
283
284         /// <summary>
285         /// Flushes the current theme.
286         /// </summary>
287         /// <since_tizen> preview </since_tizen>
288         public static void FlushTheme()
289         {
290             Interop.Elementary.elm_theme_flush(IntPtr.Zero);
291         }
292
293         /// <summary>
294         /// This flushes all the themes (default and specific ones).
295         /// </summary>
296         /// <since_tizen> preview </since_tizen>
297         public static void FlushAllThemes()
298         {
299             Interop.Elementary.elm_theme_full_flush();
300         }
301
302         /// <summary>
303         /// Deletes a theme extension from the list of extensions.
304         /// </summary>
305         /// <param name="item">The name of the theme extension.</param>
306         /// <since_tizen> preview </since_tizen>
307         public static void DeleteThemeExtention(string item)
308         {
309             Interop.Elementary.elm_theme_extension_del(IntPtr.Zero, item);
310         }
311
312         /// <summary>
313         /// Gets the amount of inertia that a scroller imposes during region to bring animations.
314         /// </summary>
315         /// <since_tizen> preview </since_tizen>
316         [EditorBrowsable(EditorBrowsableState.Never)]
317         public static double GetSystemScrollFriction()
318         {
319             return BringInScrollFriction;
320         }
321
322         /// <summary>
323         /// Sets the amount of inertia that a scroller imposes during the region bring animations.
324         /// </summary>
325         /// <since_tizen> preview </since_tizen>
326         [EditorBrowsable(EditorBrowsableState.Never)]
327         public static void SetSystemScrollFriction(double timeSet)
328
329         {
330             BringInScrollFriction = timeSet;
331         }
332
333         /// <summary>
334         /// Gets the elementary's profile in use.
335         /// </summary>
336         /// <since_tizen> preview </since_tizen>
337         [EditorBrowsable(EditorBrowsableState.Never)]
338         public static string GetProfile()
339         {
340             return Interop.Elementary.elm_config_profile_get();
341         }
342
343         /// <summary>
344         /// Sets the global scaling factor.
345         /// </summary>
346         /// <since_tizen> preview </since_tizen>
347         [EditorBrowsable(EditorBrowsableState.Never)]
348         public static void SetScale(double scale)
349         {
350             Scale = scale;
351         }
352
353         /// <summary>
354         /// Gets the global scaling factor.
355         /// </summary>
356         /// <since_tizen> preview </since_tizen>
357         [EditorBrowsable(EditorBrowsableState.Never)]
358         public static double GetScale()
359         {
360             return Scale;
361         }
362
363         /// <summary>
364         /// Use FlushAllCache instead.
365         /// </summary>
366         [Obsolete("use FlushAllCache instead")]
367         [EditorBrowsable(EditorBrowsableState.Never)]
368         public static void FlushAllCashe()
369         {
370             Interop.Elementary.elm_cache_all_flush();
371         }
372
373         /// <summary>
374         /// Flushes all the cache.
375         /// Frees all data that was in cache and is not currently being used, to reduce memory usage. This frees Edje's, Evas', and Eet's cache.
376         /// </summary>
377         /// <since_tizen> preview </since_tizen>
378         public static void FlushAllCache()
379         {
380             Interop.Elementary.elm_cache_all_flush();
381         }
382
383         /// <summary>
384         /// Changes the language of the current application.
385         /// </summary>
386         /// <param name="language">The language to set must be the full name of the locale.</param>
387         /// <since_tizen> preview </since_tizen>
388         public static void SetLanguage(string language)
389         {
390             Interop.Elementary.elm_language_set(language);
391         }
392
393         /// <summary>
394         /// Sets a new policy's value (for a given policy group/identifier).
395         /// </summary>
396         /// <param name="policy">The policy identifier.</param>
397         /// <param name="value">The policy value, which depends on the identifier.</param>
398         /// <returns></returns>
399         /// <since_tizen> preview </since_tizen>
400         public static bool SetPolicy(uint policy, int value)
401         {
402             return Interop.Elementary.elm_policy_set(policy, value);
403         }
404
405         /// <summary>
406         /// Reloads the elementary's configuration, bounded to the current selected profile.
407         /// </summary>
408         /// <since_tizen> preview </since_tizen>
409         [EditorBrowsable(EditorBrowsableState.Never)]
410         public static void ReloadConfig()
411         {
412             Interop.Elementary.elm_config_reload();
413         }
414
415         /// <summary>
416         /// Flushes all the configuration settings, and then applies those settings to all applications using elementary on the current display.
417         /// </summary>
418         /// <since_tizen> preview </since_tizen>
419         public static void FlushAllConfig()
420         {
421             Interop.Elementary.elm_config_all_flush();
422         }
423     }
424 }