Merge "Enhance Elementary(static)" into tizen
[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     /// The Elementary is a General Elementary,a VERY SIMPLE toolkit.
25     /// </summary>
26     public static class Elementary
27     {
28         private static readonly string _themeFilePath = "/usr/share/elm-sharp/elm-sharp-theme.edj";
29
30         /// <summary>
31         /// Gets or sets the configured finger size.
32         /// </summary>
33         public static int FingerSize
34         {
35             get
36             {
37                 return Interop.Elementary.elm_config_finger_size_get();
38             }
39             set
40             {
41                 Interop.Elementary.elm_config_finger_size_set(value);
42             }
43         }
44
45         /// <summary>
46         /// Gets or sets the enable status of the focus highlight animation
47         /// </summary>
48         public static bool IsFocusHighlightAnimation
49         {
50             get
51             {
52                 return Interop.Elementary.elm_config_focus_highlight_animate_get();
53             }
54             set
55             {
56                 Interop.Elementary.elm_config_focus_highlight_animate_set(value);
57             }
58         }
59
60         /// <summary>
61         /// Gets or sets the system mirrored mode.
62         /// This determines the default mirrored mode of widgets.
63         /// </summary>
64         public static bool IsMirrored
65         {
66             get
67             {
68                 return Interop.Elementary.elm_config_mirrored_get();
69             }
70             set
71             {
72                 Interop.Elementary.elm_config_mirrored_set(value);
73             }
74         }
75
76         /// <summary>
77         /// Gets or sets the enable status of the focus highlight.
78         /// </summary>
79         public static bool CanFocusHighlight
80         {
81             get
82             {
83                 return Interop.Elementary.elm_config_focus_highlight_enabled_get();
84             }
85             set
86             {
87                 Interop.Elementary.elm_config_focus_highlight_enabled_set(value);
88             }
89         }
90
91         /// <summary>
92         /// Gets or sets the base scale of the application.
93         /// </summary>
94         public static double AppBaseScale
95         {
96             get
97             {
98                 return Interop.Elementary.elm_app_base_scale_get();
99             }
100             set
101             {
102                 Interop.Elementary.elm_app_base_scale_set(value);
103             }
104         }
105
106         /// <summary>
107         /// Gets or sets the global scaling factor.
108         /// </summary>
109         public static double Scale
110         {
111             get
112             {
113                 return Interop.Elementary.elm_config_scale_get();
114             }
115             set
116             {
117                 Interop.Elementary.elm_config_scale_set(value);
118             }
119         }
120
121         /// <summary>
122         /// Gets or sets the amount of inertia a scroller imposes during region bring animations.
123         /// </summary>
124         public static double BringInScrollFriction
125         {
126             get
127             {
128                 return Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_get();
129             }
130             set
131             {
132                 Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_set(value);
133             }
134         }
135
136         /// <summary>
137         /// Initializes Elementary.
138         /// </summary>
139         public static void Initialize()
140         {
141             Interop.Elementary.elm_init(0, null);
142         }
143
144         /// <summary>
145         /// Shuts down Elementary.
146         /// </summary>
147         public static void Shutdown()
148         {
149             Interop.Elementary.elm_shutdown();
150         }
151
152         /// <summary>
153         /// Runs Elementary's main loop.
154         /// </summary>
155         public static void Run()
156         {
157             Interop.Elementary.elm_run();
158         }
159
160         /// <summary>
161         /// Prepends a theme overlay to the list of overlays.
162         /// </summary>
163         [EditorBrowsable(EditorBrowsableState.Never)]
164         public static void ThemeOverlay()
165         {
166             if (File.Exists(_themeFilePath))
167             {
168                 AddThemeOverlay(_themeFilePath);
169             }
170         }
171
172         /// <summary>
173         /// Prepends a theme overlay to the list of overlays
174         /// </summary>
175         /// <param name="filePath">The Edje file path to be used.</param>
176         public static void AddThemeOverlay(string filePath)
177         {
178             Interop.Elementary.elm_theme_overlay_add(IntPtr.Zero, filePath);
179         }
180
181         /// <summary>
182         /// Delete a theme overlay from the list of overlays
183         /// </summary>
184         /// <param name="filePath">The name of the theme overlay.</param>
185         public static void DeleteThemeOverlay(string filePath)
186         {
187             Interop.Elementary.elm_theme_overlay_del(IntPtr.Zero, filePath);
188         }
189
190         /// <summary>
191         /// Free a theme
192         /// </summary>
193         public static void FreeTheme()
194         {
195             Interop.Elementary.elm_theme_free(IntPtr.Zero);
196         }
197
198         /// <summary>
199         /// Set the theme search order for the given theme
200         /// </summary>
201         /// <param name="theme">Theme search string</param>
202         /// <remarks>This sets the search string for the theme in path-notation from first theme to search, to last, delimited by the : character. Example:"shiny:/path/to/file.edj:default"</remarks>
203         public static void SetTheme(string theme)
204         {
205             Interop.Elementary.elm_theme_set(IntPtr.Zero, theme);
206         }
207
208         /// <summary>
209         /// Flush the current theme.
210         /// </summary>
211         public static void FlushTheme()
212         {
213             Interop.Elementary.elm_theme_flush(IntPtr.Zero);
214         }
215
216         /// <summary>
217         /// This flushes all themes (default and specific ones).
218         /// </summary>
219         public static void FlushAllThemes()
220         {
221             Interop.Elementary.elm_theme_full_flush();
222         }
223
224         /// <summary>
225         /// Deletes a theme extension from the list of extensions.
226         /// </summary>
227         /// <param name="item">The name of the theme extension.</param>
228         public static void DeleteThemeExtention(string item)
229         {
230             Interop.Elementary.elm_theme_extension_del(IntPtr.Zero, item);
231         }
232
233         /// <summary>
234         /// Gets the amount of inertia a scroller imposes during region bring animations.
235         /// </summary>
236         /// <returns>The bring in scroll friction</returns>
237         [EditorBrowsable(EditorBrowsableState.Never)]
238         public static double GetSystemScrollFriction()
239         {
240             return BringInScrollFriction;
241         }
242
243         /// <summary>
244         /// Sets the amount of inertia a scroller imposes during region bring animations.
245         /// </summary>
246         /// <param name="timeSet">The bring in scroll friction</param>
247         [EditorBrowsable(EditorBrowsableState.Never)]
248         public static void SetSystemScrollFriction(double timeSet)
249         {
250             BringInScrollFriction = timeSet;
251         }
252
253         /// <summary>
254         /// Gets Elementary's profile in use.
255         /// </summary>
256         /// <returns>The profile name</returns>
257         [EditorBrowsable(EditorBrowsableState.Never)]
258         public static string GetProfile()
259         {
260             return Interop.Elementary.elm_config_profile_get();
261         }
262
263         /// <summary>
264         /// Sets the global scaling factor.
265         /// This sets the globally configured scaling factor that is applied to all objects.
266         /// </summary>
267         /// <param name="scale">The scaling factor to set</param>
268         [EditorBrowsable(EditorBrowsableState.Never)]
269         public static void SetScale(double scale)
270         {
271             Scale = scale;
272         }
273
274         /// <summary>
275         /// Gets the global scaling factor.
276         /// This gets the globally configured scaling factor that is applied to all objects.
277         /// </summary>
278         /// <returns>The scaling factor</returns>
279         [EditorBrowsable(EditorBrowsableState.Never)]
280         public static double GetScale()
281         {
282             return Scale;
283         }
284
285         /// <summary>
286         /// Flush all caches.
287         /// 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.
288         /// </summary>
289         public static void FlushAllCashe()
290         {
291             Interop.Elementary.elm_cache_all_flush();
292         }
293
294         /// <summary>
295         /// Changes the language of the current application.
296         /// </summary>
297         /// <param name="language">The language to set, must be the full name of the locale.</param>
298         public static void SetLanguage(string language)
299         {
300             Interop.Elementary.elm_language_set(language);
301         }
302
303         /// <summary>
304         /// Sets a new policy's value (for a given policy group/identifier).
305         /// </summary>
306         /// <param name="policy">The policy identifier</param>
307         /// <param name="value">The policy value, which depends on the identifier</param>
308         /// <returns></returns>
309         public static bool SetPolicy(uint policy, int value)
310         {
311             return Interop.Elementary.elm_policy_set(policy, value);
312         }
313
314         /// <summary>
315         /// Reloads Elementary's configuration, bounded to the current selected profile.
316         /// </summary>
317         public static void ReloadConfig()
318         {
319             Interop.Elementary.elm_config_reload();
320         }
321
322         /// <summary>
323         /// Flushes all config settings and then applies those settings to all applications using elementary on the current display.
324         /// </summary>
325         public static void FlushAllConfig()
326         {
327             Interop.Elementary.elm_config_all_flush();
328         }
329     }
330 }