Pan Gesture Prediction - Fixed issue where initial displacement could be close to...
[platform/core/uifw/dali-core.git] / dali / internal / update / gestures / scene-graph-pan-gesture.h
index 1d0d6a0..fe0be5c 100644 (file)
@@ -1,21 +1,22 @@
 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PAN_GESTURE_H__
 #define __DALI_INTERNAL_SCENE_GRAPH_PAN_GESTURE_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
@@ -167,7 +168,7 @@ public:
   typedef PanInfoHistory::const_iterator PanInfoHistoryConstIter;
 
 private:
-  static const unsigned int PAN_GESTURE_HISTORY = 4u;
+  static const unsigned int PAN_GESTURE_HISTORY = 10u;
 
 public:
 
@@ -195,7 +196,7 @@ public:
    * @param[in] maxAge Maximum age of an event before removing (in millis)
    * @param[in] minEvents The minimum number of events to leave in history, oldest events are removed before newest
    */
-  void RemoveOldHistory(PanInfoHistory& panHistory, uint currentTime, uint maxAge, uint minEvents);
+  void RemoveOldHistory(PanInfoHistory& panHistory, unsigned int currentTime, unsigned int maxAge, unsigned int minEvents);
 
   /**
    * USes last two gestures
@@ -217,8 +218,15 @@ public:
   /**
    * Called by the update manager so that we can update the value of our properties.
    * @param[in]  nextRenderTime  The estimated time of the next render (in milliseconds).
+   * @return true, if properties were updated.
+   */
+  virtual bool UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
+
+  /**
+   * Retrieves a reference to the panning flag property.
+   * @return The panning flag property.
    */
-  virtual void UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
+  const GesturePropertyBool& GetPanningProperty() const;
 
   /**
    * Retrieves a reference to the screen position property.
@@ -249,7 +257,14 @@ public:
    *
    * @param[in] mode The prediction mode
    */
-  void SetPredictionMode(PredictionMode mode) { mPredictionMode = mode; }
+  void SetPredictionMode(PredictionMode mode);
+
+  /**
+   * @brief Sets the prediction amount of the pan gesture
+   *
+   * @param[in] amount The prediction amount in milliseconds
+   */
+  void SetPredictionAmount(unsigned int amount);
 
   /**
    * Called to provide pan-gesture profiling information.
@@ -275,6 +290,7 @@ private:
 private:
 
   // Properties
+  GesturePropertyBool    mPanning;            ///< panning flag
   GesturePropertyVector2 mScreenPosition;     ///< screen-position
   GesturePropertyVector2 mScreenDisplacement; ///< screen-displacement
   GesturePropertyVector2 mLocalPosition;      ///< local-position
@@ -285,11 +301,13 @@ private:
   unsigned int mWritePosition;  ///< The next PanInfo buffer to write to. (starts at 0)
   unsigned int mReadPosition;   ///< The next PanInfo buffer to read. (starts at 0)
 
-  PanInfo mEventGesture;        ///< Result of all pan events received since last frame
+  PanInfo mEventGesture;        ///< Result of all pan events received this frame
+  PanInfo mLastEventGesture;    ///< The last frame's event gesture.
   PanInfo mLatestGesture;       ///< The latest gesture. (this update frame)
   bool mInGesture;              ///< True if the gesture is currently being handled i.e. between Started <-> Finished/Cancelled
 
   PredictionMode mPredictionMode;  ///< The pan gesture prediction mode
+  unsigned int mPredictionAmount;  ///< how far into future to predict in milliseconds
   PanGestureProfiling* mProfiling; ///< NULL unless pan-gesture profiling information is required.
 };