Elm gesture_layer: Added gesture layer widget.

Gesture layer allows detection of gestures and essentially gives the
user a unified way of getting "complex" input.
It doesn't do (by design) complex gestures like "V" or "S", instead it
does simple and fast interaction gestures like: 2-finger
pinch/rotate/lines or CTRL+Mouse_Wheel zoom and etc.
This lets people to write an application/widget regardless of the input
device used and in a nice consistent way.

Although we consider the API "good", it may change completely. I'm
committing it now so people will be able to start using it, and
hopefully give feedback.

Work by Aharon Hillel with my help.

SVN revision: 61118
This commit is contained in:
Tom Hacohen 2011-07-07 14:41:03 +00:00
parent 2188b1c263
commit 74d7906e61
3 changed files with 3160 additions and 0 deletions

View File

@ -3862,6 +3862,273 @@ extern "C" {
* "drag,end" - Dragged item was dropped (somewhere)
*/
/* gesture layer */
/** @defgroup Elm_Gesture_Layer Gesture Layer */
/**
* @enum _Elm_Gesture_Types
* Emum of supported gesture types.
* @ingroup Elm_Gesture_Layer
*/
enum _Elm_Gesture_Types
{
ELM_GESTURE_FIRST = 0,
ELM_GESTURE_N_TAPS, /**< N fingers single taps */
ELM_GESTURE_N_DOUBLE_TAPS, /**< N fingers double-single taps */
ELM_GESTURE_N_TRIPLE_TAPS, /**< N fingers triple-single taps */
ELM_GESTURE_MOMENTUM, /**< Reports momentum in the dircetion of move */
ELM_GESTURE_N_LINES, /**< N fingers line gesture */
ELM_GESTURE_N_FLICKS, /**< N fingers flick gesture */
ELM_GESTURE_ZOOM, /**< Zoom */
ELM_GESTURE_ROTATE, /**< Rotate */
ELM_GESTURE_LAST
};
/**
* @typedef Elm_Gesture_Types
* Type for Emum of supported gesture types.
* @ingroup Elm_Gesture_Layer
*/
typedef enum _Elm_Gesture_Types Elm_Gesture_Types;
/**
* @enum _Elm_Gesture_State
* Emum of gesture states.
* @ingroup Elm_Gesture_Layer
*/
enum _Elm_Gesture_State
{
ELM_GESTURE_STATE_UNDEFINED = -1, /**< Gesture not STARTed */
ELM_GESTURE_STATE_START, /**< Gesture STARTed */
ELM_GESTURE_STATE_MOVE, /**< Gesture is ongoing */
ELM_GESTURE_STATE_END, /**< Gesture completed */
ELM_GESTURE_STATE_ABORT /**< Onging gesture was ABORTed */
};
/**
* @typedef Elm_Gesture_State
* gesture states.
* @ingroup Elm_Gesture_Layer
*/
typedef enum _Elm_Gesture_State Elm_Gesture_State;
/**
* @struct _Elm_Gesture_Taps_Info
* Struct holds taps info for user
* @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Taps_Info
{
Evas_Coord x, y; /**< Holds center point between fingers */
unsigned int n; /**< Number of fingers tapped */
unsigned int timestamp; /**< event timestamp */
};
/**
* @typedef Elm_Gesture_Taps_Info
* holds taps info for user
* @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Taps_Info Elm_Gesture_Taps_Info;
/**
* @struct _Elm_Gesture_Momentum_Info
* Struct holds momentum info for user
* x1 and y1 are not necessarily in sync
* x1 holds x value of x direction starting point
* and same holds for y1.
* This is noticeable when doing V-shape movement
* @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Momentum_Info
{ /* Report line ends, timestamps, and momentum computed */
Evas_Coord x1; /**< Final-swipe direction starting point on X */
Evas_Coord y1; /**< Final-swipe direction starting point on Y */
Evas_Coord x2; /**< Final-swipe direction ending point on X */
Evas_Coord y2; /**< Final-swipe direction ending point on Y */
unsigned int tx; /**< Timestamp of start of final x-swipe */
unsigned int ty; /**< Timestamp of start of final y-swipe */
Evas_Coord mx; /**< Momentum on X */
Evas_Coord my; /**< Momentum on Y */
};
/**
* @typedef Elm_Gesture_Momentum_Info
* holds momentum info for user
* @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Momentum_Info Elm_Gesture_Momentum_Info;
/**
* @struct _Elm_Gesture_Line_Info
* Struct holds line info for user
* @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Line_Info
{ /* Report line ends, timestamps, and momentum computed */
Elm_Gesture_Momentum_Info momentum; /**< Line momentum info */
unsigned int n; /**< Number of fingers (lines) */
/* FIXME should be radians, bot degrees */
double angle; /**< Angle (direction) of lines */
};
/**
* @typedef _Elm_Gesture_Line_Info
* Holds line info for user
* @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Line_Info Elm_Gesture_Line_Info;
/**
* @struct _Elm_Gesture_Zoom_Info
* Struct holds zoom info for user
* @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Zoom_Info
{
Evas_Coord x, y; /**< Holds zoom center point reported to user */
Evas_Coord radius; /**< Holds radius between fingers reported to user */
float zoom; /**< Zoom value: 1.0 means no zoom */
float momentum; /**< Zoom momentum: zoom growth per second (NOT YET SUPPORTED) */
};
/**
* @typedef Elm_Gesture_Zoom_Info
* Holds zoom info for user
* @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;
/**
* @struct _Elm_Gesture_Rotate_Info
* Struct holds rotation info for user
* @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Rotate_Info
{
Evas_Coord x, y; /**< Holds zoom center point reported to user */
Evas_Coord radius; /**< Holds radius between fingers reported to user */
double base_angle; /**< Holds start-angle */
double angle; /**< Rotation value: 0.0 means no rotation */
double momentum; /**< Rotation momentum: rotation done per second (NOT YET SUPPORTED) */
};
/**
* @typedef Elm_Gesture_Rotate_Info
* Holds rotation info for user
* @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Rotate_Info Elm_Gesture_Rotate_Info;
/**
* @typedef Elm_Gesture_Event_Cb
* User callback used to stream gesture info from gesture layer
* @param data user data
* @param event_info gesture report info
* Returns a flag field to be applied on the causing event.
* You should probably return EVAS_EVENT_FLAG_ON_HOLD if your widget acted
* upon the event, in an irreversible way.
*
* @ingroup Elm_Gesture_Layer
*/
typedef Evas_Event_Flags (*Elm_Gesture_Event_Cb) (void *data, void *event_info);
/**
* Use function to set callbacks to be notified about
* change of state of gesture.
* When a user registers a callback with this function
* this means this gesture has to be tested.
*
* When ALL callbacks for a gesture are set to NULL
* it means user isn't interested in gesture-state
* and it will not be tested.
*
* @param obj Pointer to gesture-layer.
* @param idx The gesture you would like to track its state.
* @param cb callback function pointer.
* @param cb_type what event this callback tracks: START, MOVE, END, ABORT.
* @param data user info to be sent to callback (usually, Smart Data)
*
* @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_cb_set(Evas_Object *obj, Elm_Gesture_Types idx, Elm_Gesture_State cb_type, Elm_Gesture_Event_Cb cb, void *data) EINA_ARG_NONNULL(1);
/**
* Call this function to get repeat-events settings.
*
* @param obj Pointer to gesture-layer.
*
* @return repeat events settings.
* @see elm_gesture_layer_hold_events_set()
* @ingroup Elm_Gesture_Layer
*/
EAPI Eina_Bool elm_gesture_layer_hold_events_get(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* This function called in order to make gesture-layer repeat events.
* Set this of you like to get the raw events only if gestures were not detected.
* Clear this if you like gesture layer to fwd events as testing gestures.
*
* @param obj Pointer to gesture-layer.
* @param r Repeat: TRUE/FALSE
*
* @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool r) EINA_ARG_NONNULL(1);
/**
* This function sets step-value for zoom action.
* Set step to any positive value.
* Cancel step setting by setting to 0.0
*
* @param obj Pointer to gesture-layer.
* @param s new zoom step value.
*
* @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_zoom_step_set(Evas_Object *obj, double s) EINA_ARG_NONNULL(1);
/**
* This function sets step-value for rotate action.
* Set step to any positive value.
* Cancel step setting by setting to 0.0
*
* @param obj Pointer to gesture-layer.
* @param s new roatate step value.
*
* @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_rotate_step_set(Evas_Object *obj, double s) EINA_ARG_NONNULL(1);
/**
* This function called to attach gesture-layer to an Evas_Object.
* @param obj Pointer to gesture-layer.
* @param t Pointer to underlying object (AKA Target)
*
* @return TRUE, FALSE on success, failure.
*
* @ingroup Elm_Gesture_Layer
*/
EAPI Eina_Bool elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *t) EINA_ARG_NONNULL(1, 2);
/**
* Call this function to construct a new gesture-layer object.
* This does not activate the gesture layer. You have to
* call elm_gesture_layer_attach in order to 'activate' gesture-layer.
*
* @param parent the parent object.
*
* @return Pointer to new gesture-layer object.
*
* @ingroup Elm_Gesture_Layer
*/
EAPI Evas_Object *elm_gesture_layer_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
/* thumb */
typedef enum _Elm_Thumb_Animation_Setting
{

View File

@ -72,6 +72,7 @@ elm_frame.c \
elm_gengrid.c \
elm_genlist.c \
elm_genscroller.c \
elm_gesture_layer.c \
elm_glview.c \
elm_grid.c \
elm_hover.c \

File diff suppressed because it is too large Load Diff