/*
* 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.Runtime.InteropServices;
using System.Collections.Generic;
namespace ElmSharp
{
///
/// The GestureLayer is used to detect gestures.
/// Inherits Widget.
///
/// preview
public class GestureLayer : Widget
{
private readonly Interop.Elementary.GestureEventCallback _gestureCallback;
// Important: don't remove items from _handlers list
// The list can grow up to (number of GestureType) * (number of GestureState)
// but all gestures share the callback and you don't want to desynchronize mapping
private readonly List _handlers = new List();
///
/// Creates and initializes a new instance of the GestureLayer class.
///
/// The parent is a given container which will be attached by the GestureLayer as a child. It's the type.
/// preview
public GestureLayer(EvasObject parent) : base(parent)
{
_gestureCallback = new Interop.Elementary.GestureEventCallback(GestureCallbackHandler);
}
///
/// Enumeration for the supported gesture types.
///
/// preview
public enum GestureType
{
///
/// N fingers single taps.
///
Tap = 1,
///
/// N fingers single long-taps.
///
LongTap,
///
/// N fingers double-single taps.
///
DoubleTap,
///
/// N fingers triple-single taps.
///
TripleTap,
///
/// Reports momentum in the direction of the move.
///
Momentum,
///
/// N fingers line gesture.
///
Line,
///
/// N fingers flick gesture.
///
Flick,
///
/// Zoom.
///
Zoom,
///
/// Rotate.
///
Rotate,
}
///
/// Enumeration for the gesture states.
///
/// preview
public enum GestureState
{
///
/// Gesture not started.
///
Undefined = -1,
///
/// Gesture started.
///
Start,
///
/// Gesture is ongoing.
///
Move,
///
/// Gesture completed.
///
End,
///
/// Ongoing gesture is aborted.
///
Abort,
}
#region Properties
///
/// Sets or gets the repeat-events setting.
///
/// preview
public bool HoldEvents
{
get
{
return Interop.Elementary.elm_gesture_layer_hold_events_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_hold_events_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer to continue enable of an object.
///
/// preview
public bool Continues
{
get
{
return Interop.Elementary.elm_gesture_layer_continues_enable_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_continues_enable_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer finger-size for taps.
///
/// preview
public int TapFingerSize
{
get
{
return Interop.Elementary.elm_gesture_layer_tap_finger_size_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_tap_finger_size_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer long tap start timeout of an object.
///
/// preview
public double LongTapTimeout
{
get
{
return Interop.Elementary.elm_gesture_layer_long_tap_start_timeout_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_long_tap_start_timeout_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer double tap timeout of an object.
///
/// preview
public double DoubleTapTimeout
{
get
{
return Interop.Elementary.elm_gesture_layer_double_tap_timeout_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_double_tap_timeout_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer flick time limit (in ms) of an object.
///
/// preview
public int FlickTimeLimit
{
get
{
return (int)Interop.Elementary.elm_gesture_layer_flick_time_limit_ms_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_flick_time_limit_ms_set(Handle, (UInt32)value);
}
}
///
/// Sets or gets the gesture layer line minimum length of an object.
///
/// preview
public int MinimumLineLength
{
get
{
return Interop.Elementary.elm_gesture_layer_line_min_length_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_line_min_length_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer line angular tolerance of an object.
///
/// preview
public double LineAngularTolerance
{
get
{
return Interop.Elementary.elm_gesture_layer_line_angular_tolerance_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_line_angular_tolerance_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer line distance tolerance of an object.
///
/// preview
public int LineDistanceTolerance
{
get
{
return Interop.Elementary.elm_gesture_layer_line_distance_tolerance_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_line_distance_tolerance_set(Handle, value);
}
}
///
/// Sets or gets the step-value for the rotate action.
///
/// preview
public double RotateStep
{
get
{
return Interop.Elementary.elm_gesture_layer_rotate_step_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_rotate_step_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer rotate angular tolerance of an object.
///
/// preview
public double RotateAngularTolerance
{
get
{
return Interop.Elementary.elm_gesture_layer_rotate_angular_tolerance_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_rotate_angular_tolerance_set(Handle, value);
}
}
///
/// Sets or gets the control step value for the zoom action.
///
/// preview
public double ZoomStep
{
get
{
return Interop.Elementary.elm_gesture_layer_zoom_step_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_zoom_step_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer zoom distance tolerance of an object.
///
/// preview
public int ZoomDistanceTolerance
{
get
{
return Interop.Elementary.elm_gesture_layer_zoom_distance_tolerance_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_zoom_distance_tolerance_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer zoom finger factor of an object.
///
/// preview
public double ZoomFingerFactor
{
get
{
return Interop.Elementary.elm_gesture_layer_zoom_finger_factor_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_zoom_finger_factor_set(Handle, value);
}
}
///
/// Sets or gets the gesture layer zoom wheel factor of an object.
///
/// preview
public double ZoomWheelFactor
{
get
{
return Interop.Elementary.elm_gesture_layer_zoom_wheel_factor_get(Handle);
}
set
{
Interop.Elementary.elm_gesture_layer_zoom_wheel_factor_set(Handle, value);
}
}
#endregion Properties
///
/// Attaches a gesture layer widget to an Evas object (setting the widget's target).
/// A gesture layer's target may be any Evas object. This object will be used to listen to mouse and key events.
///
/// The object to attach.
/// preview
public void Attach(EvasObject target)
{
Interop.Elementary.elm_gesture_layer_attach(Handle, target.Handle);
}
///
/// Sets the gesture state change callback.
/// When all callbacks for the gesture are set to null, it means this gesture is disabled.
///
/// The gesture you want to track state of.
/// The event the callback tracks (START, MOVE, END, ABORT).
/// The callback itself.
/// preview
public void SetGestureCallback(GestureType type, GestureState state, Action