Languages

Menu
Sites
Language
How to add swipe gesture on image in tizen application?

I want to add swipe gesture to image for my application.

Responses

5 Replies
Yasin Ali

Hi,

Check out this link https://developer.tizen.org/dev-guide/2.4/org.tizen.ui.practices/html/native/efl/touch_gesture_n.htm

for Elm_Gesture_Momentum_Info data structure:

struct 
_Elm_Gesture_Momentum_Info // Report line ends, timestamps, and momentum computed        
{
   Evas_Coord x1; // Final-swipe direction with starting point on X
   Evas_Coord y1; // Final-swipe direction with starting point on Y
   Evas_Coord x2; // Final-swipe direction with ending point on X
   Evas_Coord y2; // Final-swipe direction with ending point on Y

   unsigned int tx; // Timestamp of the start of the final X swipe
   unsigned int ty; // Timestamp of the start of the final Y swipe

   Evas_Coord mx; // Momentum on X
   Evas_Coord my; // Momentum on Y

   unsigned int n; // Number of fingers
};

You may adapt or change as per your requirements.

Hope it'll work.

bhoomika rathod

Thank you. But I won't be able to change this cordinates. So, will you plz tell me how to apply this solution if you have any code?

Yasin Ali

Hi,

Share some of your code to test that you have tried.

bhoomika rathod

I have been added gesture layer,

Evas_Object *g = elm_gesture_layer_add(ad->win);
elm_gesture_layer_attach(g, ad->box);
elm_gesture_layer_cb_set(g, ELM_GESTURE_MOMENTUM,ELM_GESTURE_STATE_START, momentum_start, ad);
elm_gesture_layer_cb_set(g, ELM_GESTURE_MOMENTUM,ELM_GESTURE_STATE_END, momentum_end, ad);
elm_gesture_layer_cb_set(g, ELM_GESTURE_MOMENTUM,ELM_GESTURE_STATE_ABORT, momentum_abort, ad);
elm_gesture_layer_cb_set(g, ELM_GESTURE_MOMENTUM,ELM_GESTURE_STATE_MOVE, momentum_move, ad);

  I want to change image on swipe. You told me that i can change coordinates of momentum data structure. But i m not getting what to do in callback function and how to change coordinates.

Will you plz tell me how can i do that?

Yasin Ali
The momentum gesture is used for detecting any move events on the gesture layer and getting event information to make a meaningful gesture action.

After detecting appropriate momentum you need to change image in the callback function. Based on

momentum move you may change image. Summary:

1. Detect appropriate momentum

2. Change image accordingly

See example code:

static Evas_Event_Flags
momentum_move(void *data, void *event_info)
{
   Elm_Gesture_Momentum_Info *p = (Elm_Gesture_Momentum_Info *) event_info;
   printf("momentum move x1,y1=<%d,%d> x2,y2=<%d,%d> tx,ty=<%u,%u> mx=<%d> my=<%d> n=<%u>\n", 
          p->x1, p->y1, p->x2, p->y2, p->tx, p->ty, p->mx, p->my, p->n);

   return EVAS_EVENT_FLAG_ON_HOLD;
}

Hope it will help.