/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.ComponentModel;
using System.IO;
namespace ElmSharp
{
///
/// Focus Autoscroll Mode
///
public enum FocusAutoScrollMode
{
///
/// Directly show the focused region or item automatically
///
Show,
///
/// Do not show the focused region or item automatically
///
None,
///
/// Bring in the focused region or item automatically which might invole the scrolling
///
BringIn
}
///
/// The Elementary is a General Elementary,a VERY SIMPLE toolkit.
///
public static class Elementary
{
private static readonly string _themeFilePath = "/usr/share/elm-sharp/elm-sharp-theme.edj";
///
/// Gets or sets the configured finger size.
///
public static int FingerSize
{
get
{
return Interop.Elementary.elm_config_finger_size_get();
}
set
{
Interop.Elementary.elm_config_finger_size_set(value);
}
}
///
/// Gets or sets the enable status of the focus highlight animation
///
public static bool IsFocusHighlightAnimation
{
get
{
return Interop.Elementary.elm_config_focus_highlight_animate_get();
}
set
{
Interop.Elementary.elm_config_focus_highlight_animate_set(value);
}
}
///
/// Gets or sets the system mirrored mode.
/// This determines the default mirrored mode of widgets.
///
public static bool IsMirrored
{
get
{
return Interop.Elementary.elm_config_mirrored_get();
}
set
{
Interop.Elementary.elm_config_mirrored_set(value);
}
}
///
/// Gets or sets the enable status of the focus highlight.
///
public static bool CanFocusHighlight
{
get
{
return Interop.Elementary.elm_config_focus_highlight_enabled_get();
}
set
{
Interop.Elementary.elm_config_focus_highlight_enabled_set(value);
}
}
///
/// Gets or sets the base scale of the application.
///
public static double AppBaseScale
{
get
{
return Interop.Elementary.elm_app_base_scale_get();
}
set
{
Interop.Elementary.elm_app_base_scale_set(value);
}
}
///
/// Gets or sets the global scaling factor.
///
public static double Scale
{
get
{
return Interop.Elementary.elm_config_scale_get();
}
set
{
Interop.Elementary.elm_config_scale_set(value);
}
}
///
/// Gets or sets the amount of inertia a scroller imposes during region bring animations.
///
public static double BringInScrollFriction
{
get
{
return Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_get();
}
set
{
Interop.Elementary.elm_config_scroll_bring_in_scroll_friction_set(value);
}
}
///
/// Gets of sets focus auto scroll mode.
///
public static FocusAutoScrollMode FocusAutoScrollMode
{
get
{
return (FocusAutoScrollMode)Interop.Elementary.elm_config_focus_autoscroll_mode_get();
}
set
{
Interop.Elementary.elm_config_focus_autoscroll_mode_set((Interop.Elementary.Elm_Focus_Autoscroll_Mode)value);
}
}
///
/// Initializes Elementary.
///
public static void Initialize()
{
Interop.Elementary.elm_init(0, null);
}
///
/// Shuts down Elementary.
///
public static void Shutdown()
{
Interop.Elementary.elm_shutdown();
}
///
/// Runs Elementary's main loop.
///
public static void Run()
{
Interop.Elementary.elm_run();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static void ThemeOverlay()
{
if (File.Exists(_themeFilePath))
{
AddThemeOverlay(_themeFilePath);
}
}
///
/// Prepends a theme overlay to the list of overlays
///
/// The Edje file path to be used.
public static void AddThemeOverlay(string filePath)
{
Interop.Elementary.elm_theme_overlay_add(IntPtr.Zero, filePath);
}
///
/// Delete a theme overlay from the list of overlays
///
/// The name of the theme overlay.
public static void DeleteThemeOverlay(string filePath)
{
Interop.Elementary.elm_theme_overlay_del(IntPtr.Zero, filePath);
}
///
/// Free a theme
///
public static void FreeTheme()
{
Interop.Elementary.elm_theme_free(IntPtr.Zero);
}
///
/// Set the theme search order for the given theme
///
/// Theme search string
/// 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"
public static void SetTheme(string theme)
{
Interop.Elementary.elm_theme_set(IntPtr.Zero, theme);
}
///
/// Flush the current theme.
///
public static void FlushTheme()
{
Interop.Elementary.elm_theme_flush(IntPtr.Zero);
}
///
/// This flushes all themes (default and specific ones).
///
public static void FlushAllThemes()
{
Interop.Elementary.elm_theme_full_flush();
}
///
/// Deletes a theme extension from the list of extensions.
///
/// The name of the theme extension.
public static void DeleteThemeExtention(string item)
{
Interop.Elementary.elm_theme_extension_del(IntPtr.Zero, item);
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static double GetSystemScrollFriction()
{
return BringInScrollFriction;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetSystemScrollFriction(double timeSet)
{
BringInScrollFriction = timeSet;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static string GetProfile()
{
return Interop.Elementary.elm_config_profile_get();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetScale(double scale)
{
Scale = scale;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static double GetScale()
{
return Scale;
}
///
/// Flush all caches.
/// 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.
///
public static void FlushAllCashe()
{
Interop.Elementary.elm_cache_all_flush();
}
///
/// Changes the language of the current application.
///
/// The language to set, must be the full name of the locale.
public static void SetLanguage(string language)
{
Interop.Elementary.elm_language_set(language);
}
///
/// Sets a new policy's value (for a given policy group/identifier).
///
/// The policy identifier
/// The policy value, which depends on the identifier
///
public static bool SetPolicy(uint policy, int value)
{
return Interop.Elementary.elm_policy_set(policy, value);
}
///
/// Reloads Elementary's configuration, bounded to the current selected profile.
///
public static void ReloadConfig()
{
Interop.Elementary.elm_config_reload();
}
///
/// Flushes all config settings and then applies those settings to all applications using elementary on the current display.
///
public static void FlushAllConfig()
{
Interop.Elementary.elm_config_all_flush();
}
}
}