Adds Elementary.FocusAutoScrollMode
[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         /// <summary>
195         /// Prepends a theme overlay to the list of overlays.
196         /// </summary>
197         [EditorBrowsable(EditorBrowsableState.Never)]
198         public static void ThemeOverlay()
199         {
200             if (File.Exists(_themeFilePath))
201             {
202                 AddThemeOverlay(_themeFilePath);
203             }
204         }
205
206         /// <summary>
207         /// Prepends a theme overlay to the list of overlays
208         /// </summary>
209         /// <param name="filePath">The Edje file path to be used.</param>
210         public static void AddThemeOverlay(string filePath)
211         {
212             Interop.Elementary.elm_theme_overlay_add(IntPtr.Zero, filePath);
213         }
214
215         /// <summary>
216         /// Delete a theme overlay from the list of overlays
217         /// </summary>
218         /// <param name="filePath">The name of the theme overlay.</param>
219         public static void DeleteThemeOverlay(string filePath)
220         {
221             Interop.Elementary.elm_theme_overlay_del(IntPtr.Zero, filePath);
222         }
223
224         /// <summary>
225         /// Free a theme
226         /// </summary>
227         public static void FreeTheme()
228         {
229             Interop.Elementary.elm_theme_free(IntPtr.Zero);
230         }
231
232         /// <summary>
233         /// Set the theme search order for the given theme
234         /// </summary>
235         /// <param name="theme">Theme search string</param>
236         /// <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>
237         public static void SetTheme(string theme)
238         {
239             Interop.Elementary.elm_theme_set(IntPtr.Zero, theme);
240         }
241
242         /// <summary>
243         /// Flush the current theme.
244         /// </summary>
245         public static void FlushTheme()
246         {
247             Interop.Elementary.elm_theme_flush(IntPtr.Zero);
248         }
249
250         /// <summary>
251         /// This flushes all themes (default and specific ones).
252         /// </summary>
253         public static void FlushAllThemes()
254         {
255             Interop.Elementary.elm_theme_full_flush();
256         }
257
258         /// <summary>
259         /// Deletes a theme extension from the list of extensions.
260         /// </summary>
261         /// <param name="item">The name of the theme extension.</param>
262         public static void DeleteThemeExtention(string item)
263         {
264             Interop.Elementary.elm_theme_extension_del(IntPtr.Zero, item);
265         }
266
267         /// <summary>
268         /// Gets the amount of inertia a scroller imposes during region bring animations.
269         /// </summary>
270         /// <returns>The bring in scroll friction</returns>
271         [EditorBrowsable(EditorBrowsableState.Never)]
272         public static double GetSystemScrollFriction()
273         {
274             return BringInScrollFriction;
275         }
276
277         /// <summary>
278         /// Sets the amount of inertia a scroller imposes during region bring animations.
279         /// </summary>
280         /// <param name="timeSet">The bring in scroll friction</param>
281         [EditorBrowsable(EditorBrowsableState.Never)]
282         public static void SetSystemScrollFriction(double timeSet)
283         {
284             BringInScrollFriction = timeSet;
285         }
286
287         /// <summary>
288         /// Gets Elementary's profile in use.
289         /// </summary>
290         /// <returns>The profile name</returns>
291         [EditorBrowsable(EditorBrowsableState.Never)]
292         public static string GetProfile()
293         {
294             return Interop.Elementary.elm_config_profile_get();
295         }
296
297         /// <summary>
298         /// Sets the global scaling factor.
299         /// This sets the globally configured scaling factor that is applied to all objects.
300         /// </summary>
301         /// <param name="scale">The scaling factor to set</param>
302         [EditorBrowsable(EditorBrowsableState.Never)]
303         public static void SetScale(double scale)
304         {
305             Scale = scale;
306         }
307
308         /// <summary>
309         /// Gets the global scaling factor.
310         /// This gets the globally configured scaling factor that is applied to all objects.
311         /// </summary>
312         /// <returns>The scaling factor</returns>
313         [EditorBrowsable(EditorBrowsableState.Never)]
314         public static double GetScale()
315         {
316             return Scale;
317         }
318
319         /// <summary>
320         /// Flush all caches.
321         /// 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.
322         /// </summary>
323         public static void FlushAllCashe()
324         {
325             Interop.Elementary.elm_cache_all_flush();
326         }
327
328         /// <summary>
329         /// Changes the language of the current application.
330         /// </summary>
331         /// <param name="language">The language to set, must be the full name of the locale.</param>
332         public static void SetLanguage(string language)
333         {
334             Interop.Elementary.elm_language_set(language);
335         }
336
337         /// <summary>
338         /// Sets a new policy's value (for a given policy group/identifier).
339         /// </summary>
340         /// <param name="policy">The policy identifier</param>
341         /// <param name="value">The policy value, which depends on the identifier</param>
342         /// <returns></returns>
343         public static bool SetPolicy(uint policy, int value)
344         {
345             return Interop.Elementary.elm_policy_set(policy, value);
346         }
347
348         /// <summary>
349         /// Reloads Elementary's configuration, bounded to the current selected profile.
350         /// </summary>
351         public static void ReloadConfig()
352         {
353             Interop.Elementary.elm_config_reload();
354         }
355
356         /// <summary>
357         /// Flushes all config settings and then applies those settings to all applications using elementary on the current display.
358         /// </summary>
359         public static void FlushAllConfig()
360         {
361             Interop.Elementary.elm_config_all_flush();
362         }
363     }
364 }