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