From 057d29dfcc04dcf712bb4f0d416a923715df52c3 Mon Sep 17 00:00:00 2001 From: sangho park Date: Thu, 28 Apr 2011 17:50:05 +0900 Subject: [PATCH] upstream merge Change-Id: I20ca8959b68d1487ec9210040f46c1a26461d603 --- src/bin/test_map.c | 22 ---- src/lib/Elementary.h.in | 2 + src/lib/elm_map.c | 263 +++++++++++++++++++++++++++++++++++++++++------- src/lib/els_scroller.c | 19 ++++ src/lib/els_scroller.h | 2 + 5 files changed, 247 insertions(+), 61 deletions(-) diff --git a/src/bin/test_map.c b/src/bin/test_map.c index 195e32e..b930d26 100644 --- a/src/bin/test_map.c +++ b/src/bin/test_map.c @@ -519,26 +519,6 @@ _group_icon_get(Evas_Object *obj, void *data) } static void -_map_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) -{ - Evas_Object *map = data; - Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info; - int zoom; - //unset the mouse wheel - ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; - - zoom = elm_map_zoom_get(map); - - if (ev->z > 0) - zoom--; - else - zoom++; - - elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_MANUAL); - if ((zoom >= 0) && (zoom <= 18)) elm_map_zoom_set(map, zoom); -} - -static void _map_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { int x,y,w,h; @@ -607,8 +587,6 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ evas_object_color_set(rect, 0, 0, 0, 0); evas_object_repeat_events_set(rect,1); evas_object_show(rect); - evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_WHEEL, - _map_mouse_wheel_cb, map); evas_object_raise(rect); evas_object_event_callback_add(map, EVAS_CALLBACK_RESIZE, diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 5cb6475..b9d29e7 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -2459,6 +2459,8 @@ extern "C" { EAPI void elm_map_name_remove(Elm_Map_Name *name) EINA_ARG_NONNULL(1); EAPI void elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy) EINA_ARG_NONNULL(1); EAPI void elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy) EINA_ARG_NONNULL(1, 2, 3, 4); + EAPI void elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_map_wheel_disabled_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /* smart callbacks called: * "clicked" - when image clicked diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c index 836b169..08461d6 100644 --- a/src/lib/elm_map.c +++ b/src/lib/elm_map.c @@ -426,6 +426,9 @@ struct _Widget_Data Evas_Coord cx, cy; double level; } pinch_zoom; + double wheel_zoom; + Ecore_Timer *wheel_timer; + Eina_Bool wheel_disabled : 1; }; struct _Mod_Api @@ -551,6 +554,7 @@ static const Evas_Smart_Cb_Description _signals[] = { static void _pan_calculate(Evas_Object *obj); static Eina_Bool _hold_timer_cb(void *data); +static Eina_Bool _wheel_timer_cb(void *data); static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); @@ -747,14 +751,14 @@ route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - Eina_List *lr, *lp, *ln; Route_Node *n; Evas_Object *p; Elm_Map_Route *r; int nodes; int x, y, rx, ry; + + if (!wd) return; Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize; EINA_LIST_FOREACH(wd->route, lr, r) @@ -811,8 +815,10 @@ route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, static void rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord ax, ay, gw, gh, hh, ww; + if (!wd) return; evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh); @@ -840,6 +846,7 @@ rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_C static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord ax, ay, gw, gh, tx, ty; Eina_List *l, *markers; @@ -987,12 +994,12 @@ marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord ax, ay, gw, gh, tx, ty; int xx, yy, ww, hh; if (!wd) return; - ax = 0; ay = 0; gw = wd->size.w; @@ -1043,6 +1050,7 @@ grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord o static void grid_clear(Evas_Object *obj, Grid *g) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); char buf[PATH_MAX]; @@ -1171,6 +1179,7 @@ grid_create(Evas_Object *obj) static void grid_load(Evas_Object *obj, Grid *g) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); int x, y; int size; @@ -1376,6 +1385,7 @@ grid_load(Evas_Object *obj, Grid *g) static void grid_clearall(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Grid *g; @@ -1390,6 +1400,7 @@ grid_clearall(Evas_Object *obj) static void _smooth_update(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Eina_List *l; Grid *g; @@ -1430,7 +1441,9 @@ _grid_raise(Grid *g) static Eina_Bool _scr_timeout(void *data) { + ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL; Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return ECORE_CALLBACK_CANCEL; wd->nosmooth--; if (!wd->nosmooth) _smooth_update(data); @@ -1441,7 +1454,9 @@ _scr_timeout(void *data) static void _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(data, widtype); Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; if (!wd->scr_timer) { @@ -1455,18 +1470,28 @@ _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) static void zoom_do(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord xx, yy, ow, oh; if (!wd) return; - wd->size.w = wd->size.nw; wd->size.h = wd->size.nh; elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh); - elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy); - xx -= ow / 2; - yy -= oh / 2; + + if (wd->center_on.enabled) + { + elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy); + xx -= ow / 2; + yy -= oh / 2; + } + else + { + xx = (wd->size.spos.x * wd->size.w) - (ow / 2); + yy = (wd->size.spos.y * wd->size.h) - (oh / 2); + } + if (xx < 0) xx = 0; else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow; @@ -1486,6 +1511,7 @@ zoom_do(Evas_Object *obj) static Eina_Bool _zoom_anim(void *data) { + ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL; Evas_Object *obj = data; Widget_Data *wd = elm_widget_data_get(obj); double t; @@ -1504,34 +1530,34 @@ _zoom_anim(void *data) if ((t >= 2.0) || (t <= 0.5)) { + wd->zoom_animator = NULL; wd->pinch.level = 1.0; zoom_do(obj); - wd->zoom_animator = NULL; evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL); return ECORE_CALLBACK_CANCEL; } - else + else if (t != 1.0) { Evas_Coord x, y, w, h; float half_w, half_h; - evas_object_geometry_get(data, &x, &y, &w, &h); half_w = (float)w * 0.5; half_h = (float)h * 0.5; - - wd->pinch.level = t; wd->pinch.cx = x + half_w; wd->pinch.cy = y + half_h; + wd->pinch.level = t; if (wd->calc_job) ecore_job_del(wd->calc_job); wd->calc_job = ecore_job_add(_calc_job, wd); - return ECORE_CALLBACK_RENEW; } + return ECORE_CALLBACK_RENEW; } static Eina_Bool _long_press(void *data) { + ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL; Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return ECORE_CALLBACK_CANCEL; wd->long_timer = NULL; evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev); @@ -1546,6 +1572,14 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf Evas_Event_Mouse_Down *ev = event_info; Event *ev0; + if (!wd) return; + if (ev->button == 2) + { + if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer); + wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data); + return; + } + ev0 = get_event_object(data, 0); if (ev0) return; ev0 = create_event_object(data, obj, 0); @@ -1555,7 +1589,6 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf ev0->prev.x = ev->output.x; ev0->prev.y = ev->output.y; - if (!wd) return; if (ev->button != 1) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE; else wd->on_hold = EINA_FALSE; @@ -1586,6 +1619,8 @@ _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void * { ELM_CHECK_WIDTYPE(data, widtype); Widget_Data *wd = elm_widget_data_get(data); + + if (!wd) return; Evas_Event_Mouse_Up *ev = event_info; int mdevice; Event *ev0; @@ -1614,7 +1649,6 @@ _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void * destroy_event_object(data, ev0); } - if (!wd) return; if (ev->button != 1) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE; else wd->on_hold = EINA_FALSE; @@ -1741,7 +1775,7 @@ _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Event *ev0; Event *ev; Eina_Bool tp; - double t = 0.0; + double t; wd->multi_count--; if (wd->calc_job) ecore_job_del(wd->calc_job); @@ -1780,6 +1814,40 @@ _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, destroy_event_object(data, ev); } +static void +_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + ELM_CHECK_WIDTYPE(data, widtype); + Widget_Data *wd = elm_widget_data_get(data); + Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info; + Evas_Coord x, y, w, h; + float half_w, half_h; + evas_object_geometry_get(data, &x, &y, &w, &h); + half_w = (float)w * 0.5; + half_h = (float)h * 0.5; + + if (!wd->wheel_zoom) wd->wheel_zoom = 1.0; + if (ev->z > 0) + { + wd->zoom_method = ZOOM_METHOD_OUT; + wd->wheel_zoom -= 0.1; + if (wd->wheel_zoom <= PINCH_ZOOM_MIN) wd->wheel_zoom = PINCH_ZOOM_MIN; + } + else + { + wd->zoom_method = ZOOM_METHOD_IN; + wd->wheel_zoom += 0.1; + if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX; + } + + wd->pinch.level = wd->wheel_zoom; + wd->pinch.cx = x + half_w; + wd->pinch.cy = y + half_h; + if (wd->calc_job) ecore_job_del(wd->calc_job); + wd->calc_job = ecore_job_add(_calc_job, wd); +} + + static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL; static Eina_Bool @@ -1791,9 +1859,26 @@ _hold_timer_cb(void *data) return ECORE_CALLBACK_CANCEL; } +static Eina_Bool +_wheel_timer_cb(void *data) +{ + ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL; + Widget_Data *wd = elm_widget_data_get(data); + int zoom; + + wd->wheel_timer = NULL; + if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom - 1.0); + else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor((-1.0 / wd->wheel_zoom) + 1.0); + else return ECORE_CALLBACK_CANCEL; + elm_map_zoom_set(data, wd->zoom + zoom); + wd->wheel_zoom = 0.0; + return ECORE_CALLBACK_CANCEL; +} + static void _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(data, widtype); Widget_Data *wd = elm_widget_data_get(data); int x, y, w, h; @@ -1806,9 +1891,10 @@ _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, static void _del_hook(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); Elm_Map_Group_Class *group_clas; Elm_Map_Marker_Class *marker_clas; - Widget_Data *wd = elm_widget_data_get(obj); Eina_List *l; Event *ev; Evas_Object *p; @@ -1819,7 +1905,6 @@ _del_hook(Evas_Object *obj) Elm_Map_Name *na; if (!wd) return; - EINA_LIST_FREE(wd->groups_clas, group_clas) { if (group_clas->style) @@ -1898,15 +1983,16 @@ _del_hook(Evas_Object *obj) static void _del_pre_hook(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); Marker_Group *group; Elm_Map_Marker *marker; int i; Eina_Bool free_marker = EINA_TRUE; Eina_List *l; - Widget_Data *wd = elm_widget_data_get(obj); - grid_clearall(obj); if (!wd) return; + grid_clearall(obj); for (i = 0; i < ZOOM_MAX + 1; i++) { if (!wd->markers[i]) continue; @@ -1940,7 +2026,9 @@ _del_pre_hook(Evas_Object *obj) static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; if (elm_widget_focus_get(obj)) { @@ -1957,7 +2045,9 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) static void _theme_hook(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj)); // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale); @@ -1967,8 +2057,10 @@ _theme_hook(Evas_Object *obj) static void _sizing_eval(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; + if (!wd) return; evas_object_size_hint_max_get(wd->scr, &maxw, &maxh); evas_object_size_hint_min_set(obj, minw, minh); @@ -2122,7 +2214,9 @@ _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__) static void _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; elm_smart_scroller_hold_set(wd->scr, 1); } @@ -2130,7 +2224,9 @@ _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) static void _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; elm_smart_scroller_hold_set(wd->scr, 0); } @@ -2138,7 +2234,9 @@ _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) static void _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; elm_smart_scroller_freeze_set(wd->scr, 1); } @@ -2146,7 +2244,9 @@ _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) static void _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; elm_smart_scroller_freeze_set(wd->scr, 0); } @@ -2461,6 +2561,8 @@ _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __U static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info) { + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); double zoom; Evas_Coord x = 0; Evas_Coord y = 0; @@ -2471,10 +2573,9 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty Evas_Coord page_x = 0; Evas_Coord page_y = 0; + if (!wd) return EINA_FALSE; if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; Evas_Event_Key_Down *ev = event_info; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return EINA_FALSE; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; elm_smart_scroller_child_pos_get(wd->scr, &x, &y); @@ -2820,12 +2921,13 @@ _name_complete_cb(void *data, int ev_type __UNUSED__, void *event) static Elm_Map_Name * _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat) { + ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - char buf[PATH_MAX]; char *source; int fd; + + if (!wd) return NULL; Elm_Map_Name *name = ELM_NEW(Elm_Map_Name); if (!name) return NULL; @@ -2914,6 +3016,7 @@ elm_map_add(Evas_Object *parent) evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj); evas_object_smart_callback_add(wd->scr, "drag", _scr, obj); elm_widget_resize_object_set(obj, wd->scr); + elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE); evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj); evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj); @@ -2975,6 +3078,8 @@ elm_map_add(Evas_Object *parent) _mouse_multi_move, obj); evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP, _mouse_multi_up, obj); + evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, + _mouse_wheel_cb, obj); evas_object_smart_member_add(wd->rect, wd->pan_smart); elm_widget_sub_object_add(obj, wd->rect); @@ -3166,6 +3271,21 @@ done: wd->t_start = ecore_loop_time_get(); wd->t_end = wd->t_start + _elm_config->zoom_friction; + if ((wd->size.w > 0) && (wd->size.h > 0)) + { + wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow; + wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh; + } + else + { + wd->size.spos.x = 0.5; + wd->size.spos.y = 0.5; + } + if (rw > wd->size.ow) wd->size.spos.x = 0.5; + if (rh > wd->size.oh) wd->size.spos.y = 0.5; + if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0; + if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0; + if (wd->paused) { zoom_do(obj); @@ -3220,6 +3340,7 @@ elm_map_zoom_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) 1.0; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return 1.0; return wd->zoom; } @@ -3247,6 +3368,7 @@ elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; if (wd->mode == mode) return; wd->mode = mode; @@ -3272,6 +3394,7 @@ elm_map_zoom_mode_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL; return wd->mode; } @@ -3399,6 +3522,7 @@ elm_map_paused_set(Evas_Object *obj, Eina_Bool paused) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; if (wd->paused == !!paused) return; wd->paused = paused; @@ -3431,6 +3555,7 @@ elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; if (wd->paused_markers == !!paused) return; wd->paused_markers = paused; @@ -3451,6 +3576,7 @@ elm_map_paused_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; return wd->paused; } @@ -3470,6 +3596,7 @@ elm_map_paused_markers_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; return wd->paused_markers; } @@ -3491,8 +3618,8 @@ elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int * { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; + if (!wd) return; if (try_num) { *try_num = wd->try_num; @@ -3518,7 +3645,10 @@ elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int * EAPI void elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + + if (!wd) return; int zoom = floor(log(size/256) / log(2)); if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE) @@ -3555,7 +3685,10 @@ elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int s EAPI void elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y) { + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + + if (!wd) return; int zoom = floor(log(size/256) / log(2)); if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE) @@ -3660,11 +3793,11 @@ elm_map_utils_rotate_coord(const Evas_Object *obj __UNUSED__, const Evas_Coord x EAPI Elm_Map_Marker * elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data) { + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); int i, j; Eina_List *l; Marker_Group *group; - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); int mpi, mpj; int tabi[9]; int tabj[9]; @@ -4030,6 +4163,7 @@ elm_map_max_marker_per_group_set(Evas_Object *obj, int max) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; wd->markers_max_num = max; } @@ -4085,12 +4219,12 @@ elm_map_bubbles_close(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); Marker_Group *group; Eina_List *l, *l_next; + if (!wd) return; EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group) _group_bubble_free(group); } - /** * Create a group class. * @@ -4107,6 +4241,7 @@ elm_map_group_class_new(Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class)); clas->zoom_grouped = ZOOM_MAX; @@ -4207,6 +4342,7 @@ elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_B { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; EINA_SAFETY_ON_NULL_RETURN(clas); if (clas->hide == hide) return; @@ -4236,6 +4372,7 @@ elm_map_marker_class_new(Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class)); wd->markers_clas = eina_list_append(wd->markers_clas, clas); @@ -4331,6 +4468,7 @@ elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source) Grid *grid; int zoom; Mod_Api *api = NULL; + if (!wd) return; _elm_config_sub_init(); if (source == ELM_MAP_SOURCE_MODULE) @@ -4370,6 +4508,7 @@ elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; wd->source = source; } @@ -4387,6 +4526,7 @@ elm_map_source_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return ELM_MAP_SOURCE_MAPNIK; return wd->source; } @@ -4404,6 +4544,7 @@ elm_map_route_source_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS; Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS; return wd->route_source; } @@ -4542,7 +4683,8 @@ elm_map_route_add(Evas_Object *obj, { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return EINA_FALSE; + + if (!wd) return NULL; char buf[PATH_MAX]; char *source; char *type_name = NULL; @@ -4780,8 +4922,8 @@ elm_map_name_address_get(Elm_Map_Name *name) * This gets the current coordinates of the name object. * * @param obj The name object - * @param lat The latitude. - * @param lon The longitude. + * @param lat The latitude + * @param lon The longitude * * @ingroup Map */ @@ -4826,9 +4968,9 @@ elm_map_name_remove(Elm_Map_Name *name) * Set the rotate degree of the map * * @param obj The map object - * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis. - * @param cx rotation's center horizontal position. - * @param cy rotation's center vertical position. + * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis + * @param cx rotation's center horizontal position + * @param cy rotation's center vertical position * * @ingroup Map */ @@ -4838,6 +4980,7 @@ elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; wd->rotate.d = degree; wd->rotate.cx = cx; wd->rotate.cy = cy; @@ -4848,9 +4991,9 @@ elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy * Get the rotate degree of the map * * @param obj The map object - * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis. - * @param cx rotation's center horizontal position. - * @param cy rotation's center vertical position. + * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis + * @param cx rotation's center horizontal position + * @param cy rotation's center vertical position * * @ingroup Map */ @@ -4860,11 +5003,52 @@ elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_ ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; if (degree) *degree = wd->rotate.d; if (cx) *cx = wd->rotate.cx; if (cy) *cy = wd->rotate.cy; } +/** + * Set the wheel control state of the map + * + * @param obj The map object + * @param disabled status of wheel control + * + * @ingroup Map + */ +EAPI void +elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + + if (!wd) return; + if ((!wd->wheel_disabled) && (disabled)) + evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); + else if ((wd->wheel_disabled) && (!disabled)) + evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); + wd->wheel_disabled = disabled; +} + +/** + * Get the wheel control state of the map + * + * @param obj The map object + * @return Returns the status of wheel control + * + * @ingroup Map + */ +EAPI Eina_Bool +elm_map_wheel_disabled_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + + if (!wd) return EINA_FALSE; + return wd->wheel_disabled; +} + static char * _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom) { @@ -5033,13 +5217,14 @@ static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name _ static char * _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat) { + ELM_CHECK_WIDTYPE(obj, widtype) strdup(""); Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return strdup(""); char **str; unsigned int ele, idx; - char search_url[PATH_MAX]; char buf[PATH_MAX]; + + if (!wd) return strdup(""); if (method == ELM_MAP_NAME_METHOD_SEARCH) { search_url[0] = '\0'; diff --git a/src/lib/els_scroller.c b/src/lib/els_scroller.c index c4204f2..514050c 100644 --- a/src/lib/els_scroller.c +++ b/src/lib/els_scroller.c @@ -107,6 +107,7 @@ struct _Smart_Data unsigned char bounce_animator_disabled :1; Eina_Bool is_mirrored : 1; unsigned char event_propagation :1; + Eina_Bool wheel_disabled : 1; }; /* local subsystem functions */ @@ -359,6 +360,24 @@ elm_smart_scroller_bounce_animator_disabled_set(Evas_Object *obj, Eina_Bool disa } } +Eina_Bool +elm_smart_scroller_wheel_disabled_get(Evas_Object *obj) +{ + API_ENTRY return EINA_FALSE; + return sd->wheel_disabled; +} + +void +elm_smart_scroller_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) +{ + API_ENTRY return; + if ((!sd->wheel_disabled) && (disabled)) + evas_object_event_callback_del_full(sd->event_obj, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd); + else if ((sd->wheel_disabled) && (!disabled)) + evas_object_event_callback_add(sd->event_obj, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd); + sd->wheel_disabled = disabled; +} + /* Update the wanted coordinates according to the x, y passed * widget directionality, child size and etc. */ static void diff --git a/src/lib/els_scroller.h b/src/lib/els_scroller.h index 1c77179..eefe421 100644 --- a/src/lib/els_scroller.h +++ b/src/lib/els_scroller.h @@ -38,3 +38,5 @@ Eina_Bool elm_smart_scroller_momentum_animator_disabled_get (Evas_Object *obj) void elm_smart_scroller_momentum_animator_disabled_set (Evas_Object *obj, Eina_Bool disabled); void elm_smart_scroller_bounce_animator_disabled_set (Evas_Object *obj, Eina_Bool disabled); Eina_Bool elm_smart_scroller_bounce_animator_disabled_get (Evas_Object *obj); +Eina_Bool elm_smart_scroller_wheel_disabled_get (Evas_Object *obj); +void elm_smart_scroller_wheel_disabled_set (Evas_Object *obj, Eina_Bool disabled); -- 2.7.4