Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GestureConfigTap.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Paradox.Input
6 {
7  /// <summary>
8  /// Configuration class for the Tap gesture.
9  /// </summary>
10  /// <remarks>A tap gesture can be composed of 1 or more fingers.</remarks>
11  public sealed class GestureConfigTap : GestureConfig
12  {
13  /// <summary>
14  /// This value represents the required number of successive user touches to trigger the gesture. For example: 1 for single touch, 2 for double touch, and so on...
15  /// </summary>
16  /// <remarks>This value is strictly positive.</remarks>
17  /// <exception cref="ArgumentOutOfRangeException">The given value is not greater or equal to 1.</exception>
18  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
19  public int RequiredNumberOfTaps
20  {
21  get { return requiredNumberOfTaps; }
22  set
23  {
24  CheckNotFrozen();
25 
26  if(value < 1)
27  throw new ArgumentOutOfRangeException("value");
28 
29  requiredNumberOfTaps = value;
30  }
31  }
32  private int requiredNumberOfTaps;
33 
34  /// <summary>
35  /// This value represents the maximum interval of time that can separate two touches of a same gesture.
36  /// By reducing this value, the system will tend to detect multi-touch gesture has several single touch gesture.
37  /// By increasing this value, the system will tend to regroup distant (in time) single touch gestures into a multi-touch gesture.
38  /// </summary>
39  public TimeSpan MaximumTimeBetweenTaps
40  {
41  get { return maximumTimeBetweenTaps; }
42  set
43  {
44  CheckNotFrozen();
45 
46  maximumTimeBetweenTaps = value;
47  }
48  }
49  private TimeSpan maximumTimeBetweenTaps;
50 
51  /// <summary>
52  /// This value represents the maximum amount of time that the user can stay touching the screen before taking off its finger.
53  /// </summary>
54  public TimeSpan MaximumPressTime
55  {
56  get { return maximumPressTime; }
57  set
58  {
59  CheckNotFrozen();
60 
61  maximumPressTime = value;
62  }
63  }
64  private TimeSpan maximumPressTime;
65 
66  /// <summary>
67  /// The value represents the maximum distance that can separate two touches of the same finger during the gesture.
68  /// By reducing this value, the system will tend to detect multi-touch gesture has several single touch gesture.
69  /// By increasing this value, the system will tend to regroup distant single touch gestures into a multi-touch gesture.
70  /// </summary>
71  /// <exception cref="ArgumentOutOfRangeException">The value has to be positive.</exception>
72  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
73  public float MaximumDistanceTaps
74  {
75  get { return maximumDistanceTaps; }
76  set
77  {
78  CheckNotFrozen();
79 
80  if(value<0)
81  throw new ArgumentOutOfRangeException("value");
82 
83  maximumDistanceTaps = value;
84  }
85  }
86  private float maximumDistanceTaps;
87 
88  /// <summary>
89  /// Create a default Tap gesture configuration for single touch and single finger detection.
90  /// </summary>
92  : this(1,1)
93  {}
94 
95  /// <summary>
96  /// Create a default Tap gesture configuration for the given numbers of touches and fingers.
97  /// </summary>
98  /// <param name="numberOfTap">The number of taps required</param>
99  /// <param name="numberOfFingers">The number of fingers required</param>
100  public GestureConfigTap(int numberOfTap, int numberOfFingers)
101  {
102  AssociatedGestureType = GestureType.Tap;
103 
104  RequiredNumberOfTaps = numberOfTap;
105  RequiredNumberOfFingers = numberOfFingers;
106 
107  MaximumTimeBetweenTaps = TimeSpan.FromMilliseconds(400);
108  MaximumDistanceTaps = 0.04f;
109  MaximumPressTime = TimeSpan.FromMilliseconds(100);
110  }
111 
112  internal override GestureRecognizer CreateRecognizerImpl(float screenRatio)
113  {
114  return new GestureRecognizerTap(this, screenRatio);
115  }
116  }
117 }
GestureConfigTap()
Create a default Tap gesture configuration for single touch and single finger detection.
This represents the base class for all gesture configuration.
Configuration class for the Tap gesture.
GestureConfigTap(int numberOfTap, int numberOfFingers)
Create a default Tap gesture configuration for the given numbers of touches and fingers.