Pan Gesture Smoothing - Added APIs to change smoothing mode and amount 38/24138/1
authorJulien Heanley <j.heanley@partner.samsung.com>
Thu, 26 Jun 2014 09:04:17 +0000 (10:04 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 16:04:35 +0000 (17:04 +0100)
  DALI_PAN_SMOOTHING_MODE - Currently only 0 for off and 1 for a simple smoothing technique
  DALI_PAN_SMOOTHING_AMOUNT - From 0.0f for no smoothing to 1.0f for full smoothing

[problem]      Predicted panning is a little jittery at times
[cause]        Any slight error in touch data could skew the calculations a little
[solution]     Added smoothing phase

Change-Id: Ifc573419a63904fdadbc169fbeefd9dcae27dc0b
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
adaptors/base/environment-options.cpp
adaptors/base/environment-options.h
adaptors/base/environment-variables.h
adaptors/tizen/internal/common/adaptor-impl.cpp

index 764a159..6ef540b 100644 (file)
@@ -34,6 +34,8 @@ EnvironmentOptions::EnvironmentOptions()
   mPanGestureLoggingLevel(0),
   mPanGesturePredictionMode(-1),
   mPanGesturePredictionAmount(-1.0f), ///< only sets value in pan gesture if greater than 0
+  mPanGestureSmoothingMode(-1),
+  mPanGestureSmoothingAmount(-1.0f),
   mPanMinimumDistance(-1),
   mPanMinimumEvents(-1),
   mLogFunction( NULL )
@@ -87,7 +89,7 @@ unsigned int EnvironmentOptions::GetPanGestureLoggingLevel() const
   return mPanGestureLoggingLevel;
 }
 
-int EnvironmentOptions::GetPanGestureSmoothingMode() const
+int EnvironmentOptions::GetPanGesturePredictionMode() const
 {
   return mPanGesturePredictionMode;
 }
@@ -97,6 +99,16 @@ float EnvironmentOptions::GetPanGesturePredictionAmount() const
   return mPanGesturePredictionAmount;
 }
 
+int EnvironmentOptions::GetPanGestureSmoothingMode() const
+{
+  return mPanGestureSmoothingMode;
+}
+
+float EnvironmentOptions::GetPanGestureSmoothingAmount() const
+{
+  return mPanGestureSmoothingAmount;
+}
+
 int EnvironmentOptions::GetMinimumPanDistance() const
 {
   return mPanMinimumDistance;
@@ -107,16 +119,26 @@ int EnvironmentOptions::GetMinimumPanEvents() const
   return mPanMinimumEvents;
 }
 
-void EnvironmentOptions::SetPanGesturePredictionMode(unsigned int mode)
+void EnvironmentOptions::SetPanGesturePredictionMode( unsigned int mode )
 {
   mPanGesturePredictionMode = mode;
 }
 
-void EnvironmentOptions::SetPanGesturePredictionAmount(unsigned int amount)
+void EnvironmentOptions::SetPanGesturePredictionAmount( unsigned int amount )
 {
   mPanGesturePredictionAmount = amount;
 }
 
+void EnvironmentOptions::SetPanGestureSmoothingMode( unsigned int mode )
+{
+  mPanGestureSmoothingMode = mode;
+}
+
+void EnvironmentOptions::SetPanGestureSmoothingAmount( float amount )
+{
+  mPanGestureSmoothingAmount = amount;
+}
+
 void EnvironmentOptions::SetMinimumPanDistance( int distance )
 {
   mPanMinimumDistance = distance;
index 1ff9a8b..2ba26d0 100644 (file)
@@ -90,9 +90,9 @@ public:
   unsigned int GetPanGestureLoggingLevel() const;
 
   /**
-   * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing )
+   * @return pan-gesture prediction mode ( -1 means not set so no prediction, 0 = no prediction )
    */
-  int GetPanGestureSmoothingMode() const;
+  int GetPanGesturePredictionMode() const;
 
   /**
    * @return pan-gesture prediction amount
@@ -100,6 +100,16 @@ public:
   float GetPanGesturePredictionAmount() const;
 
   /**
+   * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing )
+   */
+  int GetPanGestureSmoothingMode() const;
+
+  /**
+   * @return pan-gesture smoothing amount
+   */
+  float GetPanGestureSmoothingAmount() const;
+
+  /**
    * @return The minimum distance before a pan can be started (-1 means it's not set)
    */
   int GetMinimumPanDistance() const;
@@ -114,14 +124,28 @@ public:
    *
    * @param[in] mode The smoothing mode to use
    */
-  void SetPanGesturePredictionMode(unsigned int mode);
+  void SetPanGesturePredictionMode( unsigned int mode );
 
   /**
    * @brief Sets the prediction amount of the pan gesture
    *
    * @param[in] amount The prediction amount in milliseconds
    */
-  void SetPanGesturePredictionAmount(unsigned int amount);
+  void SetPanGesturePredictionAmount( unsigned int amount );
+
+  /**
+   * @brief Called to set how pan gestures smooth input
+   *
+   * @param[in] mode The smoothing mode to use
+   */
+  void SetPanGestureSmoothingMode( unsigned int mode );
+
+  /**
+   * @brief Sets the prediction amount of the pan gesture
+   *
+   * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
+   */
+  void SetPanGestureSmoothingAmount( float amount );
 
   /**
    * @brief Sets the minimum distance required before a pan starts
@@ -145,6 +169,8 @@ private:
   unsigned int mPanGestureLoggingLevel;           ///< pan-gesture log level
   int mPanGesturePredictionMode;                  ///< prediction mode for pan gestures
   float mPanGesturePredictionAmount;              ///< prediction amount for pan gestures
+  int mPanGestureSmoothingMode;                  ///< prediction mode for pan gestures
+  float mPanGestureSmoothingAmount;              ///< prediction amount for pan gestures
   int mPanMinimumDistance;                        ///< minimum distance required before pan starts
   int mPanMinimumEvents;                          ///< minimum events required before pan starts
 
index f240292..dbe7513 100644 (file)
@@ -35,6 +35,10 @@ namespace Adaptor
 
 #define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT"
 
+#define DALI_ENV_PAN_SMOOTHING_MODE "DALI_PAN_SMOOTHING_MODE"
+
+#define DALI_ENV_PAN_SMOOTHING_AMOUNT "DALI_PAN_SMOOTHING_AMOUNT"
+
 #define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE"
 
 #define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS"
index 6e09188..16c53e0 100644 (file)
@@ -154,6 +154,17 @@ void Adaptor::ParseEnvironmentOptions()
     }
     mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
   }
+  int smoothingMode;
+  if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
+  {
+    mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
+  }
+  float smoothingAmount = 1.0f;
+  if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
+  {
+    smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
+    mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
+  }
 
   int minimumDistance(-1);
   if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
@@ -210,14 +221,22 @@ void Adaptor::Initialize()
   {
     Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
   }
-  if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
+  if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
   {
-    Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
+    Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
   }
   if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0.0f )
   {
     Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
   }
+  if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
+  {
+    Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
+  }
+  if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
+  {
+    Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
+  }
 }
 
 Adaptor::~Adaptor()