-#ifndef __DALI_PAN_GESTURE_DETECTOR_H__
-#define __DALI_PAN_GESTURE_DETECTOR_H__
+#ifndef DALI_PAN_GESTURE_DETECTOR_H
+#define DALI_PAN_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
*
*/
+// EXTERNAL INCLUDES
+#include <cstdint> // uint32_t
+
// INTERNAL INCLUDES
#include <dali/public-api/events/gesture-detector.h>
+#include <dali/public-api/events/pan-gesture.h>
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
-
struct Radian;
namespace Internal DALI_INTERNAL
class PanGestureDetector;
}
-struct PanGesture;
+/**
+ * @addtogroup dali_core_events
+ * @{
+ */
/**
* @brief This class looks for panning (or dragging) gestures.
* detector.SetMaximumTouchesRequired(2);
* @endcode
*
+ * @SINCE_1_0.0
* @see PanGesture
*
* Signals
* | %Signal Name | Method |
* |--------------|-----------------------|
- * | pan-detected | @ref DetectedSignal() |
+ * | panDetected | @ref DetectedSignal() |
*/
-class DALI_IMPORT_API PanGestureDetector : public GestureDetector
+class DALI_CORE_API PanGestureDetector : public GestureDetector
{
public:
-
/**
- * @brief An enumeration of properties belonging to the PanGestureDetector class.
+ * @brief Enumeration for the instance of properties belonging to the PanGestureDetector class.
+ * @SINCE_1_0.0
*/
struct Property
{
+ /**
+ * @brief Enumeration for the instance of properties belonging to the PanGestureDetector class.
+ * @SINCE_1_0.0
+ */
enum
{
- SCREEN_POSITION = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, ///< name "screen-position", type Vector2
- SCREEN_DISPLACEMENT, ///< name "screen-displacement", type Vector2
- SCREEN_VELOCITY, ///< name "screen-velocity", type Vector2
- LOCAL_POSITION, ///< name "local-position", type Vector2
- LOCAL_DISPLACEMENT, ///< name "local-displacement", type Vector2
- LOCAL_VELOCITY, ///< name "local-velocity", type Vector2
- PANNING, ///< name "panning", type bool
+ SCREEN_POSITION = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, ///< name "screenPosition", type Vector2 @SINCE_1_0.0
+ SCREEN_DISPLACEMENT, ///< name "screenDisplacement", type Vector2 @SINCE_1_0.0
+ SCREEN_VELOCITY, ///< name "screenVelocity", type Vector2 @SINCE_1_0.0
+ LOCAL_POSITION, ///< name "localPosition", type Vector2 @SINCE_1_0.0
+ LOCAL_DISPLACEMENT, ///< name "localDisplacement", type Vector2 @SINCE_1_0.0
+ LOCAL_VELOCITY, ///< name "localVelocity", type Vector2 @SINCE_1_0.0
+ PANNING, ///< name "panning", type bool @SINCE_1_0.0
};
};
// Typedefs
- typedef Signal< void ( Actor, const PanGesture& ) > DetectedSignalType; ///< Pan gesture detected signal type
+ using DetectedSignalType = Signal<void(Actor, const PanGesture&)>; ///< Pan gesture detected signal type @SINCE_1_0.0
// Directional Pan
- typedef std::pair< Radian, Radian > AngleThresholdPair; ///< Range of angles for a direction
+ using AngleThresholdPair = std::pair<Radian, Radian>; ///< Range of angles for a direction @SINCE_1_0.0
static const Radian DIRECTION_LEFT; ///< For a left pan (-PI Radians).
static const Radian DIRECTION_RIGHT; ///< For a right pan (0 Radians).
static const Radian DIRECTION_HORIZONTAL; ///< For a left and right pan (PI Radians). Useful for AddDirection().
static const Radian DIRECTION_VERTICAL; ///< For an up and down pan (-0.5 * PI Radians). Useful for AddDirection().
- static const Radian DEFAULT_THRESHOLD; ///< The default threshold is PI * 0.25 radians (or 45 degrees).
+ static const Radian DEFAULT_THRESHOLD; ///< The default threshold is PI * 0.25 radians (or 45 degrees).
public: // Creation & Destruction
-
/**
- * @brief Create an uninitialized PanGestureDetector; this can be initialized with PanGestureDetector::New().
+ * @brief Creates an uninitialized PanGestureDetector; this can be initialized with PanGestureDetector::New().
*
- * Calling member functions with an uninitialized Dali::Object is not allowed.
+ * Calling member functions with an uninitialized PanGestureDetector handle is not allowed.
+ * @SINCE_1_0.0
*/
PanGestureDetector();
/**
- * @brief Create an initialized PanGestureDetector.
+ * @brief Creates an initialized PanGestureDetector.
*
- * @return A handle to a newly allocated Dali resource.
+ * @SINCE_1_0.0
+ * @return A handle to a newly allocated Dali resource
*/
static PanGestureDetector New();
/**
- * @brief Downcast an Object handle to PanGestureDetector handle.
+ * @brief Downcasts a handle to PanGestureDetector handle.
*
- * If handle points to a PanGestureDetector object the
- * downcast produces valid handle. If not the returned handle is left uninitialized.
- * @param[in] handle to An object
- * @return handle to a PanGestureDetector object or an uninitialized handle
+ * If handle points to a PanGestureDetector object, the
+ * downcast produces valid handle. If not, the returned handle is left uninitialized.
+ * @SINCE_1_0.0
+ * @param[in] handle Handle to an object
+ * @return Handle to a PanGestureDetector object or an uninitialized handle
*/
- static PanGestureDetector DownCast( BaseHandle handle );
+ static PanGestureDetector DownCast(BaseHandle handle);
/**
- * @brief Destructor
+ * @brief Destructor.
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
+ * @SINCE_1_0.0
*/
~PanGestureDetector();
/**
* @brief This copy constructor is required for (smart) pointer semantics.
*
- * @param [in] handle A reference to the copied handle
+ * @SINCE_1_0.0
+ * @param[in] handle A reference to the copied handle
*/
PanGestureDetector(const PanGestureDetector& handle);
/**
* @brief This assignment operator is required for (smart) pointer semantics.
*
- * @param [in] rhs A reference to the copied handle
+ * @SINCE_1_0.0
+ * @param[in] rhs A reference to the copied handle
* @return A reference to this
*/
PanGestureDetector& operator=(const PanGestureDetector& rhs);
-public: // Setters
+ /**
+ * @brief This move constructor is required for (smart) pointer semantics.
+ *
+ * @SINCE_2_2.4
+ * @param[in] handle A reference to the moved handle
+ */
+ PanGestureDetector(PanGestureDetector&& handle) noexcept;
/**
+ * @brief This move assignment operator is required for (smart) pointer semantics.
+ *
+ * @SINCE_2_2.4
+ * @param[in] rhs A reference to the moved handle
+ * @return A reference to this
+ */
+ PanGestureDetector& operator=(PanGestureDetector&& rhs) noexcept;
+
+public: // Setters
+ /**
* @brief This is the minimum number of touches required for the pan gesture to be detected.
*
- * @param[in] minimum Minimum touches required.
+ * @SINCE_1_0.0
+ * @param[in] minimum Minimum touches required
* @pre The gesture detector has been initialized.
* @note The default minimum is '1'.
*/
- void SetMinimumTouchesRequired(unsigned int minimum);
+ void SetMinimumTouchesRequired(uint32_t minimum);
/**
* @brief This is the maximum number of touches required for the pan gesture to be detected.
*
- * @param[in] maximum Maximum touches required.
+ * @SINCE_1_0.0
+ * @param[in] maximum Maximum touches required
* @pre The gesture detector has been initialized.
* @note The default maximum is '1'.
*/
- void SetMaximumTouchesRequired(unsigned int maximum);
+ void SetMaximumTouchesRequired(uint32_t maximum);
-public: // Getters
+ /**
+ * @brief This value is a maximum duration of motion can live on the pan gesture event queue.
+ * If duration exceed it, the motion event is discarded.
+ *
+ * @SINCE_2_1.28
+ * @param[in] maximumAge Maximum age of motion events as milliseconds
+ * @pre The gesture detector has been initialized.
+ * @note The default maximumAge is 'std::numeric_limits<uint32_t>::max()'.
+ */
+ void SetMaximumMotionEventAge(uint32_t maximumAge);
+public: // Getters
/**
* @brief Retrieves the minimum number of touches required for the pan gesture to be detected.
*
- * @return The minimum touches required.
+ * @SINCE_1_0.0
+ * @return The minimum touches required
* @pre The gesture detector has been initialized.
*/
- unsigned int GetMinimumTouchesRequired() const;
+ uint32_t GetMinimumTouchesRequired() const;
/**
* @brief Retrieves the maximum number of touches required for the pan gesture to be detected.
*
- * @return The maximum touches required.
+ * @SINCE_1_0.0
+ * @return The maximum touches required
* @pre The gesture detector has been initialized.
*/
- unsigned int GetMaximumTouchesRequired() const;
+ uint32_t GetMaximumTouchesRequired() const;
-public: // Directional Panning
+ /**
+ * @brief Retrieves the maximum age for the pan gesture motion as milliseconds.
+ *
+ * @SINCE_2_1.28
+ * @return The maximum age of motion events as milliseconds
+ * @pre The gesture detector has been initialized.
+ */
+ uint32_t GetMaximumMotionEventAge() const;
+public: // Directional Panning
/**
* @brief The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.
*
* If an angle of 0.0 degrees is specified and the threshold is 45 degrees then the acceptable
* direction range is from -45 to 45 degrees.
*
- * @param[in] angle The angle that pan should be allowed.
- * @param[in] threshold The threshold around that angle.
+ * @SINCE_1_0.0
+ * @param[in] angle The angle that pan should be allowed
+ * @param[in] threshold The threshold around that angle
*
+ * @pre The gesture detector has been initialized.
* @note The angle added using this API is only checked when the gesture first starts, after that,
* this detector will emit the gesture regardless of what angle the pan is moving.
* @note The user can add as many angles as they require.
* @note If no threshold is provided, then the default threshold (PI * 0.25) is used.
* @note If the threshold is greater than PI, then PI will be used as the threshold.
*
- * @pre The gesture detector has been initialized.
*/
- void AddAngle( Radian angle, Radian threshold = DEFAULT_THRESHOLD );
+ void AddAngle(Radian angle, Radian threshold = DEFAULT_THRESHOLD);
/**
* @brief A helper method for adding bi-directional angles where the pan should take place.
* In other words, if 0 is requested, then PI will also be added so that we have both left and
* right scrolling.
*
- * @param[in] direction The direction of panning required.
- * @param[in] threshold The threshold.
+ * @SINCE_1_0.0
+ * @param[in] direction The direction of panning required
+ * @param[in] threshold The threshold
+ *
+ * @pre The gesture detector has been initialized.
*
* @note If a direction outside the range above is given, then it is wrapped within the range, i.e.
* 190 degrees becomes -170 degrees and 370 degrees becomes 10 degrees.
* @note If the threshold is greater than PI, then PI will be used as the threshold.
* @note As long as you specify the type, you can also pass in a Dali::Degree to this method.
*
- * @pre The gesture detector has been initialized.
- *
* @see AddAngle
*/
- void AddDirection( Radian direction, Radian threshold = DEFAULT_THRESHOLD );
+ void AddDirection(Radian direction, Radian threshold = DEFAULT_THRESHOLD);
/**
* @brief Returns the count of angles that this pan gesture detector emits a signal.
*
- * @return The count.
+ * @SINCE_1_0.0
+ * @return The count
* @pre The gesture detector has been initialized.
*/
size_t GetAngleCount() const;
/**
* @brief Returns the angle by index that this pan gesture detector emits a signal.
*
- * @return an angle threshold pair, or a zero valued angle pair when index is invalid.
+ * @SINCE_1_0.0
+ * @param[in] index The angle's index
+ * @return An angle threshold pair, or a zero valued angle pair when index is invalid
* @pre The gesture detector has been initialized.
* @pre The index is less than GetAngleCount()
*/
*
* After this, the pan gesture
* will be emitted for a pan in ANY direction.
+ * @SINCE_1_0.0
* @pre The gesture detector has been initialized.
*/
void ClearAngles();
/**
* @brief Removes the angle specified from the container.
*
- * @param[in] angle The angle to remove.
+ * @SINCE_1_0.0
+ * @param[in] angle The angle to remove
* @pre The gesture detector has been initialized.
* @note This will only remove the first instance of the angle found from the container.
* @note If an angle outside the range in AddAngle() is given, then the value is wrapped within
* the range and that is removed.
*/
- void RemoveAngle( Radian angle );
+ void RemoveAngle(Radian angle);
/**
* @brief Removes the two angles that make up the direction from the container.
*
- * @param[in] direction The direction to remove.
+ * @SINCE_1_0.0
+ * @param[in] direction The direction to remove
* @pre The gesture detector has been initialized.
* @note If a direction outside the range in AddAngle() is given, then the value is wrapped within
* the range and that is removed.
*/
- void RemoveDirection( Radian direction );
+ void RemoveDirection(Radian direction);
public: // Signals
-
/**
* @brief This signal is emitted when the pan gesture is detected on the attached actor.
*
* @code
* void YourCallbackName( Actor actor, const PanGesture& gesture );
* @endcode
+ * @SINCE_1_0.0
+ * @return The signal to connect to
* @pre The gesture detector has been initialized.
- * @return The signal to connect to.
*/
DetectedSignalType& DetectedSignal();
public: // Pan Properties Setters
-
/**
* @brief Allows setting of the pan properties that are returned in constraints.
*
- * @param[in] pan The pan gesture to set.
- *@note If a normal pan is taking place, then any value set is ignored.
+ * @SINCE_1_0.0
+ * @param[in] pan The pan gesture to set
+ * @note If a normal pan is taking place, then any value set is ignored.
*/
- static void SetPanGestureProperties( const PanGesture& pan );
+ static void SetPanGestureProperties(const PanGesture& pan);
public: // Not intended for Application developers
-
+ /// @cond internal
/**
- * @brief This constructor is used by Dali New() methods.
+ * @brief This constructor is used by PanGestureDetector::New() methods.
*
- * @param [in] internal A pointer to a newly allocated Dali resource.
+ * @SINCE_1_0.0
+ * @param[in] internal A pointer to a newly allocated Dali resource
*/
explicit DALI_INTERNAL PanGestureDetector(Internal::PanGestureDetector* internal);
-
+ /// @endcond
};
+/**
+ * @}
+ */
+
} // namespace Dali
-#endif // __DALI_PAN_GESTURE_DETECTOR_H__
+#endif // DALI_PAN_GESTURE_DETECTOR_H