From dfde103ed8867797f66faf7e2b781412c6a8ebba Mon Sep 17 00:00:00 2001 From: sangho park Date: Thu, 12 May 2011 11:24:15 +0900 Subject: [PATCH] upstream merge: removed all custom enum & url callback of elm_map Change-Id: I61251935a1567da9fbabf43db02a3bfd2a68e4d7 --- src/bin/test_map.c | 470 ++++++++++------------- src/edje_externals/elm_map.c | 34 +- src/lib/Elementary.h.in | 71 ++-- src/lib/Makefile.am | 160 ++++---- src/lib/elm_map.c | 872 +++++++++++++++++-------------------------- src/modules/test_map/mod.c | 75 ++-- 6 files changed, 701 insertions(+), 981 deletions(-) diff --git a/src/bin/test_map.c b/src/bin/test_map.c index b930d26..8704ed1 100644 --- a/src/bin/test_map.c +++ b/src/bin/test_map.c @@ -4,6 +4,7 @@ #endif #ifndef ELM_LIB_QUICKLAUNCH +#define SOURCE_MAX 10 #define MARKER_MAX 1000 #define NAME_ENTRY_TEXT "Enter freeform address" @@ -12,17 +13,25 @@ typedef struct Marker_Data const char *file; } Marker_Data; +typedef struct Map_Source +{ + Evas_Object *map; + char *source_name; +} Map_Source; static Elm_Map_Marker_Class *itc1, *itc2, *itc_parking; static Elm_Map_Group_Class *itc_group1, *itc_group2, *itc_group_parking; -static Evas_Object *rect; +static Evas_Object *rect, *menu; static int nb_elts; -static Elm_Map_Marker *markers[MARKER_MAX]; +/*static Elm_Map_Marker *markers[MARKER_MAX];*/ static Elm_Map_Marker *route_from, *route_to; static Elm_Map_Route *route; static Elm_Map_Name *name; -static Eina_List *names; +static const char **source_names = NULL; +static Evas_Coord old_x, old_y; +static Evas_Coord old_d; +static Map_Source ms[SOURCE_MAX]; Marker_Data data1 = {PACKAGE_DATA_DIR"/images/logo.png"}; Marker_Data data2 = {PACKAGE_DATA_DIR"/images/logo_small.png"}; @@ -65,24 +74,12 @@ my_map_longpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info) evas_object_geometry_get(data, &ox, &oy, &w, &h); zoom = elm_map_zoom_get(data); elm_map_geo_region_get(obj, &lon, &lat); - elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, zoom)*256, &x, &y); + elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, zoom) * 256, &x, &y); x += down->output.x - (w / 2) - ox; y += down->output.y - (h / 2) - oy; - elm_map_utils_convert_coord_into_geo(obj, x, y, pow(2.0, zoom)*256, &lon, &lat); + elm_map_utils_convert_coord_into_geo(obj, x, y, pow(2.0, zoom) * 256, &lon, &lat); name = elm_map_utils_convert_coord_into_name(data, lon, lat); - - itc1 = elm_map_marker_class_new(data); - - elm_map_marker_class_del_cb_set(itc1, NULL); - - itc_group1 = elm_map_group_class_new(data); - elm_map_group_class_icon_cb_set(itc_group1, _group_icon_get); - elm_map_group_class_data_set(itc_group1, (void *)PACKAGE_DATA_DIR"/images/bubble.png"); - elm_map_group_class_style_set(itc_group1, "empty"); - elm_map_group_class_zoom_displayed_set(itc_group1, 5); - - names = eina_list_append(names, elm_map_marker_add(data, lon, lat, itc1, itc_group1, NULL)); } static void @@ -99,7 +96,7 @@ my_map_clicked_double(void *data, Evas_Object *obj, void *event_info) evas_object_geometry_get(data, &ox, &oy, &w, &h); zoom = elm_map_zoom_get(data); - if (zoom<5) return; + if (zoom < 5) return; size = pow(2.0, zoom) * 256; elm_map_geo_region_get(obj, &lon, &lat); elm_map_utils_convert_geo_into_coord(obj, lon, lat, size, &x, &y); @@ -186,15 +183,15 @@ my_map_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event } static void -my_map_drag_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_map_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("drag,start\n"); + evas_object_smart_callback_del(data, "longpressed", my_map_longpressed); } static void -my_map_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_map_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("drag_stop\n"); + evas_object_smart_callback_add(data, "longpressed", my_map_longpressed, data); } static void @@ -264,7 +261,7 @@ my_map_name_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __U } static void -my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_show_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Eina_Bool b = elm_map_paused_get(data); elm_map_paused_set(data, EINA_TRUE); @@ -275,119 +272,109 @@ my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSE } static void -my_bt_bring_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { elm_map_geo_region_bring_in(data, 126.977969, 37.566535); } static void -my_bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_paused_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - double zoom; - - zoom = elm_map_zoom_get(data); - zoom += 1; - elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); - if (zoom >= (1.0 / 32.0)) elm_map_zoom_set(data, zoom); -} - -static void -my_bt_rotate_cw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - double d; - 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; - - elm_map_rotate_get(data, &d, NULL, NULL); - d += 15.0; - elm_map_rotate_set(data, d, x + half_w, y + half_h); + elm_map_paused_set(data, EINA_TRUE); } static void -my_bt_rotate_ccw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_paused_unset(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - double d; - 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; - - elm_map_rotate_get(data, &d, NULL, NULL); - d -= 15.0; - elm_map_rotate_set(data, d, x + half_w, y + half_h); + elm_map_paused_set(data, EINA_FALSE); } static void -my_bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - double zoom; + int zoom; - zoom = elm_map_zoom_get(data); - zoom -= 1; + zoom = elm_map_zoom_get(data) + 1; elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); - if (zoom <= 256.0) elm_map_zoom_set(data, zoom); + elm_map_zoom_set(data, zoom); } static void -my_bt_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_paused_set(data, !elm_map_paused_get(data)); -} + int zoom; -static void -my_bt_markers_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - elm_map_paused_markers_set(data, !elm_map_paused_markers_get(data)); + zoom = elm_map_zoom_get(data) - 1; + elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); + elm_map_zoom_set(data, zoom); } static void -my_bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FIT); } static void -my_bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FILL); } static void -my_bt_source_mapnik(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_rotate_cw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_set(data, ELM_MAP_SOURCE_MAPNIK); -} + double d; + 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; -static void -my_bt_source_osmarender(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - elm_map_source_set(data, ELM_MAP_SOURCE_OSMARENDER); + elm_map_rotate_get(data, &d, NULL, NULL); + d += 15.0; + elm_map_rotate_set(data, d, x + half_w, y + half_h); } static void -my_bt_source_cyclemap(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_rotate_ccw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_set(data, ELM_MAP_SOURCE_CYCLEMAP); + double d; + 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; + + elm_map_rotate_get(data, &d, NULL, NULL); + d -= 15.0; + elm_map_rotate_set(data, d, x + half_w, y + half_h); } static void -my_bt_source_maplint(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_rotate_reset(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_set(data, ELM_MAP_SOURCE_MAPLINT); + 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; + + elm_map_rotate_set(data, 0.0, x + half_w, y + half_h); } static void -my_bt_source_module(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_source(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_set(data, ELM_MAP_SOURCE_MODULE); + Map_Source *ms = data; + + if (!ms) return; + elm_map_source_name_set(ms->map, ms->source_name); } +/* static void -my_bt_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_marker_add(void *data) { int i; Elm_Map_Group_Class *g_clas; @@ -427,7 +414,7 @@ my_bt_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) } static void -my_bt_remove(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +map_marker_remove(void *data __UNUSED__) { int i; @@ -456,6 +443,7 @@ my_map_entry_activated(void *data, Evas_Object *obj, void *event_info __UNUSED__ name = elm_map_utils_convert_name_into_coord(data, addr); if (addr) free (addr); } +*/ static Evas_Object * _marker_get(Evas_Object *obj, Elm_Map_Marker *marker __UNUSED__, void *data) @@ -528,10 +516,113 @@ _map_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, evas_object_move(rect,x,y); } +static void +_populate(void *data, Elm_Menu_Item *item) +{ + int idx; + + if ((!data) || (!item) || (!source_names)) return; + for (idx = 0; source_names[idx]; idx++) + { + if (idx >= SOURCE_MAX) break; + ms[idx].map = data; + ms[idx].source_name = strdup(source_names[idx]); + elm_menu_item_add(menu, item, "", source_names[idx], map_source, &ms[idx]); + } +} + +static void +_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *down = event_info; + Elm_Menu_Item *item; + if (!down) return; + + if (down->button == 2) + { + old_x = down->output.x; + old_y = down->output.y; + old_d = 0.0; + } + else if (down->button == 3) + { + menu = elm_menu_add(obj); + item = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL); + _populate(data, item); + elm_menu_item_add(menu, NULL, NULL, "Show Seoul", map_show_seoul, data); + elm_menu_item_add(menu, NULL, NULL, "Bring Seoul", map_bring_seoul, data); + elm_menu_item_add(menu, NULL, NULL, "Paused Set", map_paused_set, data); + elm_menu_item_add(menu, NULL, NULL, "Paused Unset", map_paused_unset, data); + elm_menu_item_add(menu, NULL, NULL, "Zoom +", map_zoom_in, data); + elm_menu_item_add(menu, NULL, NULL, "Zoom -", map_zoom_out, data); + elm_menu_item_add(menu, NULL, NULL, "Zoom Fit", map_zoom_fit, data); + elm_menu_item_add(menu, NULL, NULL, "Zoom Fill", map_zoom_fill, data); + elm_menu_item_add(menu, NULL, NULL, "Add Marker", NULL, NULL); + elm_menu_item_add(menu, NULL, NULL, "Rotate CW", map_rotate_cw, data); + elm_menu_item_add(menu, NULL, NULL, "Rotate CCW", map_rotate_ccw, data); + elm_menu_item_add(menu, NULL, NULL, "Reset Rotate", map_rotate_reset, data); + + elm_menu_move(menu, down->canvas.x, down->canvas.y); + evas_object_show(menu); + } +} + +static void +_map_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Event_Mouse_Move *move = event_info; + Evas_Coord x, y, w, h; + float half_w, half_h; + int d, d_diff; + double cur_d; + if (!move) return; + + if (move->buttons == 2) + { + evas_object_geometry_get(data, &x, &y, &w, &h); + half_w = (float)w * 0.5; + half_h = (float)h * 0.5; + elm_map_rotate_get(data, &cur_d, NULL, NULL); + + d = move->cur.output.x - old_x; + if (!old_d) old_d = d; + else + { + d_diff = old_d - d; + if (d_diff > 0) + { + old_d --; + cur_d += 1.0; + } + else if (d_diff < 0) + { + old_d ++; + cur_d -= 1.0; + } + old_d = d; + elm_map_rotate_set(data, cur_d, x + half_w, y + half_h); + } + } +} + +static void +_map_mouse_up(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Event_Mouse_Up *up = event_info; + if (!up) return; + + if (up->button == 2) + { + old_x = 0; + old_y = 0; + } +} + void test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *map, *tb2, *bt, *bx, *en; + Evas_Object *win, *bg, *map; + int idx = 0; win = elm_win_add(NULL, "map", ELM_WIN_BASIC); elm_win_title_set(win, "Map"); @@ -545,7 +636,14 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ map = elm_map_add(win); if (map) { - srand( time(NULL) ); + srand(time(NULL)); + + source_names = elm_map_source_names_get(map); + + if (!source_names) return; + printf("map sources [ "); + for (idx = 0; source_names[idx] ; idx++) printf("%s ", source_names[idx]); + printf("]\n"); evas_object_size_hint_weight_set(map, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, map); @@ -593,6 +691,12 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ _map_move_resize_cb, map); evas_object_event_callback_add(map, EVAS_CALLBACK_MOVE, _map_move_resize_cb, map); + evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_DOWN, + _map_mouse_down, map); + evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_MOVE, + _map_mouse_move, map); + evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_UP, + _map_mouse_up, map); elm_map_marker_add(map, 2.352, 48.857, itc1, itc_group1, &data1); elm_map_marker_add(map, 2.355, 48.857, itc1, itc_group1, &data3); @@ -622,8 +726,8 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ evas_object_smart_callback_add(map, "zoom,change", my_map_zoom_change, win); evas_object_smart_callback_add(map, "scroll,anim,start", my_map_anim_start, win); evas_object_smart_callback_add(map, "scroll,anim,stop", my_map_anim_stop, win); - evas_object_smart_callback_add(map, "scroll,drag,start", my_map_drag_start, win); - evas_object_smart_callback_add(map, "scroll,drag,stop", my_map_drag_stop, win); + evas_object_smart_callback_add(map, "scroll,drag,start", my_map_drag_start, map); + evas_object_smart_callback_add(map, "scroll,drag,stop", my_map_drag_stop, map); evas_object_smart_callback_add(map, "scroll", my_map_scroll, win); evas_object_smart_callback_add(map, "downloaded", my_map_downloaded, map); evas_object_smart_callback_add(map, "route,load", my_map_route_load, map); @@ -632,192 +736,6 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ evas_object_smart_callback_add(map, "name,loaded", my_map_name_loaded, map); evas_object_show(map); - - tb2 = elm_table_add(win); - evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, tb2); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Z -"); - evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_out, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.1); - elm_table_pack(tb2, bt, 0, 0, 1, 1); - evas_object_show(bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Z +"); - evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_in, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.9, 0.1); - elm_table_pack(tb2, bt, 2, 0, 1, 1); - evas_object_show(bt); - - bx = elm_box_add(win); - evas_object_show(bx); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx, 0.5, 0.1); - elm_table_pack(tb2, bx, 1, 0, 1, 1); - - // - en = elm_scrolled_entry_add(win); - evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); - elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scrolled_entry_entry_set(en, NAME_ENTRY_TEXT); - elm_scrolled_entry_single_line_set(en, 1); - elm_box_pack_end(bx, en); - evas_object_smart_callback_add(en, "focused", my_map_entry_focused, win); - evas_object_smart_callback_add(en, "activated", my_map_entry_activated, map); - evas_object_show(en); - - // - bt = elm_button_add(win); - elm_button_label_set(bt, "Add 1000 markers"); - evas_object_smart_callback_add(bt, "clicked", my_bt_add, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.5, 0.1); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "remove 1000 markers"); - evas_object_smart_callback_add(bt, "clicked", my_bt_remove, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.5, 0.1); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - // - - bt = elm_button_add(win); - elm_button_label_set(bt, "Show Seoul"); - evas_object_smart_callback_add(bt, "clicked", my_bt_show_reg, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.5); - elm_table_pack(tb2, bt, 0, 1, 1, 1); - evas_object_show(bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Bring Seoul"); - evas_object_smart_callback_add(bt, "clicked", my_bt_bring_reg, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.9, 0.5); - elm_table_pack(tb2, bt, 2, 1, 1, 1); - evas_object_show(bt); - - // - bx = elm_box_add(win); - evas_object_show(bx); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx, 0.1, 0.9); - elm_table_pack(tb2, bx, 0, 2, 1, 1); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Pause On/Off"); - evas_object_smart_callback_add(bt, "clicked", my_bt_pause, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Markers pause On/Off"); - evas_object_smart_callback_add(bt, "clicked", my_bt_markers_pause, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "R +"); - evas_object_smart_callback_add(bt, "clicked", my_bt_rotate_cw, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "R -"); - evas_object_smart_callback_add(bt, "clicked", my_bt_rotate_ccw, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.1, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - // - - // - bx = elm_box_add(win); - evas_object_show(bx); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx, 0.5, 0.9); - elm_table_pack(tb2, bx, 1, 2, 1, 1); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Fit"); - evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.5, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Fill"); - evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fill, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 0.5, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - // - - // - bx = elm_box_add(win); - evas_object_show(bx); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx, 1.0, 0.9); - elm_table_pack(tb2, bx, 2, 2, 1, 1); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Mapnik"); - evas_object_smart_callback_add(bt, "clicked", my_bt_source_mapnik, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 1.0, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Osmarender"); - evas_object_smart_callback_add(bt, "clicked", my_bt_source_osmarender, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 1.0, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Cycle Map"); - evas_object_smart_callback_add(bt, "clicked", my_bt_source_cyclemap, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 1.0, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Maplint"); - evas_object_smart_callback_add(bt, "clicked", my_bt_source_maplint, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 1.0, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - - bt = elm_button_add(win); - elm_button_label_set(bt, "Module"); - evas_object_smart_callback_add(bt, "clicked", my_bt_source_module, map); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, 1.0, 0.9); - evas_object_show(bt); - elm_box_pack_end(bx, bt); - // - - evas_object_show(tb2); } evas_object_resize(win, 800, 800); diff --git a/src/edje_externals/elm_map.c b/src/edje_externals/elm_map.c index c5e8386..fa4c0d0 100644 --- a/src/edje_externals/elm_map.c +++ b/src/edje_externals/elm_map.c @@ -14,9 +14,7 @@ typedef struct _Elm_Params_Map static const char *zoom_choices[] = {"manual", "auto fit", "auto fill", NULL}; static const char *source_choices[] = - {"Mapnik", "Osmarender", "Cycle Map", "Maplint", - "Custom 1", "Custom 2", "Custom 3", "Custom 4", - "Custom 5", "Custom 6", "Custom 7"}; + {"Mapnik", "Osmarender", "CycleMap", "Maplint"}; static Elm_Map_Zoom_Mode _zoom_mode_get(const char *map_src) @@ -32,20 +30,6 @@ _zoom_mode_get(const char *map_src) return ELM_MAP_ZOOM_MODE_LAST; } -static Elm_Map_Sources -_map_source_get(const char *map_src) -{ - unsigned int i; - - assert(sizeof(source_choices)/sizeof(source_choices[0]) == - ELM_MAP_SOURCE_LAST); - - for (i = 0; i < sizeof(source_choices); i++) - if (!strcmp(map_src, source_choices[i])) return i; - - return ELM_MAP_SOURCE_LAST; -} - static void external_map_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) { @@ -57,9 +41,7 @@ external_map_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from if (p->map_source) { - Elm_Map_Sources set = _map_source_get(p->map_source); - if (set == ELM_MAP_SOURCE_LAST) return; - elm_map_source_set(obj, set); + elm_map_source_name_set(obj, p->map_source); } if (p->zoom_mode) { @@ -77,9 +59,7 @@ external_map_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Exter { if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) { - Elm_Map_Sources set = _map_source_get(param->s); - if (set == ELM_MAP_SOURCE_LAST) return EINA_FALSE; - elm_map_source_set(obj, set); + elm_map_source_name_set(obj, param->s); return EINA_TRUE; } } @@ -115,9 +95,8 @@ external_map_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_Exter { if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) { - Elm_Map_Sources set = elm_map_source_get(obj); - if (set == ELM_MAP_SOURCE_LAST) return EINA_FALSE; - param->s = source_choices[set]; + const char *set = elm_map_source_name_get(obj); + param->s = set; return EINA_TRUE; } } @@ -195,8 +174,7 @@ external_map_params_free(void *params) static Edje_External_Param_Info external_map_params[] = { DEFINE_EXTERNAL_COMMON_PARAMS, - EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("map source", "Mapnik", - source_choices), + EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("map source", "Mapnik", source_choices), EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("zoom mode", "manual", zoom_choices), EDJE_EXTERNAL_PARAM_INFO_DOUBLE("zoom level"), EDJE_EXTERNAL_PARAM_INFO_SENTINEL diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index b2a09a6..fc5b925 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -2318,47 +2318,17 @@ extern "C" { ELM_MAP_ZOOM_MODE_LAST } Elm_Map_Zoom_Mode; - typedef enum _Elm_Map_Sources - { - ELM_MAP_SOURCE_MAPNIK, - ELM_MAP_SOURCE_OSMARENDER, - ELM_MAP_SOURCE_CYCLEMAP, - ELM_MAP_SOURCE_MAPLINT, - ELM_MAP_SOURCE_CUSTOM_1, - ELM_MAP_SOURCE_CUSTOM_2, - ELM_MAP_SOURCE_CUSTOM_3, - ELM_MAP_SOURCE_CUSTOM_4, - ELM_MAP_SOURCE_CUSTOM_5, - ELM_MAP_SOURCE_CUSTOM_6, - ELM_MAP_SOURCE_MODULE, - ELM_MAP_SOURCE_LAST - } Elm_Map_Sources; - typedef enum _Elm_Map_Route_Sources { ELM_MAP_ROUTE_SOURCE_YOURS, ELM_MAP_ROUTE_SOURCE_MONAV, ELM_MAP_ROUTE_SOURCE_ORS, - ELM_MAP_ROUTE_SOURCE_CUSTOM_1, - ELM_MAP_ROUTE_SOURCE_CUSTOM_2, - ELM_MAP_ROUTE_SOURCE_CUSTOM_3, - ELM_MAP_ROUTE_SOURCE_CUSTOM_4, - ELM_MAP_ROUTE_SOURCE_CUSTOM_5, - ELM_MAP_ROUTE_SOURCE_CUSTOM_6, - ELM_MAP_ROUTE_SOURCE_MODULE, ELM_MAP_ROUTE_SOURCE_LAST } Elm_Map_Route_Sources; typedef enum _Elm_Map_Name_Sources { ELM_MAP_NAME_SOURCE_NOMINATIM, - ELM_MAP_NAME_SOURCE_CUSTOM_1, - ELM_MAP_NAME_SOURCE_CUSTOM_2, - ELM_MAP_NAME_SOURCE_CUSTOM_3, - ELM_MAP_NAME_SOURCE_CUSTOM_4, - ELM_MAP_NAME_SOURCE_CUSTOM_5, - ELM_MAP_NAME_SOURCE_CUSTOM_6, - ELM_MAP_NAME_SOURCE_MODULE, ELM_MAP_NAME_SOURCE_LAST } Elm_Map_Name_Sources; @@ -2389,17 +2359,25 @@ extern "C" { typedef struct _Elm_Map_Group_Class Elm_Map_Group_Class; typedef struct _Elm_Map_Route Elm_Map_Route; typedef struct _Elm_Map_Name Elm_Map_Name; + typedef Evas_Object *(*ElmMapMarkerGetFunc) (Evas_Object *obj, Elm_Map_Marker *marker, void *data); typedef void (*ElmMapMarkerDelFunc) (Evas_Object *obj, Elm_Map_Marker *marker, void *data, Evas_Object *o); typedef Evas_Object *(*ElmMapMarkerIconGetFunc) (Evas_Object *obj, Elm_Map_Marker *marker, void *data); typedef Evas_Object *(*ElmMapGroupIconGetFunc) (Evas_Object *obj, void *data); - typedef char *(*ElmMapSourceURLFunc) (Evas_Object *obj, int x, int y, int zoom); - typedef char *(*ElmMapRouteSourceURLFunc) (Evas_Object *obj, char *type_name, int method, double flon, double flat, double tlon, double tlat); - typedef char *(*ElmMapNameSourceURLFunc) (Evas_Object *obj, int method, char *name, double lon, double lat); + + typedef char *(*ElmMapModuleSourceFunc) (void); + typedef int (*ElmMapModuleZoomMinFunc) (void); + typedef int (*ElmMapModuleZoomMaxFunc) (void); + typedef char *(*ElmMapModuleUrlFunc) (Evas_Object *obj, int x, int y, int zoom); + typedef int (*ElmMapModuleRouteSourceFunc) (void); + typedef char *(*ElmMapModuleRouteUrlFunc) (Evas_Object *obj, char *type_name, int method, double flon, double flat, double tlon, double tlat); + typedef char *(*ElmMapModuleNameUrlFunc) (Evas_Object *obj, int method, char *name, double lon, double lat); + typedef Eina_Bool (*ElmMapModuleGeoIntoCoordFunc) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y); + typedef Eina_Bool (*ElmMapModuleCoordIntoGeoFunc) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat); EAPI Evas_Object *elm_map_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_map_zoom_set(Evas_Object *obj, int zoom) EINA_ARG_NONNULL(1); - EAPI double elm_map_zoom_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI int elm_map_zoom_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode) EINA_ARG_NONNULL(1); EAPI Elm_Map_Zoom_Mode elm_map_zoom_mode_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat) EINA_ARG_NONNULL(1); @@ -2437,25 +2415,24 @@ extern "C" { EAPI void elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get) EINA_ARG_NONNULL(1); EAPI void elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get) EINA_ARG_NONNULL(1); EAPI void elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del) EINA_ARG_NONNULL(1); - EAPI void elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source) EINA_ARG_NONNULL(1); + EAPI const char **elm_map_source_names_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI void elm_map_source_name_set(Evas_Object *obj, const char *source_name) EINA_ARG_NONNULL(1); + EAPI const char *elm_map_source_name_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source) EINA_ARG_NONNULL(1); - EAPI Elm_Map_Sources elm_map_source_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Elm_Map_Route_Sources elm_map_route_source_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - EAPI void elm_map_source_custom_api_set(Elm_Map_Sources source, const char *label, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb, ElmMapRouteSourceURLFunc route_url_cb, ElmMapNameSourceURLFunc name_url_cb) EINA_ARG_NONNULL(2, 5, 6, 7); - EAPI int elm_map_source_zoom_min_get(Elm_Map_Sources source); - EAPI int elm_map_source_zoom_max_get(Elm_Map_Sources source); - EAPI const char *elm_map_source_name_get(Elm_Map_Sources source); + EAPI int elm_map_source_zoom_min_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI int elm_map_source_zoom_max_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_map_user_agent_set(Evas_Object *obj, const char *user_agent) EINA_ARG_NONNULL(1, 2); - EAPI const char *elm_map_user_agent_get(Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI const char *elm_map_user_agent_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Elm_Map_Route *elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat) EINA_ARG_NONNULL(1); EAPI void elm_map_route_remove(Elm_Map_Route *route) EINA_ARG_NONNULL(1); EAPI void elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a) EINA_ARG_NONNULL(1); - EAPI void elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a) EINA_ARG_NONNULL(1); - EAPI double elm_map_route_distance_get(Elm_Map_Route *route) EINA_ARG_NONNULL(1); - EAPI const char *elm_map_route_node_get(Elm_Map_Route *route) EINA_ARG_NONNULL(1); - EAPI const char *elm_map_route_waypoint_get(Elm_Map_Route *route) EINA_ARG_NONNULL(1); - EAPI const char *elm_map_name_address_get(Elm_Map_Name *name) EINA_ARG_NONNULL(1); - EAPI void elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat) EINA_ARG_NONNULL(1); + EAPI void elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a) EINA_ARG_NONNULL(1); + EAPI double elm_map_route_distance_get(const Elm_Map_Route *route) EINA_ARG_NONNULL(1); + EAPI const char *elm_map_route_node_get(const Elm_Map_Route *route) EINA_ARG_NONNULL(1); + EAPI const char *elm_map_route_waypoint_get(const Elm_Map_Route *route) EINA_ARG_NONNULL(1); + EAPI const char *elm_map_name_address_get(const Elm_Map_Name *name) EINA_ARG_NONNULL(1); + EAPI void elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat) EINA_ARG_NONNULL(1); 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); diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 02c572a..801d0e0 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ -DELM_INTERNAL_API_ARGESFSDFEFC=1 \ +-DMODULES_PATH=\"$(libdir)/elementary/modules\" \ -I. \ -I$(top_builddir) \ -I$(top_srcdir) \ @@ -32,112 +33,105 @@ lib_LTLIBRARIES = libelementary.la includes_HEADERS = \ Elementary.h \ Elementary_Cursor.h \ -elm_widget.h \ -elm_priv.h +elm_widget.h includesdir = $(includedir)/elementary-@VMAJ@ libelementary_la_SOURCES = \ elm_priv.h \ -\ -elm_main.c \ -elm_util.c \ -elm_theme.c \ -elm_module.c \ -elm_store.c \ -\ -elm_win.c \ -elm_widget.c \ +elc_anchorblock.c \ +elc_anchorview.c \ +elc_ctxpopup.c \ +elc_fileselector.c \ +elc_fileselector_button.c \ +elc_fileselector_entry.c \ +elc_hoversel.c \ +elc_scrolled_entry.c \ +elm_actionslider.c \ +elm_animator.c \ elm_bg.c \ -elm_icon.c \ -elm_image.c \ elm_box.c \ +elm_bubble.c \ elm_button.c \ -elm_scroller.c \ -elm_label.c \ -elm_toggle.c \ -elm_frame.c \ -elm_table.c \ -elm_gengrid.c \ +elm_calendar.c \ +elm_carousel.c \ +elm_cbhm_helper.c \ +elm_check.c \ elm_clock.c \ -elm_layout.c \ -elm_hover.c \ +elm_cnp_helper.c \ +elm_colorpalette.c \ +elm_colorselector.c \ +elm_config.c \ +elm_conform.c \ +elm_controlbar.c \ +elm_datefield.c \ +elm_dayselector.c \ +elm_dialoguegroup.c \ +elm_diskselector.c \ +elm_editfield.c \ elm_entry.c \ -elm_bubble.c \ -elm_photo.c \ -elm_toolbar.c \ -elm_searchbar.c \ -elm_list.c \ -elm_carousel.c \ -elm_slider.c \ -elm_actionslider.c \ +elm_flip.c \ +elm_flipselector.c \ +elm_font.c \ +elm_frame.c \ +elm_gengrid.c \ elm_genlist.c \ -elm_check.c \ -elm_radio.c \ -elm_segment_control.c \ -elm_pagecontrol.c \ -elm_pager.c \ -elm_progressbar.c \ -elm_separator.c \ -elm_spinner.c \ +elm_hover.c \ +elm_icon.c \ +elm_image.c \ +elm_imageslider.c \ elm_index.c \ -elm_photocam.c \ -elm_notify.c \ -elm_slideshow.c \ -elm_menu.c \ -elm_panel.c \ -elm_panes.c \ +elm_label.c \ +elm_layout.c \ +elm_list.c \ +elm_main.c \ elm_map.c \ -elm_flip.c \ -elm_conform.c \ elm_mapbuf.c \ -elm_thumb.c \ -elm_config.c \ -elm_font.c \ -elm_animator.c \ -elm_popup.c \ +elm_menu.c \ +elm_module.c \ +elm_multibuttonentry.c \ elm_navigationbar.c \ elm_navigationbar_ex.c\ -elm_transit.c \ -elm_calendar.c \ -elm_flipselector.c \ -elm_editfield.c \ -elm_diskselector.c \ -elm_colorselector.c \ -elm_colorpalette.c \ -elm_controlbar.c \ -elm_dialoguegroup.c \ -elm_dayselector.c \ -elm_cbhm_helper.c \ -elm_datefield.c \ elm_nocontents.c \ -elm_tickernoti.c \ -elm_imageslider.c \ -elm_multibuttonentry.c \ +elm_notify.c \ +elm_pagecontrol.c \ +elm_pager.c \ +elm_panel.c \ +elm_panes.c \ +elm_photo.c \ +elm_photocam.c \ +elm_popup.c \ +elm_progressbar.c \ +elm_radio.c \ +elm_scroller.c \ +elm_searchbar.c \ +elm_segment_control.c \ +elm_separator.c \ +elm_slider.c \ +elm_slideshow.c \ elm_slidingdrawer.c \ +elm_spinner.c \ elm_stackedicon.c \ -\ -elc_anchorblock.c \ -elc_anchorview.c \ -elc_ctxpopup.c \ -elc_fileselector.c \ -elc_fileselector_button.c \ -elc_fileselector_entry.c \ -elc_hoversel.c \ -elc_scrolled_entry.c \ -\ -els_tooltip.c \ +elm_store.c \ +elm_table.c \ +elm_theme.c \ +elm_thumb.c \ +elm_tickernoti.c \ +elm_toggle.c \ +elm_toolbar.c \ +elm_transit.c \ +elm_util.c \ +elm_widget.c \ +elm_win.c \ +els_box.c \ +els_box.h \ els_cursor.c \ +els_icon.c \ +els_icon.h \ els_pan.c \ els_pan.h \ els_scroller.c \ els_scroller.h \ -els_box.c \ -els_box.h \ -els_icon.c \ -els_icon.h \ -\ -elm_cnp_helper.c - +els_tooltip.c libelementary_la_CFLAGS = libelementary_la_LIBADD = \ diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c index 42bf3b6..097760e 100644 --- a/src/lib/elm_map.c +++ b/src/lib/elm_map.c @@ -61,7 +61,6 @@ typedef struct _Pan Pan; typedef struct _Grid Grid; typedef struct _Grid_Item Grid_Item; typedef struct _Marker_Group Marker_Group; -typedef struct _Mod_Api Mod_Api; typedef struct _Event Event; typedef struct _Route_Node Route_Node; typedef struct _Route_Waypoint Route_Waypoint; @@ -72,7 +71,6 @@ typedef struct _Name_Dump Name_Dump; #define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/" #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/" #define DEST_FILE_PATH "%s%d.png" -#define MOD_AS "map/api" #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX" #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX" @@ -94,22 +92,23 @@ typedef struct _Name_Dump Name_Dump; #define NOMINATIM_ATTR_LON "lon" #define NOMINATIM_ATTR_LAT "lat" -#define PINCH_ZOOM_MIN 0.25 -#define PINCH_ZOOM_MAX 3.0 +#define PINCH_ZOOM_MIN 0.1 +#define PINCH_ZOOM_MAX 5.0 // Map sources // Currently the size of a tile must be 256*256 // and the size of the map must be pow(2.0, z)*tile_size typedef struct _Map_Sources_Tab { - Elm_Map_Sources source; const char *name; int zoom_min; int zoom_max; - ElmMapSourceURLFunc url_cb; + ElmMapModuleUrlFunc url_cb; Elm_Map_Route_Sources route_source; - ElmMapRouteSourceURLFunc route_url_cb; - ElmMapNameSourceURLFunc name_url_cb; + ElmMapModuleRouteUrlFunc route_url_cb; + ElmMapModuleNameUrlFunc name_url_cb; + ElmMapModuleGeoIntoCoordFunc geo_into_coord; + ElmMapModuleCoordIntoGeoFunc coord_into_geo; } Map_Sources_Tab; #define ZOOM_MAX 18 @@ -119,50 +118,20 @@ static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom) static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char *_module_url_cb(Evas_Object *obj, int x, int y, int zoom); -static char * _custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char * _custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char * _custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char * _custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char * _custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char * _custom6_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); /* static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat) static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); */ -static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -/* -static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); - */ - static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat); -static char *_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); -static char *_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); -static char *_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); -static char *_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); -static char *_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); -static char *_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__); - -static Map_Sources_Tab map_sources_tab[] = -{ - {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}, - {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}, - {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}, - {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, _custom1_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_1, _route_custom1_url_cb, _name_custom1_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, _custom2_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_2, _route_custom2_url_cb, _name_custom2_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, _custom3_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_3, _route_custom3_url_cb, _name_custom3_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, _custom4_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_4, _route_custom4_url_cb, _name_custom4_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, _custom5_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_5, _route_custom5_url_cb, _name_custom5_url_cb}, - {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, _custom6_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_6, _route_custom6_url_cb, _name_custom6_url_cb}, - {ELM_MAP_SOURCE_MODULE, "Module", 0, 18, _module_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb} + +static Map_Sources_Tab default_map_sources_tab[] = +{ + {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, + {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, + {"CycleMap", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, + {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, }; struct _Url_Data @@ -361,7 +330,7 @@ struct _Widget_Data Ecore_Timer *scr_timer; Ecore_Timer *long_timer; Ecore_Animator *zoom_animator; - double t_start, t_end; + double t; struct { int w, h; int ow, oh, nw, nh; @@ -398,9 +367,7 @@ struct _Widget_Data Eina_List *groups_clas; // list of Elm_Map_Group_Class* Eina_List *markers_clas; // list of Elm_Map_Markers_Class* - Elm_Map_Sources source; Elm_Map_Route_Sources route_source; - Elm_Module *m; Eina_List *s_event_list; int try_num; int finish_num; @@ -429,16 +396,15 @@ struct _Widget_Data double wheel_zoom; Ecore_Timer *wheel_timer; Eina_Bool wheel_disabled : 1; -}; -struct _Mod_Api -{ - Eina_Bool (*obj_hook) (Evas_Object *obj); - Eina_Bool (*obj_unhook) (Evas_Object *obj); - char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom); - Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat); - Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y); + Eina_Array *modules; + Eina_List *map_sources_tab; + const char **source_names; + Evas_Map *map; + Ecore_Timer *zoom_timer; + Map_Sources_Tab *src; }; + struct _Pan { Evas_Object_Smart_Clipped_Data __clipped_data; @@ -659,69 +625,116 @@ destroy_event_object(void *data, Event *ev) free(ev); } -static void -module(Evas_Object *obj) +static Eina_Bool +module_list_cb(Eina_Module *m, void *data) { - Widget_Data *wd = elm_widget_data_get(obj); - const char *p, *pe; + ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(data); + Map_Sources_Tab *s; + ElmMapModuleSourceFunc source; + ElmMapModuleZoomMinFunc zoom_min; + ElmMapModuleZoomMaxFunc zoom_max; + ElmMapModuleUrlFunc url; + ElmMapModuleRouteSourceFunc route_source; + ElmMapModuleRouteUrlFunc route_url; + ElmMapModuleNameUrlFunc name_url; + ElmMapModuleGeoIntoCoordFunc geo_into_coord; + ElmMapModuleCoordIntoGeoFunc coord_into_geo; + const char *file; - if (wd->m) + if (!wd) return EINA_FALSE; + + file = eina_module_file_get(m); + if (!eina_module_load(m)) { - Mod_Api *api = wd->m->api; - if ((api) && (api->obj_unhook)) api->obj_unhook(obj); - _elm_module_del(wd->m); - wd->m = NULL; + ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get())); + return EINA_FALSE; } - p = _elm_config->modules; - pe = p; - for (;;) + source = eina_module_symbol_get(m, "map_module_source_get"); + zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get"); + zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get"); + url = eina_module_symbol_get(m, "map_module_url_get"); + route_source = eina_module_symbol_get(m, "map_module_route_source_get"); + route_url = eina_module_symbol_get(m, "map_module_route_url_get"); + name_url = eina_module_symbol_get(m, "map_module_name_url_get"); + geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord"); + coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo"); + if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo)) { - if ((*pe == ':') || (!*pe)) - { - if (pe > p) - { - char *n = malloc(pe - p + 1); - if (n) - { - char *nn; + ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get())); + eina_module_unload(m); + return EINA_FALSE; + } + s = calloc(1, sizeof(Map_Sources_Tab)); + EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE); + s->name = source(); + s->zoom_min = zoom_min(); + s->zoom_max = zoom_max(); + s->url_cb = url; + s->route_source = route_source(); + s->route_url_cb = route_url; + s->name_url_cb = name_url; + s->geo_into_coord = geo_into_coord; + s->coord_into_geo = coord_into_geo; + wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s); - strncpy(n, p, pe - p); - n[pe - p] = 0; - nn = strchr(n, '>'); - if (nn) - { - *nn = 0; - nn++; - if (!strcmp(nn, MOD_AS)) - { - wd->m = _elm_module_add(n, nn); - _elm_module_load(wd->m); - } - } - free(n); - } - } - if (!*pe) break; - p = pe + 1; - pe = p; - } - else - pe++; + return EINA_TRUE; +} + +static void +module_init(void *data) +{ + ELM_CHECK_WIDTYPE(data, widtype); + Widget_Data *wd = elm_widget_data_get(data); + + if (!wd) return; + wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data); +} + +static void +source_init(void *data) +{ + ELM_CHECK_WIDTYPE(data, widtype); + Widget_Data *wd = elm_widget_data_get(data); + Map_Sources_Tab *s; + Eina_List *l; + int idx; + + if (!wd) return; + for (idx = 0; idx < 4; idx++) + { + s = calloc(1, sizeof(Map_Sources_Tab)); + EINA_SAFETY_ON_NULL_RETURN(s); + s->name = default_map_sources_tab[idx].name; + s->zoom_min = default_map_sources_tab[idx].zoom_min; + s->zoom_max = default_map_sources_tab[idx].zoom_max; + s->url_cb = default_map_sources_tab[idx].url_cb; + s->route_source = default_map_sources_tab[idx].route_source; + s->route_url_cb = default_map_sources_tab[idx].route_url_cb; + s->name_url_cb = default_map_sources_tab[idx].name_url_cb; + s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord; + s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo; + wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s); + if (!idx) wd->src = s; } + module_init(data); - if (!wd->m) return; - if (!wd->m->api) wd->m->api = malloc(sizeof(Mod_Api)); - ((Mod_Api *)(wd->m->api) )->obj_hook = - _elm_module_symbol_get(wd->m, "obj_hook"); - ((Mod_Api *)(wd->m->api) )->obj_unhook = - _elm_module_symbol_get(wd->m, "obj_unhook"); - ((Mod_Api *)(wd->m->api) )->obj_url_request = - _elm_module_symbol_get(wd->m, "obj_url_request"); - ((Mod_Api *)(wd->m->api) )->obj_convert_coord_into_geo = - _elm_module_symbol_get(wd->m, "obj_convert_coord_into_geo"); - ((Mod_Api *)(wd->m->api) )->obj_convert_geo_into_coord = - _elm_module_symbol_get(wd->m, "obj_convert_geo_into_coord"); + int n = eina_list_count(wd->map_sources_tab); + wd->source_names = malloc(sizeof(char *) * (n + 1)); + if (!wd->source_names) + { + ERR("init source names failed."); + return; + } + idx = 0; + EINA_LIST_FOREACH(wd->map_sources_tab, l, s) + { + wd->source_names[idx] = strdup(s->name); + INF("source : %s", wd->source_names[idx]); + idx++; + } + wd->source_names[idx] = NULL; } static void @@ -735,15 +748,11 @@ obj_rotate_zoom(void *data, Evas_Object *obj) wd->pinch.cy = wd->rotate.cy; } - Evas_Map *map = evas_map_new(4); - if (!map) return; - - evas_map_util_points_populate_from_object_full(map, obj, 0); - evas_map_util_zoom(map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy); - evas_map_util_rotate(map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy); + evas_map_util_points_populate_from_object_full(wd->map, obj, 0); + evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy); + evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy); evas_object_map_enable_set(obj, EINA_TRUE); - evas_object_map_set(obj, map); - evas_map_free(map); + evas_object_map_set(obj, wd->map); } static void @@ -903,9 +912,9 @@ marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord if (g_xx < 0) g_xx = 0; g_yy = wd->pan_y / wd->tsize; if (g_yy < 0) g_yy = 0; - g_ww = ow / wd->tsize + 1; + g_ww = (ow / wd->tsize) + 1; if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1; - g_hh = oh / wd->tsize + 1; + g_hh = (oh / wd->tsize) + 1; if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1; //hide groups no more displayed @@ -921,6 +930,12 @@ marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord } } + if (!wd->marker_zoom) + { + g_ww = 0; + g_hh = 0; + } + for (y = g_yy; y <= g_yy + g_hh; y++) { for (x = g_xx; x <= g_xx + g_ww; x++) @@ -1168,17 +1183,19 @@ _tile_downloaded(void *data, const char *file __UNUSED__, int status) static Grid * grid_create(Evas_Object *obj) { + ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); Grid *g; + if ((!wd) || (!wd->src)) return NULL; g = calloc(1, sizeof(Grid)); g->zoom = wd->zoom; g->tsize = wd->tsize; g->wd = wd; - if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL; - if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL; + if (g->zoom > wd->src->zoom_max) return NULL; + if (g->zoom < wd->src->zoom_min) return NULL; int size = pow(2.0, wd->zoom); g->gw = size; @@ -1204,7 +1221,7 @@ grid_load(Evas_Object *obj, Grid *g) Eina_Matrixsparse_Cell *cell; Grid_Item *gi; - if (!wd) return; + if ((!wd) || (!wd->src)) return; evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh); evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh); @@ -1287,16 +1304,16 @@ grid_load(Evas_Object *obj, Grid *g) } eina_iterator_free(it); - xx = wd->pan_x / size; + xx = wd->pan_x / size - 1; if (xx < 0) xx = 0; - yy = wd->pan_y / size; + yy = wd->pan_y / size - 1; if (yy < 0) yy = 0; - ww = ow / size + 1; + ww = ow / size + 2; if (xx + ww >= g->gw) ww = g->gw - xx - 1; - hh = oh / size + 1; + hh = oh / size + 2; if (yy + hh >= g->gh) hh = g->gh - yy - 1; for (y = yy; y <= yy + hh; y++) @@ -1357,7 +1374,7 @@ grid_load(Evas_Object *obj, Grid *g) snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y); - source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom); + source = wd->src->url_cb(obj, x, y, g->zoom); if ((!source) || (strlen(source)==0)) continue; eina_stringshare_replace(&gi->file, buf2); @@ -1436,24 +1453,6 @@ _smooth_update(Evas_Object *obj) } } -static void -_grid_raise(Grid *g) -{ - Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid); - Eina_Matrixsparse_Cell *cell; - - g->wd->size.w = g->w; - g->wd->size.h = g->h; - - EINA_ITERATOR_FOREACH(it, cell) - { - Grid_Item *gi = eina_matrixsparse_cell_data_get(cell); - evas_object_raise(gi->img); - //evas_object_raise(gi->txt); - } - eina_iterator_free(it); -} - static Eina_Bool _scr_timeout(void *data) { @@ -1525,34 +1524,54 @@ zoom_do(Evas_Object *obj) } static Eina_Bool +_zoom_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->zoom_timer = NULL; + wd->pinch.level = 1.0; + zoom_do(data); + evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL); + return ECORE_CALLBACK_CANCEL; +} + +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; if (!wd) return ECORE_CALLBACK_CANCEL; - t = ecore_loop_time_get(); - if (t >= wd->t_end) - t = 1.0; - else if (wd->t_end > wd->t_start) - t = (t - wd->t_start) / (wd->t_end - wd->t_start); + if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ; + else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05; else - t = 1.0; - if (wd->zoom_method == ZOOM_METHOD_IN) t = 1.0 + (t * t); - else if (wd->zoom_method == ZOOM_METHOD_OUT) t = 1.0 - (t * t); - else return ECORE_CALLBACK_CANCEL; - - if ((t >= 2.0) || (t <= 0.5)) { wd->zoom_animator = NULL; - wd->pinch.level = 1.0; zoom_do(obj); - evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL); + evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL); return ECORE_CALLBACK_CANCEL; } - else if (t != 1.0) + + if (wd->t >= 2.0) + { + wd->zoom_animator = NULL; + wd->pinch.level = 2.0; + if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer); + wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj); + return ECORE_CALLBACK_CANCEL; + } + else if (wd->t <= 0.5) + { + wd->zoom_animator = NULL; + wd->pinch.level = 0.5; + if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer); + wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj); + return ECORE_CALLBACK_CANCEL; + } + else if (wd->t != 1.0) { Evas_Coord x, y, w, h; float half_w, half_h; @@ -1561,7 +1580,7 @@ _zoom_anim(void *data) half_h = (float)h * 0.5; wd->pinch.cx = x + half_w; wd->pinch.cy = y + half_h; - wd->pinch.level = t; + wd->pinch.level = wd->t; if (wd->calc_job) ecore_job_del(wd->calc_job); wd->calc_job = ecore_job_add(_calc_job, wd); } @@ -1589,13 +1608,6 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf 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); @@ -1723,6 +1735,7 @@ _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__ Event *ev0; Event *ev; + if ((!wd) || (!wd->src)) return; ev = get_event_object(data, move->device); if (!ev) return; @@ -1746,8 +1759,8 @@ _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__ tt = wd->pinch.diff; wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis); t = (wd->pinch.diff * 0.01) + 1.0; - if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= map_sources_tab[wd->source].zoom_min) || - ((wd->zoom + (int)t - 1) >= map_sources_tab[wd->source].zoom_max) || + if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) || + ((wd->zoom + (int)t - 1) > wd->src->zoom_max) || (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN)) { wd->pinch.diff = tt; @@ -1790,7 +1803,7 @@ _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Event *ev0; Event *ev; Eina_Bool tp; - double t = 0.0; + int zoom = 0; wd->multi_count--; if (wd->calc_job) ecore_job_del(wd->calc_job); @@ -1801,9 +1814,9 @@ _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, } tp = wd->paused; wd->paused = EINA_TRUE; - if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01; - else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0); - elm_map_zoom_set(data, wd->zoom + (int)ceil(t)); + if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0); + else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0)); + elm_map_zoom_set(data, wd->zoom + zoom); wd->pinch.level = 1.0; wd->paused = tp; wd->rotate.a = 0.0; @@ -1837,6 +1850,8 @@ _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info; Evas_Coord x, y, w, h; float half_w, half_h; + + if (!wd) return; evas_object_geometry_get(data, &x, &y, &w, &h); half_w = (float)w * 0.5; half_h = (float)h * 0.5; @@ -1845,21 +1860,27 @@ _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi if (ev->z > 0) { wd->zoom_method = ZOOM_METHOD_OUT; - wd->wheel_zoom -= 0.1; + wd->wheel_zoom -= 0.05; 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; + wd->wheel_zoom += 0.2; if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX; } + if (!wd->paused) + { 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); + } + + if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer); + wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data); } @@ -1881,12 +1902,22 @@ _wheel_timer_cb(void *data) Widget_Data *wd = elm_widget_data_get(data); int zoom; - wd->wheel_timer = NULL; + if (!wd) + { + wd->wheel_timer = NULL; + return ECORE_CALLBACK_CANCEL; + } 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; + else + { + wd->wheel_timer = NULL; + return ECORE_CALLBACK_CANCEL; + } + wd->mode = ELM_MAP_ZOOM_MODE_MANUAL; elm_map_zoom_set(data, wd->zoom + zoom); wd->wheel_zoom = 0.0; + wd->wheel_timer = NULL; return ECORE_CALLBACK_CANCEL; } @@ -1980,15 +2011,12 @@ _del_hook(Evas_Object *obj) } } + if (wd->map) evas_map_free(wd->map); + if (wd->source_names) free(wd->source_names); if (wd->calc_job) ecore_job_del(wd->calc_job); if (wd->scr_timer) ecore_timer_del(wd->scr_timer); if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator); if (wd->long_timer) ecore_timer_del(wd->long_timer); - if ((wd->m) && (wd->m->api)) - { - Mod_Api *api = wd->m->api; - if (api->obj_unhook) api->obj_unhook(obj); - } if (wd->user_agent) eina_stringshare_del(wd->user_agent); if (wd->ua) eina_hash_free(wd->ua); @@ -2088,11 +2116,12 @@ _calc_job(void *data) Widget_Data *wd = data; Evas_Coord minw, minh; + if (!wd) return; minw = wd->size.w; minh = wd->size.h; if (wd->resized) { - wd->resized = 0; + wd->resized = EINA_FALSE; if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) { double tz = wd->zoom; @@ -2193,7 +2222,7 @@ _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) if (!sd) return; evas_object_geometry_get(obj, NULL, NULL, &ow, &oh); if ((ow == w) && (oh == h)) return; - sd->wd->resized = 1; + sd->wd->resized = EINA_TRUE; if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job); sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd); } @@ -2210,7 +2239,7 @@ _pan_calculate(Evas_Object *obj) rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh); EINA_LIST_FOREACH(sd->wd->grids, l, g) { - if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g); + if ((sd->wd->pinch.level == 1.0) || (sd->wd->pinch.level == 0.5)) grid_load(sd->wd->obj, g); grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh); marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh); if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh); @@ -2578,7 +2607,7 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty { ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); - double zoom; + int zoom; Evas_Coord x = 0; Evas_Coord y = 0; Evas_Coord step_x = 0; @@ -2630,16 +2659,14 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty } else if (!strcmp(ev->keyname, "KP_Add")) { - zoom = elm_map_zoom_get(obj); - zoom += 1; + zoom = elm_map_zoom_get(obj) + 1; elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL); elm_map_zoom_set(obj, zoom); return EINA_TRUE; } else if (!strcmp(ev->keyname, "KP_Subtract")) { - zoom = elm_map_zoom_get(obj); - zoom -= 1; + zoom = elm_map_zoom_get(obj) - 1; elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL); elm_map_zoom_set(obj, zoom); return EINA_TRUE; @@ -2721,7 +2748,7 @@ cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned attrs = eina_simple_xml_tag_attributes_find(value, length); if (attrs) { - if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME; + if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME; else dump->id = NAME_XML_NONE; eina_simple_xml_attributes_parse @@ -2942,7 +2969,7 @@ _utils_convert_name(const Evas_Object *obj, int method, char *address, double lo char *source; int fd; - if (!wd) return NULL; + if ((!wd) || (!wd->src)) return NULL; Elm_Map_Name *name = ELM_NEW(Elm_Map_Name); if (!name) return NULL; @@ -2974,7 +3001,7 @@ _utils_convert_name(const Evas_Object *obj, int method, char *address, double lo name->lon = lon; name->lat = lat; - source = map_sources_tab[wd->source].name_url_cb(wd->obj, method, address, lon, lat); + source = wd->src->name_url_cb(wd->obj, method, address, lon, lat); INF("name url = %s", source); wd->names = eina_list_append(wd->names, name); @@ -3040,11 +3067,13 @@ elm_map_add(Evas_Object *parent) evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj); elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce); + source_init(obj); wd->obj = obj; + wd->map = evas_map_new(4); + if (!wd->map) return NULL; wd->markers_max_num = 30; - wd->source = ELM_MAP_SOURCE_MAPNIK; wd->pinch.level = 1.0; evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj); @@ -3101,28 +3130,23 @@ elm_map_add(Evas_Object *parent) evas_object_show(wd->rect); evas_object_color_set(wd->rect, 0, 0, 0, 0); - wd->zoom = -1; wd->mode = ELM_MAP_ZOOM_MODE_MANUAL; wd->id = ((int)getpid() << 16) | idnum; idnum++; wd->tsize = 256; - edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh); evas_object_size_hint_min_set(obj, minw, minh); + wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart); + wd->paused = EINA_TRUE; elm_map_zoom_set(obj, 0); wd->paused = EINA_FALSE; - _sizing_eval(obj); - wd->calc_job = ecore_job_add(_calc_job, wd); - - wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj)); - evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart); - // TODO: convert Elementary to subclassing of Evas_Smart_Class // TODO: and save some bytes, making descriptions per-class and not instance! evas_object_smart_callbacks_descriptions_set(obj, _signals); @@ -3131,6 +3155,7 @@ elm_map_add(Evas_Object *parent) { ERR("Ecore must be built with curl support for the map widget!"); } + return obj; } @@ -3149,31 +3174,29 @@ elm_map_zoom_set(Evas_Object *obj, int zoom) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - Eina_List *l, *lr; + Eina_List *l; Grid *g, *g_zoom = NULL; Evas_Coord rx, ry, rw, rh; Evas_Object *p; Elm_Map_Route *r; - int z; - int zoom_changed = 0, started = 0; + int z = 0, zoom_changed = 0, started = 0; - if ((!wd) || (wd->zoom_animator)) return; + if ((!wd) || (!wd->src) || (wd->zoom_animator)) return; if (zoom < 0 ) zoom = 0; - if (zoom > map_sources_tab[wd->source].zoom_max) - zoom = map_sources_tab[wd->source].zoom_max; - if (zoom < map_sources_tab[wd->source].zoom_min) - zoom = map_sources_tab[wd->source].zoom_min; + if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max; + if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min; if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT; else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN; else wd->zoom_method = ZOOM_METHOD_NONE; + if (wd->zoom != zoom ) zoom_changed = 1; wd->zoom = zoom; wd->size.ow = wd->size.w; wd->size.oh = wd->size.h; elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry); elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh); - EINA_LIST_FOREACH(wd->route, lr, r) + EINA_LIST_FOREACH(wd->route, l, r) { if (r) { @@ -3184,12 +3207,7 @@ elm_map_zoom_set(Evas_Object *obj, int zoom) } } - if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL) - { - wd->size.nw = pow(2.0, wd->zoom) * wd->tsize; - wd->size.nh = pow(2.0, wd->zoom) * wd->tsize; - } - else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT) + if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) { int p2w, p2h; int cumulw, cumulh; @@ -3212,56 +3230,21 @@ elm_map_zoom_set(Evas_Object *obj, int zoom) } p2h--; - if (p2w < p2h) - z = p2w; - else - z = p2h; - - wd->zoom = z; - wd->size.nw = pow(2.0, wd->zoom) * wd->tsize; - wd->size.nh = pow(2.0, wd->zoom) * wd->tsize; - } - else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL) - { - int p2w, p2h; - int cumulw, cumulh; - - cumulw = wd->tsize; - p2w = 0; - while (cumulw <= rw) + if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT) { - p2w++; - cumulw *= 2; + if (p2w < p2h) z = p2w; + else z = p2h; } - p2w--; - - cumulh = wd->tsize; - p2h = 0; - while (cumulh <= rh) + else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL) { - p2h++; - cumulh *= 2; + if (p2w > p2h) z = p2w; + else z = p2h; } - p2h--; - - if (p2w > p2h) - z = p2w; - else - z = p2h; - wd->zoom = z; - wd->size.nw = pow(2.0, wd->zoom) * wd->tsize; - wd->size.nh = pow(2.0, wd->zoom) * wd->tsize; } + wd->size.nw = pow(2.0, wd->zoom) * wd->tsize; + wd->size.nh = pow(2.0, wd->zoom) * wd->tsize; - EINA_LIST_FOREACH(wd->grids, l, g) - { - if (g->zoom == wd->zoom) - { - _grid_raise(g); - goto done; - } - } g = grid_create(obj); if (g) { @@ -3282,10 +3265,8 @@ elm_map_zoom_set(Evas_Object *obj, int zoom) free(g); } } -done: - wd->t_start = ecore_loop_time_get(); - wd->t_end = wd->t_start + _elm_config->zoom_friction; + wd->t = 1.0; if ((wd->size.w > 0) && (wd->size.h > 0)) { wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow; @@ -3296,6 +3277,7 @@ done: 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; @@ -3304,6 +3286,8 @@ done: if (wd->paused) { zoom_do(obj); + if (wd->calc_job) ecore_job_del(wd->calc_job); + wd->calc_job = ecore_job_add(_calc_job, wd); } else { @@ -3315,26 +3299,14 @@ done: started = 1; } } - if (wd->zoom_animator) - { - if (!_zoom_anim(obj)) - { - ecore_animator_del(wd->zoom_animator); - wd->zoom_animator = NULL; - } - } - if (wd->calc_job) ecore_job_del(wd->calc_job); - wd->calc_job = ecore_job_add(_calc_job, wd); + if (!wd->paused) { - if (started) - evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL); - if (!wd->zoom_animator) - evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL); + if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL); + if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL); } - if (zoom_changed) - evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL); + if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL); } /** @@ -3350,13 +3322,13 @@ done: * * @ingroup Map */ -EAPI double +EAPI int elm_map_zoom_get(const Evas_Object *obj) { - ELM_CHECK_WIDTYPE(obj, widtype) 1.0; + ELM_CHECK_WIDTYPE(obj, widtype) 0; Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return 1.0; + if (!wd) return 0; return wd->zoom; } @@ -3368,7 +3340,7 @@ elm_map_zoom_get(const Evas_Object *obj) * elm_map_zoom_set() and will stay at that level until changed by code * or until zoom mode is changed. This is the default mode. * The Automatic modes will allow the map object to automatically - * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will + * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT will * adjust zoom so the map fits inside the scroll frame with no pixels * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but * ensure no pixels within the frame are left unfilled. Do not forget that the valid sizes are 2^zoom, consequently the map may be smaller than the scroller view. @@ -3387,9 +3359,11 @@ elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode) if (!wd) return; if (wd->mode == mode) return; wd->mode = mode; + + if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) { - double tz = wd->zoom; - wd->zoom = 0.0; + int tz = wd->zoom; + wd->zoom = 0; elm_map_zoom_set(wd->obj, tz); } } @@ -3545,7 +3519,7 @@ elm_map_paused_set(Evas_Object *obj, Eina_Bool paused) { if (wd->zoom_animator) { - ecore_animator_del(wd->zoom_animator); + if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator); wd->zoom_animator = NULL; zoom_do(obj); evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL); @@ -3664,15 +3638,11 @@ elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int s 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) - if ((wd->m) && (wd->m->api)) - { - Mod_Api *api = wd->m->api; - if ((api) && (api->obj_convert_coord_into_geo)) - if (api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)) return; - } + int zoom = floor(log(size / 256) / log(2)); + if ((wd->src) && (wd->src->coord_into_geo)) + { + if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return; + } if (lon) { @@ -3704,20 +3674,16 @@ elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double 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) - if ((wd->m) && (wd->m->api)) - { - Mod_Api *api = wd->m->api; - if ((api) && (api->obj_convert_geo_into_coord)) - if (api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)) return; - } + int zoom = floor(log(size / 256) / log(2)); + if ((wd->src) && (wd->src->geo_into_coord)) + { + if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return; + } if (x) *x = floor((lon + 180.0) / 360.0 * size); if (y) - *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size); + *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size); } /** @@ -4123,7 +4089,6 @@ elm_map_markers_list_show(Eina_List *markers) Widget_Data *wd; EINA_SAFETY_ON_NULL_RETURN(markers); - EINA_LIST_FOREACH(markers, l, marker) { wd = marker->wd; @@ -4145,7 +4110,7 @@ elm_map_markers_list_show(Eina_List *markers) lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude; elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh); - for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--) + for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--) { Evas_Coord size = pow(2.0, zoom)*wd->tsize; elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc); @@ -4464,86 +4429,104 @@ elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc } /** + * Get the list of the sources. + * + * @param obj The map object + * @return sources the source list + * + * @ingroup Map + */ + +EAPI const char ** +elm_map_source_names_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + + if (!wd) return NULL; + return wd->source_names; +} + +/** * Set the source of the map. * * Elm_Map retrieves the image which composed the map from a web service. This web service can * be set with this method. A different service can return a different maps with different * information and it can use different zoom value. * - * @param clas the group class + * @param obj the map object * @param source the new source * * @ingroup Map */ EAPI void -elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source) +elm_map_source_name_set(Evas_Object *obj, const char *source_name) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); + Map_Sources_Tab *s; + Eina_List *l; Grid *grid; int zoom; - Mod_Api *api = NULL; if (!wd) return; - _elm_config_sub_init(); - if (source == ELM_MAP_SOURCE_MODULE) - { - module(obj); - api = wd->m->api; - if ((api) && (api->obj_hook)) api->obj_hook(obj); - } - - if (wd->source == source ) return; - if (!map_sources_tab[source].url_cb) return; + if ((wd->src) && (!strcmp(wd->src->name, source_name))) return; + if ((wd->src) && (!wd->src->url_cb)) return; EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid); - - wd->source = source; + EINA_LIST_FOREACH(wd->map_sources_tab, l, s) + { + if (!strcmp(s->name, source_name)) + { + wd->src = s; + break; + } + } zoom = wd->zoom; wd->zoom = -1; - if (map_sources_tab[wd->source].zoom_max < zoom) - zoom = map_sources_tab[wd->source].zoom_max; - if (map_sources_tab[wd->source].zoom_min > zoom) - zoom = map_sources_tab[wd->source].zoom_min; + if (wd->src->zoom_max < zoom) + zoom = wd->src->zoom_max; + if (wd->src->zoom_min > zoom) + zoom = wd->src->zoom_min; elm_map_zoom_set(obj, zoom); } /** - * Set the source of the route. + * Get the name of a source. * - * @param clas the group class - * @param source the new source + * @param source the source + * @return Returns the name of the source * * @ingroup Map */ -EAPI void -elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source) +EAPI const char * +elm_map_source_name_get(const Evas_Object *obj) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - wd->source = source; + if ((!wd) || (!wd->src)) return NULL; + return wd->src->name; } /** - * Get the current source + * Set the source of the route. * - * @param obj the map object - * @return Returns the maximum zoom of the source + * @param clas the group class + * @param source the new source * * @ingroup Map */ -EAPI Elm_Map_Sources -elm_map_source_get(const Evas_Object *obj) +EAPI void +elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source) { - ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK; + ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return ELM_MAP_SOURCE_MAPNIK; - return wd->source; + if (!wd) return; + wd->route_source = source; } /** @@ -4565,32 +4548,6 @@ elm_map_route_source_get(const Evas_Object *obj) } /** - * Set the API of a custom source. - * - * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7). - * - * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7)) - * @param name the name of the source - * @param zoom_min the minimum zoom of the source, must be >= 0 - * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX - * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded. - * - * @ingroup Map - */ -EAPI void -elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb, ElmMapRouteSourceURLFunc route_url_cb, ElmMapNameSourceURLFunc name_url_cb) -{ - EINA_SAFETY_ON_NULL_RETURN(name); - EINA_SAFETY_ON_NULL_RETURN(url_cb); - map_sources_tab[source].name = name; - map_sources_tab[source].zoom_min = zoom_min; - map_sources_tab[source].zoom_max = zoom_max; - map_sources_tab[source].url_cb = url_cb; - map_sources_tab[source].route_url_cb = route_url_cb; - map_sources_tab[source].name_url_cb = name_url_cb; -} - -/** * Get the maximum zoom of the source. * * @param source the source @@ -4599,9 +4556,13 @@ elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom * @ingroup Map */ EAPI int -elm_map_source_zoom_max_get(Elm_Map_Sources source) +elm_map_source_zoom_max_get(const Evas_Object *obj) { - return map_sources_tab[source].zoom_max; + ELM_CHECK_WIDTYPE(obj, widtype) 18; + Widget_Data *wd = elm_widget_data_get(obj); + + if ((!wd) || (!wd->src)) return 18; + return wd->src->zoom_max; } /** @@ -4613,23 +4574,13 @@ elm_map_source_zoom_max_get(Elm_Map_Sources source) * @ingroup Map */ EAPI int -elm_map_source_zoom_min_get(Elm_Map_Sources source) +elm_map_source_zoom_min_get(const Evas_Object *obj) { - return map_sources_tab[source].zoom_min; -} + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); -/** - * Get the name of a source. - * - * @param source the source - * @return Returns the name of the source - * - * @ingroup Map - */ -EAPI const char * -elm_map_source_name_get(Elm_Map_Sources source) -{ - return map_sources_tab[source].name; + if ((!wd) || (!wd->src)) return 0; + return wd->src->zoom_min; } /** @@ -4663,7 +4614,7 @@ elm_map_user_agent_set(Evas_Object *obj, const char *user_agent) * @ingroup Map */ EAPI const char * -elm_map_user_agent_get(Evas_Object *obj) +elm_map_user_agent_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); @@ -4698,12 +4649,13 @@ elm_map_route_add(Evas_Object *obj, { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); - - if (!wd) return NULL; char buf[PATH_MAX]; char *source; char *type_name = NULL; int fd; + + if ((!wd) || (!wd->src)) return NULL; + Elm_Map_Route *route = ELM_NEW(Elm_Map_Route); if (!route) return NULL; @@ -4759,7 +4711,7 @@ elm_map_route_add(Evas_Object *obj, break; } - source = map_sources_tab[wd->source].route_url_cb(obj, type_name, method, flon, flat, tlon, tlat); + source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat); INF("route url = %s", source); wd->route = eina_list_append(wd->route, route); @@ -4860,7 +4812,7 @@ elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a) * @ingroup Map */ EAPI void -elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a) +elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a) { EINA_SAFETY_ON_NULL_RETURN(route); if (r) *r = route->color.r; @@ -4878,7 +4830,7 @@ elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a) * @ingroup Map */ EAPI double -elm_map_route_distance_get(Elm_Map_Route *route) +elm_map_route_distance_get(const Elm_Map_Route *route) { EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0); return route->info.distance; @@ -4894,7 +4846,7 @@ elm_map_route_distance_get(Elm_Map_Route *route) */ EAPI const char* -elm_map_route_node_get(Elm_Map_Route *route) +elm_map_route_node_get(const Elm_Map_Route *route) { EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); return route->info.nodes; @@ -4910,7 +4862,7 @@ elm_map_route_node_get(Elm_Map_Route *route) */ EAPI const char* -elm_map_route_waypoint_get(Elm_Map_Route *route) +elm_map_route_waypoint_get(const Elm_Map_Route *route) { EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); return route->info.waypoints; @@ -4925,7 +4877,7 @@ elm_map_route_waypoint_get(Elm_Map_Route *route) * @ingroup Map */ EAPI const char * -elm_map_name_address_get(Elm_Map_Name *name) +elm_map_name_address_get(const Elm_Map_Name *name) { EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); return name->address; @@ -4943,7 +4895,7 @@ elm_map_name_address_get(Elm_Map_Name *name) * @ingroup Map */ EAPI void -elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat) +elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat) { EINA_SAFETY_ON_NULL_RETURN(name); if (lon) *lon = name->lon; @@ -5103,59 +5055,6 @@ _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom) return strdup(buf); } -static char * -_custom1_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_custom2_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_custom3_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_custom4_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_custom5_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_custom6_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__) -{ - return strdup(""); -} - -static char * -_module_url_cb(Evas_Object *obj, int x, int y, int zoom) -{ - char *buf = NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE) - if ((wd->m) && (wd->m->api)) - { - Mod_Api *api = wd->m->api; - if ((api) && (api->obj_url_request)) buf = api->obj_url_request(obj, x, y, zoom); - } - - if (!buf) buf = strdup(""); - - return buf; -} - static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat) { char buf[PATH_MAX]; @@ -5192,43 +5091,6 @@ static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int metho } */ -static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} - -static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} - -static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} - -static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} - -static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} - -static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - return strdup(""); -} -/* -static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) -{ - // TODO: make example route module - return strdup(""); -} -*/ - static char * _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat) { @@ -5257,39 +5119,3 @@ _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double l return strdup(buf); } -static char * -_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - -static char * -_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - -static char * -_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - -static char * -_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - -static char * -_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - -static char * -_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) -{ - return strdup(""); -} - diff --git a/src/modules/test_map/mod.c b/src/modules/test_map/mod.c index 8b45ede..8466aa3 100644 --- a/src/modules/test_map/mod.c +++ b/src/modules/test_map/mod.c @@ -1,50 +1,77 @@ -#include +#include "Elementary.h" +#include #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif -EAPI int -elm_modapi_init(void *m __UNUSED__) -{ - return 1; // succeed always +EAPI char * +map_module_source_get(void) +{ + return strdup("test_map"); } -EAPI int -elm_modapi_shutdown(void *m __UNUSED__) +EAPI int +map_module_zoom_min_get(void) { - return 1; // succeed always + return 0; } -EAPI Eina_Bool -obj_hook(Evas_Object *obj __UNUSED__) +EAPI int +map_module_zoom_max_get(void) { - return EINA_TRUE; + return 18; } -EAPI Eina_Bool -obj_unhook(Evas_Object *obj __UNUSED__) -{ - return EINA_TRUE; +EAPI char * +map_module_url_get(Evas_Object *obj __UNUSED__, int x, int y, int zoom) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png", + zoom, x, y); + return strdup(buf); } -EAPI Eina_Bool -obj_convert_geo_into_coord(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int size __UNUSED__, int *x __UNUSED__, int *y __UNUSED__) +EAPI int +map_module_route_source_get(void) +{ + return 0; +} + +EAPI char * +map_module_route_url_get(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) +{ + return strdup(""); +} + +EAPI char * +map_module_name_url_get(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) +{ + return strdup(""); +} + +EAPI Eina_Bool +map_module_geo_into_coord(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int size __UNUSED__, int *x __UNUSED__, int *y __UNUSED__) { return EINA_FALSE; } EAPI Eina_Bool -obj_convert_coord_into_geo(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, int x __UNUSED__, int y __UNUSED__, int size __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__) +map_module_coord_into_geo(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, int x __UNUSED__, int y __UNUSED__, int size __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__) { return EINA_FALSE; } -EAPI char* -obj_url_request(Evas_Object *obj __UNUSED__, int x, int y, int zoom) +static Eina_Bool +_module_init(void) { - char buf[PATH_MAX]; - snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png", - zoom, x, y); - return strdup(buf); + return EINA_TRUE; } +static void +_module_shutdown(void) +{ +} + +EINA_MODULE_INIT(_module_init); +EINA_MODULE_SHUTDOWN(_module_shutdown); + -- 2.7.4