/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* 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 Tizen.NUI.BaseComponents;
using System.ComponentModel;
namespace Tizen.NUI
{
///
/// This class emits a signals when a pan gesture occurs.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class PanGestureDetector : GestureDetector
{
///
/// Creates an initialized PanGestureDetector.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public PanGestureDetector() : this(Interop.PanGestureDetector.New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The copy constructor.
///
/// A reference to the copied handle
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public PanGestureDetector(PanGestureDetector handle) : this(Interop.PanGestureDetector.NewPanGestureDetector(PanGestureDetector.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal PanGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PanGestureDetector.Upcast(cPtr), cMemoryOwn)
{
}
private DaliEventHandler _detectedEventHandler;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void DetectedCallbackType(IntPtr actor, IntPtr panGesture);
private DetectedCallbackType _detectedCallback;
///
/// This signal is emitted when the specified pan is detected on the attached view.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public event DaliEventHandler Detected
{
add
{
if (_detectedEventHandler == null)
{
_detectedCallback = OnPanGestureDetected;
DetectedSignal().Connect(_detectedCallback);
}
_detectedEventHandler += value;
}
remove
{
_detectedEventHandler -= value;
if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
{
DetectedSignal().Disconnect(_detectedCallback);
}
}
}
///
/// For a left pan (-PI Radians).
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionLeft
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionLeftGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// For a right pan (0 Radians).
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionRight
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionRightGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// For an up pan (-0.5 * PI Radians).
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionUp
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionUpGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// For a down pan (0.5 * PI Radians).
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionDown
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionDownGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// For a left and right pan (PI Radians). Useful for AddDirection().
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionHorizontal
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionHorizontalGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// For an up and down pan (-0.5 * PI Radians). Useful for AddDirection().
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DirectionVertical
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionVerticalGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The default threshold is PI * 0.25 radians (or 45 degrees).
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Radian DefaultThreshold
{
get
{
global::System.IntPtr cPtr = Interop.PanGestureDetector.DefaultThresholdGet();
Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// Retrieves the screen position.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 ScreenPosition
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return temp;
}
}
///
/// Retrieves the screen displacement.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 ScreenDisplacement
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenDisplacement).Get(temp);
return temp;
}
}
///
/// Retrieves the screen velocity.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 ScreenVelocity
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenVelocity).Get(temp);
return temp;
}
}
///
/// Retrieves the local position.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 LocalPosition
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalPosition).Get(temp);
return temp;
}
}
///
/// Retrieves the local displacement
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 LocalDisplacement
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalDisplacement).Get(temp);
return temp;
}
}
///
/// Retrieves the local velocity.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 LocalVelocity
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalVelocity).Get(temp);
return temp;
}
}
///
/// Retrieves the panning flag.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool Panning
{
get
{
bool temp = false;
Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.PANNING).Get(out temp);
return temp;
}
}
///
/// This is the minimum number of touches required for the pan gesture to be detected.
///
/// Minimum touches required
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetMinimumTouchesRequired(uint minimum)
{
Interop.PanGestureDetector.SetMinimumTouchesRequired(SwigCPtr, minimum);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// This is the maximum number of touches required for the pan gesture to be detected.
///
/// Maximum touches required
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetMaximumTouchesRequired(uint maximum)
{
Interop.PanGestureDetector.SetMaximumTouchesRequired(SwigCPtr, maximum);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Retrieves the minimum number of touches required for the pan gesture to be detected.
///
/// The minimum touches required
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetMinimumTouchesRequired()
{
uint ret = Interop.PanGestureDetector.GetMinimumTouchesRequired(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves the maximum number of touches required for the pan gesture to be detected.
///
/// The maximum touches required
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetMaximumTouchesRequired()
{
uint ret = Interop.PanGestureDetector.GetMaximumTouchesRequired(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.
/// If an angle of 0.0 degrees is specified and the threshold is 45 degrees then the acceptable direction range is from -45 to 45 degrees.
/// The angle added using this API is only checked when the gesture first starts, after that, this detector will emit the gesture regardless of what angle the pan is moving.
/// The user can add as many angles as they require.
///
/// The angle that pan should be allowed
/// The threshold around that angle
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddAngle(Radian angle, Radian threshold)
{
Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance. The default threshold (PI * 0.25) is used.
/// The angle added using this API is only checked when the gesture first starts, after that, this detector will emit the gesture regardless of what angle the pan is moving.
/// The user can add as many angles as they require.
///
/// The angle that pan should be allowed
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddAngle(Radian angle)
{
Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// A helper method for adding bi-directional angles where the pan should take place.
/// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.
///
/// The direction of panning required
/// The threshold
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddDirection(Radian direction, Radian threshold)
{
Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// A helper method for adding bi-directional angles where the pan should take place.
/// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.
/// The default threshold (PI * 0.25) is used.
///
/// The direction of panning required
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddDirection(Radian direction)
{
Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns the count of angles that this pan gesture detector emits a signal.
///
/// The gesture detector has been initialized.
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetAngleCount()
{
uint ret = Interop.PanGestureDetector.GetAngleCount(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Clears any directional angles that are used by the gesture detector.
///
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void ClearAngles()
{
Interop.PanGestureDetector.ClearAngles(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Removes the angle specified from the container. This will only remove the first instance of the angle found from the container.
///
/// The angle to remove
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void RemoveAngle(Radian angle)
{
Interop.PanGestureDetector.RemoveAngle(SwigCPtr, Radian.getCPtr(angle));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Removes the two angles that make up the direction from the container.
///
/// The direction to remove
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void RemoveDirection(Radian direction)
{
Interop.PanGestureDetector.RemoveDirection(SwigCPtr, Radian.getCPtr(direction));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Allows setting of the pan properties that are returned in constraints.
///
/// The pan gesture to set
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetPanGestureProperties(PanGesture pan)
{
Interop.PanGestureDetector.SetPanGestureProperties(PanGesture.getCPtr(pan));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
{
PanGestureDetector ret = new PanGestureDetector(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PanGestureDetector obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
}
internal new static PanGestureDetector DownCast(BaseHandle handle)
{
PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal AngleThresholdPair GetAngle(uint index)
{
AngleThresholdPair ret = new AngleThresholdPair(Interop.PanGestureDetector.GetAngle(SwigCPtr, index), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal PanGestureDetector Assign(PanGestureDetector rhs)
{
PanGestureDetector ret = new PanGestureDetector(Interop.PanGestureDetector.Assign(SwigCPtr, PanGestureDetector.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal PanGestureDetectedSignal DetectedSignal()
{
PanGestureDetectedSignal ret = new PanGestureDetectedSignal(Interop.PanGestureDetector.DetectedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
if (_detectedCallback != null)
{
DetectedSignal().Disconnect(_detectedCallback);
}
Interop.PanGestureDetector.DeletePanGestureDetector(swigCPtr);
}
private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
{
DetectedEventArgs e = new DetectedEventArgs();
// Populate all members of "e" (PanGestureEventArgs) with real data
e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
if (null == e.View)
{
e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
}
e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
if (_detectedEventHandler != null)
{
_detectedEventHandler(this, e);
}
}
///
/// Event arguments that are passed via the PanGestureEvent signal.
///
/// 5
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class DetectedEventArgs : EventArgs
{
private View _view;
private PanGesture _panGesture;
///
/// The attached view.
///
/// 5
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public View View
{
get
{
return _view;
}
set
{
_view = value;
}
}
///
/// The PanGesture.
///
/// 5
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public PanGesture PanGesture
{
get
{
return _panGesture;
}
set
{
_panGesture = value;
}
}
}
internal class Property
{
internal static readonly int ScreenPosition = Interop.PanGestureDetector.ScreenPositionGet();
internal static readonly int ScreenDisplacement = Interop.PanGestureDetector.ScreenDisplacementGet();
internal static readonly int ScreenVelocity = Interop.PanGestureDetector.ScreenVelocityGet();
internal static readonly int LocalPosition = Interop.PanGestureDetector.LocalPositionGet();
internal static readonly int LocalDisplacement = Interop.PanGestureDetector.LocalDisplacementGet();
internal static readonly int LocalVelocity = Interop.PanGestureDetector.LocalVelocityGet();
internal static readonly int PANNING = Interop.PanGestureDetector.PanningGet();
}
}
}