Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GestureConfigFlick.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 using SiliconStudio.Core.Mathematics;
6 
7 namespace SiliconStudio.Paradox.Input
8 {
9  /// <summary>
10  /// Configuration class for the Flick gesture.
11  /// </summary>
12  /// <remarks>A Flick gesture can be composed of 1 or more fingers.</remarks>
13  public sealed class GestureConfigFlick : GestureConfig
14  {
15  /// <summary>
16  /// The (x,y) error margins allowed during directional dragging.
17  /// </summary>
18  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
19  /// <exception cref="ArgumentOutOfRangeException">The provided x or y value was not positive.</exception>
20  public Vector2 AllowedErrorMargins
21  {
22  get { return allowedErrorMargins; }
23  set
24  {
25  CheckNotFrozen();
26 
27  if (value.X < 0 || value.Y < 0)
28  throw new ArgumentOutOfRangeException("value");
29 
30  allowedErrorMargins = value;
31  }
32  }
33  private Vector2 allowedErrorMargins;
34 
35  /// <summary>
36  /// The shape of the flick gesture.
37  /// </summary>
38  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
39  public GestureShape FlickShape
40  {
41  get { return flickShape; }
42  set
43  {
44  CheckNotFrozen();
45 
46  flickShape = value;
47  }
48  }
49  private GestureShape flickShape;
50 
51  /// <summary>
52  /// The minimum average speed of the gesture to be detected as a flick.
53  /// </summary>
54  /// <exception cref="ArgumentOutOfRangeException">The value must be positive</exception>
55  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
56  public float MinimumAverageSpeed
57  {
58  get { return minimumAverageSpeed; }
59 
60  set
61  {
62  CheckNotFrozen();
63 
64  if(value < 0)
65  throw new ArgumentOutOfRangeException("value");
66 
67  minimumAverageSpeed = value;
68  }
69  }
70 
71  private float minimumAverageSpeed;
72 
73  /// <summary>
74  /// The minimum distance that the flick gesture has to cross from its origin to be detected has Flick.
75  /// </summary>
76  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
77  public float MinimumFlickLength
78  {
79  get { return minimumFlickLength; }
80  set
81  {
82  CheckNotFrozen();
83 
84  if(value <= 0)
85  throw new ArgumentOutOfRangeException("value");
86 
87  minimumFlickLength = value;
88  }
89  }
90  private float minimumFlickLength;
91 
92  /// <summary>
93  /// Create a default Flick gesture configuration for one finger free flicking.
94  /// </summary>
96  : this(GestureShape.Free)
97  {
98  }
99 
100  /// <summary>
101  /// Create a default gesture configuration for one finger flicking.
102  /// </summary>
103  /// <param name="flickShape">The shape of the flicking.</param>
104  public GestureConfigFlick(GestureShape flickShape)
105  {
106  AssociatedGestureType = GestureType.Flick;
107 
108  FlickShape = flickShape;
109  RequiredNumberOfFingers = 1;
110  MinimumAverageSpeed = 0.4f;
111  MinimumFlickLength = 0.04f;
112  AllowedErrorMargins = 0.02f * Vector2.One;
113  }
114 
115  internal override GestureRecognizer CreateRecognizerImpl(float screenRatio)
116  {
117  return new GestureRecognizerFlick(this, screenRatio);
118  }
119  }
120 }
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
Configuration class for the Flick gesture.
Represent a gesture that has a random shape.
GestureShape
Gesture possible shapes.
Definition: GestureShape.cs:8
This represents the base class for all gesture configuration.
GestureConfigFlick()
Create a default Flick gesture configuration for one finger free flicking.
GestureConfigFlick(GestureShape flickShape)
Create a default gesture configuration for one finger flicking.