Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GestureConfigComposite.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 Composite gesture.
9  /// </summary>
10  /// <remarks>
11  /// <para>A composite gesture is a transformation which is a composition of a translation, a rotation and a scale.
12  /// It is performed by using two fingers and performing translation, scale and rotation motions.</para>
13  /// <para>A composite gesture can only be composed of 2 fingers.
14  /// Trying to modify the <see cref="GestureConfig.RequiredNumberOfFingers"/> field will throw an exception.</para></remarks>
15  public sealed class GestureConfigComposite : GestureConfig
16  {
17  /// <summary>
18  /// The scale value above which the gesture is started.
19  /// </summary>
20  /// <exception cref="ArgumentOutOfRangeException">The value has to be greater or equal to 1.</exception>
21  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
22  /// <remarks>The user can increase this value if he has small or no interest in the scale component of the transformation.
23  /// By doing so, he avoids triggering the Composite Gesture when only small scale changes happen.
24  /// On the contrary, the user can decrease this value if he wants to be immediately warned about the smallest change in scale.</remarks>
25  public float MinimumScaleValue
26  {
27  get { return minimumScaleValue; }
28  set
29  {
30  CheckNotFrozen();
31 
32  if (value <= 1)
33  throw new ArgumentOutOfRangeException("value");
34 
35  minimumScaleValue = value;
36  MinimumScaleValueInv = 1 / minimumScaleValue;
37  }
38  }
39  private float minimumScaleValue;
40 
41  internal float MinimumScaleValueInv { get; set; }
42 
43  /// <summary>
44  /// The translation distance above which the gesture is started.
45  /// </summary>
46  /// <exception cref="ArgumentOutOfRangeException">The value has to be positive.</exception>
47  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
48  /// <remarks>The user can increase this value if he has small or no interest in the translation component of the transformation.
49  /// By doing so, he avoids triggering the Composite Gesture when only small translation changes happen.
50  /// On the contrary, the user can decrease this value if he wants to be immediately warned about the smallest change in translation.</remarks>
51  public float MinimumTranslationDistance
52  {
53  get { return mminimumTranslationDistance; }
54  set
55  {
56  CheckNotFrozen();
57 
58  if(value<0)
59  throw new ArgumentOutOfRangeException("value");
60 
61  mminimumTranslationDistance = value;
62  }
63  }
64  private float mminimumTranslationDistance;
65 
66  /// <summary>
67  /// The rotation angle (in radian) above which the gesture is started.
68  /// </summary>
69  /// <exception cref="ArgumentOutOfRangeException">The angle has to be strictly positive.</exception>
70  /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
71  /// <remarks>The user can increase this value if he has small or no interest in the rotation component of the transformation.
72  /// By doing so, he avoids triggering the Composite Gesture when only small rotation changes happen.
73  /// On the contrary, the user can decrease this value if he wants to be immediately warned about the smallest change in rotation.</remarks>
74  public float MinimumRotationAngle
75  {
76  get { return minimumRotationAngle; }
77  set
78  {
79  CheckNotFrozen();
80 
81  if(value <= 0)
82  throw new ArgumentOutOfRangeException("value");
83 
84  minimumRotationAngle = value;
85  }
86  }
87 
88  private float minimumRotationAngle;
89 
90  /// <summary>
91  /// Create a default Rotation gesture configuration.
92  /// </summary>
94  : base(2)
95  {
96  AssociatedGestureType = GestureType.Composite;
97 
98  RequiredNumberOfFingers = 2;
99  MinimumRotationAngle = 0.1f;
100  MinimumScaleValue = 1.075f;
101  MinimumTranslationDistance = 0.016f;
102  }
103 
104  internal override GestureRecognizer CreateRecognizerImpl(float screenRatio)
105  {
106  return new GestureRecognizerComposite(this, screenRatio);
107  }
108  }
109 }
This represents the base class for all gesture configuration.
GestureConfigComposite()
Create a default Rotation gesture configuration.
Configuration class for the Composite gesture.