Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GestureConfigDrag.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 Drag gesture.
11  /// </summary>
12  /// <remarks>A drag gesture can be composed of 1 or more fingers.</remarks>
13  public sealed class GestureConfigDrag : GestureConfig
14  {
15  /// <summary>
16  /// Specify the minimum translation distance required before that the gesture can be recognized as a Drag.
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 value was negative.</exception>
20  /// <remarks>The user can reduce this value if he needs the drag gesture to be triggered even for very small drags.
21  /// On the contrary, he can increase this value if he wants to avoid to deals with too small drags.</remarks>
22  public float MinimumDragDistance
23  {
24  get { return minimumDragDistance; }
25  set
26  {
27  CheckNotFrozen();
28 
29  if(value<0)
30  throw new ArgumentOutOfRangeException("value");
31 
32  minimumDragDistance = value;
33  }
34  }
35 
36  private float minimumDragDistance;
37 
38  /// <summary>
39  /// The (x,y) error margins allowed during directional dragging.
40  /// </summary>
41  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
42  /// <exception cref="ArgumentOutOfRangeException">The provided x or y value was not positive.</exception>
43  /// <remarks>Those values are used only for directional (vertical or horizontal) dragging.
44  /// Decrease those values to trigger the gesture only when the dragging is perfectly in the desired direction.
45  /// Increase those values to allow directional gestures to be more approximative.</remarks>
46  public Vector2 AllowedErrorMargins
47  {
48  get { return allowedErrorMargins; }
49  set
50  {
51  CheckNotFrozen();
52 
53  if(value.X < 0 || value.Y< 0)
54  throw new ArgumentOutOfRangeException("value");
55 
56  allowedErrorMargins = value;
57  }
58  }
59 
60  private Vector2 allowedErrorMargins;
61 
62  /// <summary>
63  /// The shape (direction) of the drag gesture.
64  /// </summary>
65  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
66  public GestureShape DragShape
67  {
68  get { return dragShape; }
69  set
70  {
71  CheckNotFrozen();
72 
73  dragShape = value;
74  }
75  }
76  private GestureShape dragShape;
77 
78  /// <summary>
79  /// Create a default drag gesture configuration for one finger free dragging.
80  /// </summary>
82  : this(GestureShape.Free)
83  {
84  }
85 
86  /// <summary>
87  /// Create a default drag gesture configuration for one finger dragging.
88  /// </summary>
89  /// <param name="dragShape">The dragging shape</param>
90  public GestureConfigDrag(GestureShape dragShape)
91  {
92  AssociatedGestureType = GestureType.Drag;
93 
94  DragShape = dragShape;
95  RequiredNumberOfFingers = 1;
96  AllowedErrorMargins = 0.02f * Vector2.One;
97  MinimumDragDistance = 0.02f;
98  }
99 
100  internal override GestureRecognizer CreateRecognizerImpl(float screenRatio)
101  {
102  return new GestureRecognizerDrag(this, screenRatio);
103  }
104  }
105 }
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
Configuration class for the Drag gesture.
Represent a gesture that has a random shape.
GestureConfigDrag(GestureShape dragShape)
Create a default drag gesture configuration for one finger dragging.
GestureShape
Gesture possible shapes.
Definition: GestureShape.cs:8
This represents the base class for all gesture configuration.
GestureConfigDrag()
Create a default drag gesture configuration for one finger free dragging.