From a6f207eac2d816e21b139e24c81a69019fe09b7c Mon Sep 17 00:00:00 2001 From: Rajeev Ranjan Date: Tue, 7 Dec 2010 18:05:34 +0530 Subject: [PATCH] [src/lib/elm_imageslider.c] Code cleanup --- src/lib/elm_imageslider.c | 862 ++++++++++++++++++++-------------------------- 1 file changed, 366 insertions(+), 496 deletions(-) diff --git a/src/lib/elm_imageslider.c b/src/lib/elm_imageslider.c index 4bed454..ef97ddb 100644 --- a/src/lib/elm_imageslider.c +++ b/src/lib/elm_imageslider.c @@ -17,21 +17,21 @@ typedef struct _Widget_Data Widget_Data; -#define ANI_STEP (14 * elm_scale_get()) -#define ANI_TIME (0.005) -#define ANI_TIME_MSEC (12) -#define CLICK_TIME_MAX (180) -#define CLICK_WIDTH_MIN (elm_finger_size_get() >> 1) -#define FLICK_TIME_MAX (200) -#define FLICK_WIDTH_MIN (elm_finger_size_get() >> 2) -#define MOVE_STEP (3) -#define STEP_WEIGHT_DEF (1) -#define STEP_WEIGHT_MAX (2) -#define STEP_WEIGHT_MIN (0) -#define MOVING_IMAGE_SIZE (128) -#define MAX_ZOOM_SIZE (6) -#define INTERVAL_WIDTH (15) -#define MULTITOUCHDEVICE (11) +#define ANI_STEP (14 * elm_scale_get()) +#define ANI_TIME (0.005) +#define ANI_TIME_MSEC (12) +#define CLICK_TIME_MAX (180) +#define CLICK_WIDTH_MIN (elm_finger_size_get() >> 1) +#define FLICK_TIME_MAX (200) +#define FLICK_WIDTH_MIN (elm_finger_size_get() >> 2) +#define MOVE_STEP (3) +#define STEP_WEIGHT_DEF (1) +#define STEP_WEIGHT_MAX (2) +#define STEP_WEIGHT_MIN (0) +#define MOVING_IMAGE_SIZE (128) +#define MAX_ZOOM_SIZE (6) +#define INTERVAL_WIDTH (15) +#define MULTITOUCHDEVICE (11) // Enumeration for layout. enum @@ -85,12 +85,12 @@ struct _Widget_Data int ratio; }; -// Global value definition. +// Global value declaration. static const char *widtype = NULL; static const char SIG_CLICKED[] = "clicked"; -// Internal function definition. +// Internal function declaration. static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); @@ -99,21 +99,14 @@ static void _sizing_eval(Evas_Object *obj); static void _imageslider_del_all(Widget_Data * wd); -static void _imageslider_move(void *data, Evas * e, Evas_Object *obj, - void *event_info); -static void _imageslider_resize(void *data, Evas * e, Evas_Object *obj, - void *event_info); -static void _imageslider_show(void *data, Evas * e, Evas_Object *obj, - void *event_info); -static void _imageslider_hide(void *data, Evas * e, Evas_Object *obj, - void *event_info); +static void _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info); +static void _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info); +static void _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info); +static void _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info); static void _imageslider_update(Widget_Data * wd); -static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, - Evas_Coord y, Evas_Coord w); -static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, - Evas_Coord my, Evas_Coord y, - Evas_Coord w); +static void _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w); +static void _imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w); static Evas_Object *_imageslider_add_obj(Widget_Data * wd); static void _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left); @@ -131,12 +124,9 @@ static void _anim(Widget_Data * wd); static Eina_Bool _timer_cb(void *data); //static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source); -static void ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, - void *event_info); -static void ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, - void *event_info); -static void ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, - void *event_info); +static void ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info); +static void ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info); +static void ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info); // Whenever the Image Slider item is deleted, Call this funtion. static void @@ -153,25 +143,25 @@ _del_hook(Evas_Object *obj) for (i = 0; i < BLOCK_MAX; i++) { - evas_object_del(wd->ly[i]); + evas_object_del(wd->ly[i]); } if (wd->its) { - eina_list_free(wd->its); - wd->its = NULL; + eina_list_free(wd->its); + wd->its = NULL; } if (wd->queue_idler) { - ecore_idler_del(wd->queue_idler); - wd->queue_idler = NULL; + ecore_idler_del(wd->queue_idler); + wd->queue_idler = NULL; } if (wd->anim_timer) { - ecore_timer_del(wd->anim_timer); - wd->anim_timer = NULL; + ecore_timer_del(wd->anim_timer); + wd->anim_timer = NULL; } if (wd) @@ -190,16 +180,14 @@ _theme_hook(Evas_Object *obj) wd = elm_widget_data_get(obj); if (!wd || !wd->ly) - { - return; - } + return; for (i = 0; i < BLOCK_MAX; i++) { - wd->ly[i] = elm_layout_add(obj); - _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default"); - elm_widget_resize_object_set(obj, wd->ly[i]); - evas_object_show(wd->ly[i]); + wd->ly[i] = elm_layout_add(obj); + _elm_theme_object_set(obj, wd->ly[i], "imageslider", "base", "default"); + elm_widget_resize_object_set(obj, wd->ly[i]); + evas_object_show(wd->ly[i]); } _sizing_eval(obj); @@ -214,9 +202,7 @@ _sizing_eval(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); if (!wd) - { - return; - } + return; e = evas_object_evas_get(wd->obj); @@ -234,15 +220,11 @@ _imageslider_move(void *data, Evas * e, Evas_Object *obj, void *event_info) Evas_Coord x, y; if (!data) - { - return; - } + return; wd = elm_widget_data_get((Evas_Object *) data); if (!wd) - { - return; - } + return; evas_object_geometry_get(obj, &x, &y, NULL, NULL); wd->x = x; @@ -264,15 +246,11 @@ _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info) Evas_Coord w, h; if (!data) - { - return; - } + return; wd = elm_widget_data_get((Evas_Object *) data); if (!wd || !wd->ly) - { - return; - } + return; evas_object_geometry_get(obj, NULL, NULL, &w, &h); fprintf(stderr, "%d %d -resize\n", w, h); @@ -281,7 +259,7 @@ _imageslider_resize(void *data, Evas * e, Evas_Object *obj, void *event_info) for (i = 0; i < BLOCK_MAX; i++) { - evas_object_resize(wd->ly[i], w, h); + evas_object_resize(wd->ly[i], w, h); } evas_object_resize(wd->clip, w, h); @@ -298,14 +276,11 @@ _imageslider_show(void *data, Evas * e, Evas_Object *obj, void *event_info) if (!data) { - return; + return; } wd = elm_widget_data_get((Evas_Object *) data); - if (!wd) - { - return; - } + if (!wd) return; evas_object_show(wd->clip); } @@ -316,16 +291,10 @@ _imageslider_hide(void *data, Evas * e, Evas_Object *obj, void *event_info) { Widget_Data *wd; - if (!data) - { - return; - } + if (!data) return; wd = elm_widget_data_get((Evas_Object *) data); - if (!wd) - { - return; - } + if (!wd) return; evas_object_hide(wd->clip); } @@ -336,21 +305,17 @@ _imageslider_del_all(Widget_Data * wd) int i; - if (!wd) - { - return; - } + if (!wd) return; for (i = 0; i < BLOCK_MAX; i++) { - evas_object_del(wd->ly[i]); + evas_object_del(wd->ly[i]); } } // Update Image Slider item position. static void -_imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, - Evas_Coord w) +_imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, Evas_Coord w) { evas_object_move(wd->ly[BLOCK_LEFT], x - (w + INTERVAL_WIDTH), y); evas_object_move(wd->ly[BLOCK_CENTER], x, y); @@ -360,24 +325,20 @@ _imageslider_update_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord y, // Update the center position of Image Slider item. static void -_imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, - Evas_Coord y, Evas_Coord w) +_imageslider_update_center_pos(Widget_Data * wd, Evas_Coord x, Evas_Coord my, Evas_Coord y, Evas_Coord w) { Evas_Object *eo; Evas_Coord ix, iy, iw, ih; - eo = - edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "swl.photo"); + eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo"); evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); if ((ix > 0) || (ix + iw < wd->w)) { - edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "block.on", "block"); - _imageslider_update_pos(wd, x, y, w); - wd->on_zoom = EINA_FALSE; + edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block"); + _imageslider_update_pos(wd, x, y, w); + wd->on_zoom = EINA_FALSE; } } @@ -393,12 +354,9 @@ _imageslider_add_obj(Widget_Data * wd) //evas_object_smart_member_add(eo, wd->obj); //edje_object_signal_callback_add(elm_layout_edje_get(eo), "elm,photo,clicked", "", _signal_clicked, wd->obj); - evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, - ev_imageslider_down_cb, wd); - evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, - ev_imageslider_up_cb, wd); - evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, - ev_imageslider_move_cb, wd); + evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd); + evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd); + evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd); evas_object_resize(eo, wd->w, wd->h); evas_object_move(eo, wd->w + INTERVAL_WIDTH, wd->y); evas_object_clip_set(eo, wd->clip); @@ -413,27 +371,27 @@ _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left) { if (!left) { - if (wd->ly[BLOCK_LEFT]) - { - evas_object_del(wd->ly[BLOCK_LEFT]); - wd->ly[BLOCK_LEFT] = NULL; - } - - wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER]; - wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_RIGHT]; - wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd); + if (wd->ly[BLOCK_LEFT]) + { + evas_object_del(wd->ly[BLOCK_LEFT]); + wd->ly[BLOCK_LEFT] = NULL; + } + + wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER]; + wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_RIGHT]; + wd->ly[BLOCK_RIGHT] = _imageslider_add_obj(wd); } else { - if (wd->ly[BLOCK_RIGHT]) - { - evas_object_del(wd->ly[BLOCK_RIGHT]); - wd->ly[BLOCK_RIGHT] = NULL; - } - - wd->ly[BLOCK_RIGHT] = wd->ly[BLOCK_CENTER]; - wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_LEFT]; - wd->ly[BLOCK_LEFT] = _imageslider_add_obj(wd); + if (wd->ly[BLOCK_RIGHT]) + { + evas_object_del(wd->ly[BLOCK_RIGHT]); + wd->ly[BLOCK_RIGHT] = NULL; + } + + wd->ly[BLOCK_RIGHT] = wd->ly[BLOCK_CENTER]; + wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_LEFT]; + wd->ly[BLOCK_LEFT] = _imageslider_add_obj(wd); } } @@ -443,43 +401,43 @@ _imageslider_obj_move(Widget_Data * wd, Evas_Coord step) { if (step > 0) { - wd->cur = eina_list_next(wd->cur); - if (wd->cur == NULL) - { - wd->cur = eina_list_last(wd->its); - wd->step = ANI_STEP; - } - else - { - wd->step = -ANI_STEP; - wd->move_x += wd->w; - _imageslider_obj_shift(wd, 0); - } - wd->moving = 1; + wd->cur = eina_list_next(wd->cur); + if (wd->cur == NULL) + { + wd->cur = eina_list_last(wd->its); + wd->step = ANI_STEP; + } + else + { + wd->step = -ANI_STEP; + wd->move_x += wd->w; + _imageslider_obj_shift(wd, 0); + } + wd->moving = 1; } else if (step < 0) { - wd->cur = eina_list_prev(wd->cur); - if (wd->cur == NULL) - { - wd->cur = wd->its; - wd->step = -ANI_STEP; - } - else - { - wd->step = ANI_STEP; - wd->move_x -= wd->w; - _imageslider_obj_shift(wd, 1); - } - wd->moving = 1; + wd->cur = eina_list_prev(wd->cur); + if (wd->cur == NULL) + { + wd->cur = wd->its; + wd->step = -ANI_STEP; + } + else + { + wd->step = ANI_STEP; + wd->move_x -= wd->w; + _imageslider_obj_shift(wd, 1); + } + wd->moving = 1; } else { - if (wd->move_x < 0) - wd->step = ANI_STEP; - else - wd->step = -ANI_STEP; - wd->moving = 0; + if (wd->move_x < 0) + wd->step = ANI_STEP; + else + wd->step = -ANI_STEP; + wd->moving = 0; } _imageslider_update(wd); @@ -487,8 +445,7 @@ _imageslider_obj_move(Widget_Data * wd, Evas_Coord step) // Whenever MOUSE DOWN event occurs, Call this function. static void -ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, - void *event_info) +ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, void *event_info) { Widget_Data *wd = data; @@ -519,9 +476,8 @@ ev_imageslider_down_cb(void *data, Evas * e, Evas_Object *obj, if (iw != wd->w) { - wd->on_zoom = EINA_TRUE; - edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block"); -// edje_thaw(); + wd->on_zoom = EINA_TRUE; + edje_object_signal_emit(elm_layout_edje_get(obj), "block.off", "block"); } } @@ -547,69 +503,63 @@ ev_imageslider_up_cb(void *data, Evas * e, Evas_Object *obj, void *event_info) } else { - step = wd->down_pos.x - ev->canvas.x; - interval = ev->timestamp - wd->timestamp; - if (step == 0 || interval == 0) - { - fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n"); - evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL); - return; - } - if (interval < CLICK_TIME_MAX) - { - if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN) - { - fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n"); - evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL); - return; - } - } - - if (interval < FLICK_TIME_MAX) - { - - if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN) - { - fprintf(stderr, - "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (1)\n"); - - _imageslider_obj_move(wd, 0); - } - else - { - fprintf(stderr, - "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (2)\n"); - - _imageslider_obj_move(wd, step); - } - - } - else - { - step = (wd->x - wd->move_x) << 1; - if (step <= wd->w && step >= -(wd->w)) - { - fprintf(stderr, - "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (1)\n"); - - _imageslider_obj_move(wd, 0); - } - else - { - fprintf(stderr, - "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (2)\n"); - - _imageslider_obj_move(wd, step); - } - } + step = wd->down_pos.x - ev->canvas.x; + interval = ev->timestamp - wd->timestamp; + if (step == 0 || interval == 0) + { + fprintf(stderr, "[[[ DEBUG ]]]: case1: emit CLICK event\n"); + evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL); + return; + } + if (interval < CLICK_TIME_MAX) + { + if (step < CLICK_WIDTH_MIN && step > CLICK_WIDTH_MIN) + { + fprintf(stderr, "[[[ DEBUG ]]]: case2: emit CLICK event\n"); + evas_object_smart_callback_call(wd->obj, SIG_CLICKED, NULL); + return; + } + } + + if (interval < FLICK_TIME_MAX) + { + if (step < FLICK_WIDTH_MIN && step > FLICK_WIDTH_MIN) + { + fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (1)\n"); + + _imageslider_obj_move(wd, 0); + } + else + { + fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-black zone (2)\n"); + + _imageslider_obj_move(wd, step); + } + + } + else + { + step = (wd->x - wd->move_x) << 1; + if (step <= wd->w && step >= -(wd->w)) + { + fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (1)\n"); + + _imageslider_obj_move(wd, 0); + } + else + { + fprintf(stderr, "[[[ DEBUG ]]]:ev_imageslider_up_cb-white zone (2)\n"); + + _imageslider_obj_move(wd, step); + } + } } } // Whenever MOUSE MOVE event occurs, Call this API. static void -ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, - void *event_info) +ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void *event_info) { int idx; @@ -628,65 +578,53 @@ ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, if (wd->move_cnt == MOVE_STEP) { - if (wd->on_hold == EINA_FALSE) - { - wd->move_cnt = 0; - - if (ev->buttons) - { - step = ev->cur.canvas.x - wd->down_pos.x; - if (step > 0) - idx = BLOCK_LEFT; - else - idx = BLOCK_RIGHT; - - wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x)); - wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y)); - - if (wd->on_zoom) - { - _imageslider_update_center_pos(wd, wd->move_x, - wd->move_y, wd->y, wd->w); - } - else - { - _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w); - } - } - } - else - { - wd->mx = ev->cur.canvas.x; - wd->my = ev->cur.canvas.y; - - wd->ratio = - sqrt((wd->mx - wd->mmx) * (wd->mx - wd->mmx) + - (wd->my - wd->mmy) * (wd->my - wd->mmy)); - - eo = - edje_object_part_swallow_get(elm_layout_edje_get(obj), - "swl.photo"); - if (eo) - { - it = eina_list_data_get(wd->cur); - if (((it->w * wd->ratio / wd->dratio) / it->ow) < - MAX_ZOOM_SIZE) - { - edje_object_part_unswallow(elm_layout_edje_get(obj), eo); - evas_object_resize(eo, it->w * wd->ratio / wd->dratio, - it->h * wd->ratio / wd->dratio); - evas_object_size_hint_min_set(eo, - it->w * wd->ratio / - wd->dratio, - it->h * wd->ratio / - wd->dratio); - edje_object_part_swallow(elm_layout_edje_get(obj), - "swl.photo", eo); - } - } - } + if (wd->on_hold == EINA_FALSE) + { + wd->move_cnt = 0; + + if (ev->buttons) + { + step = ev->cur.canvas.x - wd->down_pos.x; + if (step > 0) + idx = BLOCK_LEFT; + else + idx = BLOCK_RIGHT; + + wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x)); + wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y)); + + if (wd->on_zoom) + { + _imageslider_update_center_pos(wd, wd->move_x, wd->move_y, wd->y, wd->w); + } + else + { + _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w); + } + } + } + else + { + wd->mx = ev->cur.canvas.x; + wd->my = ev->cur.canvas.y; + + wd->ratio = + sqrt((wd->mx - wd->mmx) * (wd->mx - wd->mmx) + (wd->my - wd->mmy) * (wd->my - wd->mmy)); + + eo = edje_object_part_swallow_get(elm_layout_edje_get(obj), "swl.photo"); + if (eo) + { + it = eina_list_data_get(wd->cur); + if (((it->w * wd->ratio / wd->dratio) / it->ow) < MAX_ZOOM_SIZE) + { + edje_object_part_unswallow(elm_layout_edje_get(obj), eo); + evas_object_resize(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio); + evas_object_size_hint_min_set(eo, it->w * wd->ratio / wd->dratio, it->h * wd->ratio / wd->dratio); + edje_object_part_swallow(elm_layout_edje_get(obj), "swl.photo", eo); + } + } + } } - wd->move_cnt++; } @@ -696,11 +634,9 @@ ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, // But, DONOT emit CLICK event. // DO NOT use this callback function. Remove later. static void -_signal_clicked(void *data, Evas_Object *obj, const char *emission, - const char *source) +_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) { - fprintf(stderr, - "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n"); + fprintf(stderr, "[[[ DEBUG ]]]: Call the callback function about Click event!, But DONOT emit CLICK event in the callback function!\n"); } #endif @@ -727,8 +663,8 @@ _icon_to_image(void *data) if (wd->queue_idler) { - ecore_idler_del(wd->queue_idler); - wd->queue_idler = NULL; + ecore_idler_del(wd->queue_idler); + wd->queue_idler = NULL; } return ECORE_CALLBACK_CANCEL; } @@ -754,28 +690,22 @@ _check_drag(int state, void *data) it = eina_list_data_get(l[state]); - eo = - edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), - "swl.photo"); + eo = edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[state]), "swl.photo"); if (eo) - evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); - evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); - edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), - "swl.photo", &dx, &dy); + evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); + edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy); if ((iw != wd->w) || ((dx != 0) || (dy != 0))) { - if (wd->ly[state]) - { - evas_object_del(wd->ly[state]); - wd->ly[state] = NULL; - } - wd->ly[state] = _imageslider_add_obj(wd); + if (wd->ly[state]) + { + evas_object_del(wd->ly[state]); + wd->ly[state] = NULL; + } + wd->ly[state] = _imageslider_add_obj(wd); } else - { - return 1; - } + return 1; return 0; } @@ -796,27 +726,21 @@ _check_zoom(void *data) it = eina_list_data_get(wd->cur); eo = - edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "swl.photo"); + edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo"); if (eo) evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); evas_object_geometry_get(eo, &ix, &iy, &iw, &ih); - edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "swl.photo", &dx, &dy); + edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "swl.photo", &dx, &dy); if ((iw != wd->w) || ((dx != 0) || (dy != 0))) { - wd->on_zoom = EINA_TRUE; - edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "block.off", "block"); -// edje_thaw(); + wd->on_zoom = EINA_TRUE; + edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.off", "block"); } else { - wd->on_zoom = EINA_FALSE; - edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), - "block.on", "block"); -// edje_freeze(); + wd->on_zoom = EINA_FALSE; + edje_object_signal_emit(elm_layout_edje_get(wd->ly[BLOCK_CENTER]), "block.on", "block"); } } @@ -839,54 +763,53 @@ _timer_cb(void *data) gettimeofday(&tv, NULL); - t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - - wd->tv.tv_usec) / 1000; + t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000; gettimeofday(&wd->tv, NULL); t = t / ANI_TIME_MSEC; if (t <= STEP_WEIGHT_MIN) - t = STEP_WEIGHT_DEF; + t = STEP_WEIGHT_DEF; else if (t > STEP_WEIGHT_MAX) - t = STEP_WEIGHT_MAX; + t = STEP_WEIGHT_MAX; wd->move_x += (wd->step) * t; if (wd->step < 0 && wd->move_x < wd->x) - wd->move_x = wd->x; + wd->move_x = wd->x; else if (wd->step > 0 && wd->move_x > wd->x) - wd->move_x = wd->x; + wd->move_x = wd->x; _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w); if (wd->move_x == wd->x) { - wd->ani_lock = 0; - if (wd->cur) - { - it = eina_list_data_get(wd->cur); - if (it->func) - it->func(it->data, wd->obj, it); - } - if (wd->cur) - { - it = eina_list_data_get(wd->cur); - evas_object_smart_callback_call(wd->obj, "changed", it); - } - - ret = _check_drag(BLOCK_LEFT, wd); - ret = _check_drag(BLOCK_RIGHT, wd); - _check_zoom(wd); - - if (!wd->queue_idler) - wd->queue_idler = ecore_idler_add(_icon_to_image, wd); - - if (wd->anim_timer) - { - ecore_timer_del(wd->anim_timer); - wd->anim_timer = NULL; - } - - return ECORE_CALLBACK_CANCEL; + wd->ani_lock = 0; + if (wd->cur) + { + it = eina_list_data_get(wd->cur); + if (it->func) + it->func(it->data, wd->obj, it); + } + if (wd->cur) + { + it = eina_list_data_get(wd->cur); + evas_object_smart_callback_call(wd->obj, "changed", it); + } + + ret = _check_drag(BLOCK_LEFT, wd); + ret = _check_drag(BLOCK_RIGHT, wd); + _check_zoom(wd); + + if (!wd->queue_idler) + wd->queue_idler = ecore_idler_add(_icon_to_image, wd); + + if (wd->anim_timer) + { + ecore_timer_del(wd->anim_timer); + wd->anim_timer = NULL; + } + + return ECORE_CALLBACK_CANCEL; } return ECORE_CALLBACK_RENEW; @@ -899,8 +822,8 @@ _anim(Widget_Data * wd) if (wd->x == wd->move_x) { - _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w); - return; + _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w); + return; } wd->ani_lock = 1; @@ -909,9 +832,7 @@ _anim(Widget_Data * wd) gettimeofday(&wd->tv, NULL); if (!wd->anim_timer) - { - wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd); - } + wd->anim_timer = ecore_timer_add(ANI_TIME, _timer_cb, wd); } // Update Image Slider Items. @@ -927,14 +848,12 @@ _imageslider_update(Widget_Data * wd) Evas_Object *eo; if (!wd) - { - return; - } + return; if (!wd->cur) { - _imageslider_del_all(wd); - return; + _imageslider_del_all(wd); + return; } l[BLOCK_LEFT] = eina_list_prev(wd->cur); @@ -943,51 +862,46 @@ _imageslider_update(Widget_Data * wd) for (i = 0; i < BLOCK_MAX; i++) { - eo = - edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), - "swl.photo"); - if (!l[i]) - { - elm_layout_content_set(wd->ly[i], "swl.photo", NULL); - evas_object_del(eo); - } - else - { - it = eina_list_data_get(l[i]); - if (!it) - return; - - if (!eo) - { - eo = elm_image_add(wd->obj); - elm_layout_content_set(wd->ly[i], "swl.photo", eo); - elm_image_prescale_set(eo, wd->w); - elm_image_file_set(eo, it->photo_file, NULL); - elm_image_object_size_get(eo, &it->w, &it->h); - evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, - &it->oh); - it->ow = it->w; - it->oh = it->h; - } - - if (wd->moving != it->moving) - { - it->moving = wd->moving; - if (wd->moving) - { - elm_image_prescale_set(eo, MOVING_IMAGE_SIZE); - } - else - { - elm_image_prescale_set(eo, - it->w > it->h ? it->w : it->h); - } - } - } + eo = + edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo"); + if (!l[i]) + { + elm_layout_content_set(wd->ly[i], "swl.photo", NULL); + evas_object_del(eo); + } + else + { + it = eina_list_data_get(l[i]); + if (!it) + return; + + if (!eo) + { + eo = elm_image_add(wd->obj); + elm_layout_content_set(wd->ly[i], "swl.photo", eo); elm_image_prescale_set(eo, wd->w); + elm_image_file_set(eo, it->photo_file, NULL); + elm_image_object_size_get(eo, &it->w, &it->h); + evas_object_geometry_get(eo, &it->ox, &it->oy, &it->ow, &it->oh); + it->ow = it->w; + it->oh = it->h; + } + + if (wd->moving != it->moving) + { + it->moving = wd->moving; + if (wd->moving) + { + elm_image_prescale_set(eo, MOVING_IMAGE_SIZE); + } + else + { + elm_image_prescale_set(eo, it->w > it->h ? it->w : it->h); + } + } + } } _anim(wd); - } /** @@ -1010,23 +924,18 @@ elm_imageslider_add(Evas_Object *parent) Evas *e; if (!parent) - { - return NULL; - } + return NULL; wd = ELM_NEW(Widget_Data); e = evas_object_evas_get(parent); if (e == NULL) - { - return NULL; - } + return NULL; obj = elm_widget_add(e); ELM_SET_WIDTYPE(widtype, "imageslider"); elm_widget_type_set(obj, "imageslider"); elm_widget_sub_object_add(parent, obj); elm_widget_data_set(obj, wd); - //wd->parent = parent; elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); @@ -1034,32 +943,25 @@ elm_imageslider_add(Evas_Object *parent) for (i = 0; i < BLOCK_MAX; i++) { - wd->ly[i] = elm_layout_add(obj); - elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default"); - elm_widget_resize_object_set(obj, wd->ly[i]); - evas_object_smart_member_add(wd->ly[i], obj); - - //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj); - evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, - ev_imageslider_down_cb, wd); - evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, - ev_imageslider_up_cb, wd); - evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, - ev_imageslider_move_cb, wd); - evas_object_clip_set(wd->ly[i], wd->clip); - evas_object_show(wd->ly[i]); + wd->ly[i] = elm_layout_add(obj); + elm_layout_theme_set(wd->ly[i], "imageslider", "base", "default"); + elm_widget_resize_object_set(obj, wd->ly[i]); + evas_object_smart_member_add(wd->ly[i], obj); + + //edje_object_signal_callback_add(elm_layout_edje_get(wd->ly[i]), "elm,photo,clicked", "", _signal_clicked, obj); + evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_DOWN, ev_imageslider_down_cb, wd); + evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_UP, ev_imageslider_up_cb, wd); + evas_object_event_callback_add(wd->ly[i], EVAS_CALLBACK_MOUSE_MOVE, ev_imageslider_move_cb, wd); + evas_object_clip_set(wd->ly[i], wd->clip); + evas_object_show(wd->ly[i]); } wd->obj = obj; - evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, - _imageslider_resize, obj); - evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, - obj); - evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, - obj); - evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, - obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj); _sizing_eval(obj); @@ -1078,8 +980,7 @@ elm_imageslider_add(Evas_Object *parent) * @ingroup Imageslider */ EAPI Elm_Imageslider_Item * -elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, - Elm_Imageslider_Cb func, void *data) +elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd; @@ -1087,9 +988,7 @@ elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Item *it; if (!obj || !(wd = elm_widget_data_get(obj))) - { - return NULL; - } + return NULL; it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item)); if (!it) @@ -1121,22 +1020,17 @@ elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, * @ingroup Imageslider */ EAPI Elm_Imageslider_Item * -elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, - Elm_Imageslider_Cb func, - unsigned int index, void *data) +elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd; Elm_Imageslider_Item *it; - fprintf(stderr, - "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n"); + fprintf(stderr, "[[[ DEBUG ]]]:: New elm_imageslider_item_append_relative()\n"); if (!obj || !(wd = elm_widget_data_get(obj))) - { - return NULL; - } + return NULL; it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item)); if (!it) @@ -1170,8 +1064,7 @@ elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, * @ingroup Imageslider */ EAPI Elm_Imageslider_Item * -elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, - Elm_Imageslider_Cb func, void *data) +elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd; @@ -1179,9 +1072,7 @@ elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Item *it; if (!obj || !(wd = elm_widget_data_get(obj))) - { - return NULL; - } + return NULL; it = (Elm_Imageslider_Item *) calloc(1, sizeof(Elm_Imageslider_Item)); it->photo_file = eina_stringshare_add(photo_file); @@ -1215,21 +1106,19 @@ elm_imageslider_item_del(Elm_Imageslider_Item * it) Eina_List *l; if (!it || !(wd = elm_widget_data_get(it->obj))) - { - return; - } + return; EINA_LIST_FOREACH(wd->its, l, _it) { if (_it == it) - { - if (l == wd->cur) - wd->cur = eina_list_prev(wd->cur); - wd->its = eina_list_remove(wd->its, it); - if (!wd->cur) - wd->cur = wd->its; - break; - } + { + if (l == wd->cur) + wd->cur = eina_list_prev(wd->cur); + wd->its = eina_list_remove(wd->its, it); + if (!wd->cur) + wd->cur = wd->its; + break; + } } _imageslider_update(wd); @@ -1251,9 +1140,7 @@ elm_imageslider_selected_item_get(Evas_Object *obj) Widget_Data *wd; if (!obj || (!(wd = elm_widget_data_get(obj)))) - { - return NULL; - } + return NULL; if (!wd->cur) return NULL; @@ -1275,9 +1162,7 @@ elm_imageslider_item_selected_get(Elm_Imageslider_Item * it) Widget_Data *wd; if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) - { - return EINA_FALSE; - } + return EINA_FALSE; if (!wd->cur) return EINA_FALSE; @@ -1310,28 +1195,23 @@ elm_imageslider_item_selected_set(Elm_Imageslider_Item * it) Evas_Object *eo; if (!it || !it->obj || (!(wd = elm_widget_data_get(it->obj)))) - { - return; - } + return; EINA_LIST_FOREACH(wd->its, l, _it) { if (_it == it) - { - wd->cur = l; - } + wd->cur = l; } for (i = 0; i < BLOCK_MAX; i++) { - eo = - edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), - "swl.photo"); - if (eo) - { - elm_layout_content_set(wd->ly[i], "swl.photo", NULL); - evas_object_del(eo); - } + eo = + edje_object_part_swallow_get(elm_layout_edje_get(wd->ly[i]), "swl.photo"); + if (eo) + { + elm_layout_content_set(wd->ly[i], "swl.photo", NULL); + evas_object_del(eo); + } } _imageslider_update(wd); @@ -1350,9 +1230,7 @@ EAPI const char * elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it) { if (!it) - { - return NULL; - } + return NULL; return it->photo_file; } @@ -1375,19 +1253,17 @@ elm_imageslider_item_prev(Elm_Imageslider_Item * it) Eina_List *l; if (!it || (!(wd = elm_widget_data_get(it->obj)))) - { - return NULL; - } + return NULL; EINA_LIST_FOREACH(wd->its, l, _it) { if (_it == it) - { - l = eina_list_prev(l); - if (!l) - break; - return eina_list_data_get(l); - } + { + l = eina_list_prev(l); + if (!l) + break; + return eina_list_data_get(l); + } } return NULL; @@ -1411,19 +1287,17 @@ elm_imageslider_item_next(Elm_Imageslider_Item * it) Eina_List *l; if (!it || (!(wd = elm_widget_data_get(it->obj)))) - { - return NULL; - } + return NULL; EINA_LIST_FOREACH(wd->its, l, _it) { if (_it == it) - { - l = eina_list_next(l); - if (!l) - break; - return eina_list_data_get(l); - } + { + l = eina_list_next(l); + if (!l) + break; + return eina_list_data_get(l); + } } return NULL; @@ -1443,12 +1317,10 @@ elm_imageslider_prev(Evas_Object *obj) Widget_Data *wd; if (!obj || (!(wd = elm_widget_data_get(obj)))) - { - return; - } + return; if (wd->ani_lock) - return; + return; _imageslider_obj_move(wd, -1); } @@ -1467,12 +1339,10 @@ elm_imageslider_next(Evas_Object * obj) Widget_Data *wd; if (!obj || (!(wd = elm_widget_data_get(obj)))) - { - return; - } + return; if (wd->ani_lock) - return; + return; _imageslider_obj_move(wd, 1); -- 2.7.4