summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBluezery <ohpowel@gmail.com>2012-03-22 10:40:04 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-22 10:40:04 +0000
commit7cac236269074945679e69e1fb2eb838508236f2 (patch)
tree5a2165190b94963d3d6ec1567b5eaa5913882654 /src/bin
parentfde918c79ff5dda1acf6f41fe286921687c24075 (diff)
From: Bluezery <ohpowel@gmail.com>
Subject: [E-devel] [Patch][elm_map] Add line, polygon, circle, scale overlay This patch adds new overlay APIs (line, polygon, circle, scale) for elm_map. These overlays are adhered to map even though zooming, panning. You can test these by doing "elementary_test --> click mouse right --> overlay" SVN revision: 69562
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_map.c317
1 files changed, 211 insertions, 106 deletions
diff --git a/src/bin/test_map.c b/src/bin/test_map.c
index 5ed2f8d73..bf1b0d2fe 100644
--- a/src/bin/test_map.c
+++ b/src/bin/test_map.c
@@ -38,6 +38,11 @@ static Elm_Map_Overlay *route_start, *route_end, *route_clas;
38static Elm_Map_Overlay *bubble_img; 38static Elm_Map_Overlay *bubble_img;
39static Elm_Map_Overlay *bubble_parking; 39static Elm_Map_Overlay *bubble_parking;
40static Elm_Map_Overlay *route_ovl; 40static Elm_Map_Overlay *route_ovl;
41static Elm_Map_Overlay *line_start, *line_end, *line;
42static Elm_Map_Overlay *poly;
43static Elm_Map_Overlay *circle;
44static Elm_Map_Overlay *scale;
45static Eina_List *poly_points;
41 46
42static Evas_Object *menu, *fs_win; 47static Evas_Object *menu, *fs_win;
43static Elm_Map_Route *route; 48static Elm_Map_Route *route;
@@ -81,6 +86,109 @@ _route_icon_get(Evas_Object *obj)
81 return icon; 86 return icon;
82} 87}
83 88
89static Evas_Object *
90_box_get(Evas_Object *obj, Overlay_Data *data, Elm_Map_Overlay *ovl)
91{
92 Evas_Object *bx, *img, *label;
93 double lon, lat;
94 char buf[256];
95 bx = elm_box_add(obj);
96 evas_object_show(bx);
97
98 img = evas_object_image_add(evas_object_evas_get(obj));
99 evas_object_image_file_set(img, data->file, NULL);
100 evas_object_image_filled_set(img, EINA_TRUE);
101 evas_object_size_hint_min_set(img, 64, 64);
102 evas_object_show(img);
103 elm_box_pack_end(bx, img);
104
105 label = elm_label_add(bx);
106 elm_map_overlay_region_get(ovl, &lon, &lat);
107 snprintf(buf, sizeof(buf), "%0.4lf %0.4lf", lon, lat);
108 elm_object_text_set(label, buf);
109 evas_object_show(label);
110 elm_box_pack_end(bx, label);
111 return bx;
112}
113
114static Evas_Object *
115_label_get(Evas_Object *obj)
116{
117 Evas_Object *label;
118 label = elm_label_add(obj);
119 elm_object_text_set(label, "Here is a parking lot.");
120 return label;
121}
122
123static Evas_Object *
124_icon_get(Evas_Object *obj, Overlay_Data *data)
125{
126 Evas_Object *icon = elm_icon_add(obj);
127 elm_icon_file_set(icon, data->file, NULL);
128 evas_object_show(icon);
129
130 return icon;
131}
132
133static void
134_overlay_hide(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
135{
136 elm_map_overlay_hide_set(data, EINA_TRUE);
137}
138
139static void
140_overlay_pause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
141{
142 elm_map_overlay_paused_set(data, EINA_TRUE);
143}
144
145static void
146_overlay_unpause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
147{
148 elm_map_overlay_paused_set(data, EINA_FALSE);
149}
150
151static void
152_overlay_show(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
153{
154 elm_map_overlay_show(data);
155}
156
157static Evas_Object *
158_btn_box_get(Evas_Object *obj, Elm_Map_Overlay *ovl)
159{
160 Evas_Object *bx, *btn, *btn2, *btn3, *btn4;
161 bx = elm_box_add(obj);
162 elm_box_horizontal_set(bx, EINA_TRUE);
163 evas_object_show(bx);
164
165 btn = elm_button_add(bx);
166 elm_object_text_set(btn, "Hide");
167 evas_object_smart_callback_add(btn, "clicked", _overlay_hide, ovl);
168 evas_object_show(btn);
169 elm_box_pack_end(bx, btn);
170
171 btn2 = elm_button_add(bx);
172 elm_object_text_set(btn2, "Pause");
173 evas_object_smart_callback_add(btn2, "clicked", _overlay_pause, ovl);
174 evas_object_show(btn2);
175 elm_box_pack_end(bx, btn2);
176
177 btn3 = elm_button_add(bx);
178 elm_object_text_set(btn3, "Unpause");
179 evas_object_smart_callback_add(btn3, "clicked", _overlay_unpause, ovl);
180 evas_object_show(btn3);
181 elm_box_pack_end(bx, btn3);
182
183 btn4 = elm_button_add(bx);
184 elm_object_text_set(btn4, "Show");
185 evas_object_smart_callback_add(btn4, "clicked", _overlay_show, ovl);
186 evas_object_show(btn4);
187 elm_box_pack_end(bx, btn4);
188
189 return bx;
190}
191
84static void 192static void
85_bubble_parking_follow(Evas_Object *map) 193_bubble_parking_follow(Evas_Object *map)
86{ 194{
@@ -316,7 +424,16 @@ _map_name_loaded_fail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
316} 424}
317 425
318static void 426static void
319map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 427_src_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
428{
429 Map_Source *s = data;
430
431 if (!s) return;
432 elm_map_source_set(s->map, s->type, s->source_name);
433}
434
435static void
436_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
320{ 437{
321 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); 438 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
322 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12); 439 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12);
@@ -324,7 +441,7 @@ map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUS
324} 441}
325 442
326static void 443static void
327map_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 444_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
328{ 445{
329 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); 446 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
330 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12); 447 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12);
@@ -504,115 +621,74 @@ _zoom_max_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED
504} 621}
505 622
506static void 623static void
507src_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 624_line_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
508{
509 Map_Source *s = data;
510
511 if (!s) return;
512 elm_map_source_set(s->map, s->type, s->source_name);
513}
514
515static Evas_Object *
516_box_get(Evas_Object *obj, Overlay_Data *data, Elm_Map_Overlay *ovl)
517{ 625{
518 Evas_Object *bx, *img, *label;
519 double lon, lat; 626 double lon, lat;
520 char buf[256];
521 bx = elm_box_add(obj);
522 evas_object_show(bx);
523 627
524 img = evas_object_image_add(evas_object_evas_get(obj)); 628 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
525 evas_object_image_file_set(img, data->file, NULL); 629 printf("line marker: %d %d %lf %lf\n", down_x, down_y, lon, lat);
526 evas_object_image_filled_set(img, EINA_TRUE); 630 if (line_start && line_end)
527 evas_object_size_hint_min_set(img, 64, 64); 631 {
528 evas_object_show(img); 632 elm_map_overlay_del(line_start);
529 elm_box_pack_end(bx, img); 633 elm_map_overlay_del(line_end);
634 elm_map_overlay_del(line);
635 line_start = NULL;
636 line_end = NULL;
637 line = NULL;
638 }
639 if (!line_start) line_start = elm_map_overlay_add(data, lon, lat);
640 else if (!line_end) line_end = elm_map_overlay_add(data, lon, lat);
530 641
531 label = elm_label_add(bx); 642 if (line_start && line_end)
532 elm_map_overlay_region_get(ovl, &lon, &lat); 643 {
533 snprintf(buf, sizeof(buf), "%0.4lf %0.4lf", lon, lat); 644 double flon, flat, tlon, tlat;
534 elm_object_text_set(label, buf); 645 elm_map_overlay_region_get(line_start, &flon, &flat);
535 evas_object_show(label); 646 elm_map_overlay_region_get(line_end, &tlon, &tlat);
536 elm_box_pack_end(bx, label); 647 line = elm_map_overlay_line_add(data, flon, flat, tlon, tlat);
537 return bx; 648 printf("line add: (%lf, %lf) --> (%lf, %lf)\n", flon, flat, tlon, tlat);
649 }
538} 650}
539 651
540static void 652static void
541_overlay_hide(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 653_poly_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
542{ 654{
543 elm_map_overlay_hide_set(data, EINA_TRUE); 655 double lon, lat;
544}
545 656
546static void 657 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
547_overlay_pause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 658 printf("%d %d %lf %lf\n", down_x, down_y, lon, lat);
548{
549 elm_map_overlay_paused_set(data, EINA_TRUE);
550}
551 659
552static void 660 if (!poly) poly = elm_map_overlay_polygon_add(data);
553_overlay_unpause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 661 poly_points = eina_list_append(poly_points,
554{ 662 elm_map_overlay_add(data, lon, lat));
555 elm_map_overlay_paused_set(data, EINA_FALSE); 663 elm_map_overlay_polygon_region_add(poly, lon, lat);
556} 664}
557 665
558static void 666static void
559_overlay_show(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 667_poly_clear(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
560{ 668{
561 elm_map_overlay_show(data); 669 Elm_Map_Overlay *ovl;
670 if (poly) elm_map_overlay_del(poly);
671 EINA_LIST_FREE(poly_points, ovl) elm_map_overlay_del(ovl);
672 poly = NULL;
673 poly_points = NULL;
562} 674}
563 675
564static Evas_Object * 676static void
565_btn_box_get(Evas_Object *obj, Elm_Map_Overlay *ovl) 677_circle_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
566{ 678{
567 Evas_Object *bx, *btn, *btn2, *btn3, *btn4; 679 double radius = 100;
568 bx = elm_box_add(obj); 680 double lon, lat;
569 elm_box_horizontal_set(bx, EINA_TRUE);
570 evas_object_show(bx);
571
572 btn = elm_button_add(bx);
573 elm_object_text_set(btn, "Hide");
574 evas_object_smart_callback_add(btn, "clicked", _overlay_hide, ovl);
575 evas_object_show(btn);
576 elm_box_pack_end(bx, btn);
577
578 btn2 = elm_button_add(bx);
579 elm_object_text_set(btn2, "Pause");
580 evas_object_smart_callback_add(btn2, "clicked", _overlay_pause, ovl);
581 evas_object_show(btn2);
582 elm_box_pack_end(bx, btn2);
583
584 btn3 = elm_button_add(bx);
585 elm_object_text_set(btn3, "Unpause");
586 evas_object_smart_callback_add(btn3, "clicked", _overlay_unpause, ovl);
587 evas_object_show(btn3);
588 elm_box_pack_end(bx, btn3);
589
590 btn4 = elm_button_add(bx);
591 elm_object_text_set(btn4, "Show");
592 evas_object_smart_callback_add(btn4, "clicked", _overlay_show, ovl);
593 evas_object_show(btn4);
594 elm_box_pack_end(bx, btn4);
595
596 return bx;
597}
598 681
599static Evas_Object * 682 if (circle) elm_map_overlay_del(circle);
600_label_get(Evas_Object *obj) 683 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
601{ 684 circle = elm_map_overlay_circle_add(data, lon, lat, radius);
602 Evas_Object *label;
603 label = elm_label_add(obj);
604 elm_object_text_set(label, "Here is a parking lot.");
605 return label;
606} 685}
607 686
608static Evas_Object * 687static void
609_icon_get(Evas_Object *obj, Overlay_Data *data) 688_scale_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
610{ 689{
611 Evas_Object *icon = elm_icon_add(obj); 690 if (scale) elm_map_overlay_del(scale);
612 elm_icon_file_set(icon, data->file, NULL); 691 scale = elm_map_overlay_scale_add(data, down_x, down_y);
613 evas_object_show(icon);
614
615 return icon;
616} 692}
617 693
618static void 694static void
@@ -635,7 +711,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
635 ts[idx].map = data; 711 ts[idx].map = data;
636 ts[idx].type = ELM_MAP_SOURCE_TYPE_TILE; 712 ts[idx].type = ELM_MAP_SOURCE_TYPE_TILE;
637 ts[idx].source_name = strdup(tile_srcs[idx]); 713 ts[idx].source_name = strdup(tile_srcs[idx]);
638 elm_menu_item_add(menu, parent, "", tile_srcs[idx], src_set, &ts[idx]); 714 elm_menu_item_add(menu, parent, "", tile_srcs[idx], _src_set, &ts[idx]);
639 } 715 }
640 for (idx = 0; route_srcs[idx]; idx++) 716 for (idx = 0; route_srcs[idx]; idx++)
641 { 717 {
@@ -643,7 +719,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
643 rs[idx].map = data; 719 rs[idx].map = data;
644 rs[idx].type = ELM_MAP_SOURCE_TYPE_ROUTE; 720 rs[idx].type = ELM_MAP_SOURCE_TYPE_ROUTE;
645 rs[idx].source_name = strdup(route_srcs[idx]); 721 rs[idx].source_name = strdup(route_srcs[idx]);
646 elm_menu_item_add(menu, parent, "", route_srcs[idx], src_set, &rs[idx]); 722 elm_menu_item_add(menu, parent, "", route_srcs[idx], _src_set, &rs[idx]);
647 } 723 }
648 for (idx = 0; name_srcs[idx]; idx++) 724 for (idx = 0; name_srcs[idx]; idx++)
649 { 725 {
@@ -651,7 +727,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
651 ns[idx].map = data; 727 ns[idx].map = data;
652 ns[idx].type = ELM_MAP_SOURCE_TYPE_NAME; 728 ns[idx].type = ELM_MAP_SOURCE_TYPE_NAME;
653 ns[idx].source_name = strdup(name_srcs[idx]); 729 ns[idx].source_name = strdup(name_srcs[idx]);
654 elm_menu_item_add(menu, parent, "", name_srcs[idx], src_set, &ns[idx]); 730 elm_menu_item_add(menu, parent, "", name_srcs[idx], _src_set, &ns[idx]);
655 } 731 }
656} 732}
657 733
@@ -659,8 +735,8 @@ static void
659_submenu_move_add(void *data, Elm_Object_Item *parent) 735_submenu_move_add(void *data, Elm_Object_Item *parent)
660{ 736{
661 if ((!data) || (!parent)) return; 737 if ((!data) || (!parent)) return;
662 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", map_show_urmatt, data); 738 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", _show_urmatt, data);
663 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", map_bring_seoul, data); 739 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", _bring_seoul, data);
664 740
665} 741}
666 742
@@ -699,6 +775,17 @@ _submenu_track_add(void *data, Elm_Object_Item *parent)
699} 775}
700 776
701static void 777static void
778_submenu_ovl_add(void *data, Elm_Object_Item *parent)
779{
780 if ((!data) || (!parent)) return;
781 elm_menu_item_add(menu, parent, NULL, "Add line", _line_add, data);
782 elm_menu_item_add(menu, parent, NULL, "Add polygon", _poly_add, data);
783 elm_menu_item_add(menu, parent, NULL, "Clear polygon", _poly_clear, data);
784 elm_menu_item_add(menu, parent, NULL, "Add circle", _circle_add, data);
785 elm_menu_item_add(menu, parent, NULL, "Add scale", _scale_add, data);
786}
787
788static void
702_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) 789_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
703{ 790{
704 Evas_Event_Mouse_Down *down = event_info; 791 Evas_Event_Mouse_Down *down = event_info;
@@ -726,9 +813,11 @@ _map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event
726 _submenu_prop_add(data, menu_it); 813 _submenu_prop_add(data, menu_it);
727 menu_it = elm_menu_item_add(menu, NULL, "", "Track", NULL, NULL); 814 menu_it = elm_menu_item_add(menu, NULL, "", "Track", NULL, NULL);
728 _submenu_track_add(data, menu_it); 815 _submenu_track_add(data, menu_it);
816 menu_it = elm_menu_item_add(menu, NULL, "", "Overlay", NULL, NULL);
817 _submenu_ovl_add(data, menu_it);
729 818
730 elm_menu_move(menu, down->canvas.x, down->canvas.y); 819 elm_menu_move(menu, down->canvas.x, down->canvas.y);
731 evas_object_show(menu); 820 evas_object_show(menu);
732 } 821 }
733} 822}
734 823
@@ -791,25 +880,41 @@ _overlay_cb(void *data __UNUSED__, Evas_Object *map, void *ev)
791 Overlay_Data *od; 880 Overlay_Data *od;
792 Elm_Map_Overlay_Type type = elm_map_overlay_type_get(overlay); 881 Elm_Map_Overlay_Type type = elm_map_overlay_type_get(overlay);
793 882
794 if (type != ELM_MAP_OVERLAY_TYPE_DEFAULT) return; 883 if (type != ELM_MAP_OVERLAY_TYPE_GROUP &&
884 type != ELM_MAP_OVERLAY_TYPE_DEFAULT) return;
795 885
796 if (!bubble_img) bubble_img = elm_map_overlay_bubble_add(map); 886 if (!bubble_img) bubble_img = elm_map_overlay_bubble_add(map);
797 elm_map_overlay_bubble_follow(bubble_img, overlay); 887 elm_map_overlay_bubble_follow(bubble_img, overlay);
798 elm_map_overlay_bubble_content_clear(bubble_img); 888 elm_map_overlay_bubble_content_clear(bubble_img);
799 889
800 od = elm_map_overlay_data_get(overlay); 890 if (type == ELM_MAP_OVERLAY_TYPE_GROUP)
801 if (od) 891 {
802 elm_map_overlay_bubble_content_append(bubble_img, 892 Eina_List *l;
803 _box_get(map, od, overlay)); 893 Elm_Map_Overlay *memb;
804 elm_map_overlay_bubble_content_append(bubble_img, 894 Eina_List *members = elm_map_overlay_group_members_get(overlay);
805 _btn_box_get(map, overlay)); 895 printf("Group Members Num: %d\n", eina_list_count(members));
896 EINA_LIST_FOREACH(members, l, memb)
897 {
898 od = elm_map_overlay_data_get(memb);
899 if (od)
900 elm_map_overlay_bubble_content_append(bubble_img,
901 _box_get(map, od, memb));
902 }
903 }
904 else
905 {
906 od = elm_map_overlay_data_get(overlay);
907 if (od)
908 elm_map_overlay_bubble_content_append(bubble_img,
909 _box_get(map, od, overlay));
910 elm_map_overlay_bubble_content_append(bubble_img,
911 _btn_box_get(map, overlay));
912 }
806} 913}
807 914
808static void 915static void
809_parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl) 916_parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl)
810{ 917{
811 if (elm_map_overlay_type_get(ovl) != ELM_MAP_OVERLAY_TYPE_DEFAULT) return;
812
813 double lon, lat; 918 double lon, lat;
814 Evas_Coord x, y; 919 Evas_Coord x, y;
815 elm_map_overlay_region_get(ovl, &lon, &lat); 920 elm_map_overlay_region_get(ovl, &lon, &lat);