From 73f4df462c0cfaa01250c39950faad57a9fb73f5 Mon Sep 17 00:00:00 2001 From: Gustavo Lima Chaves Date: Thu, 1 Apr 2010 17:34:49 +0000 Subject: [PATCH] Elm_map exported as edje external. SVN revision: 47654 --- data/edje_externals/Makefile.am | 1 + data/edje_externals/ico_map.png | Bin 0 -> 2232 bytes data/edje_externals/icons.edc | 1 + src/edje_externals/Makefile.am | 1 + src/edje_externals/elm_map.c | 198 ++++++++++++++++++++++++++++++++++++++++ src/edje_externals/modules.inc | 1 + src/lib/Elementary.h.in | 8 +- 7 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 data/edje_externals/ico_map.png create mode 100644 src/edje_externals/elm_map.c diff --git a/data/edje_externals/Makefile.am b/data/edje_externals/Makefile.am index bdbe895..3d1e16e 100644 --- a/data/edje_externals/Makefile.am +++ b/data/edje_externals/Makefile.am @@ -17,6 +17,7 @@ ico_check.png \ ico_clock.png \ ico_fileselector.png \ ico_hoversel.png \ +ico_map.png \ ico_notepad.png \ ico_photocam.png \ ico_progressbar.png \ diff --git a/data/edje_externals/ico_map.png b/data/edje_externals/ico_map.png new file mode 100644 index 0000000000000000000000000000000000000000..1c8ca8b22e35018edb7487c6bc070438a4b3411b GIT binary patch literal 2232 zcmV;p2uJscP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igN4 z783|ZG`^Am00=lqL_t(o!{wK0Y+Th9$A9m=nKz!z_QYdjhd6ee#EnfBh|>gPvM5Vg zN(%y2MSM!BXw?d&Qo)C+DiW2dE_`4qQd=aFwkou=K--9&qy#XDNgSIb4za=Up0Pb% z#`es-<-Ysg>jy6oa8hXdrRtNeo^u+du|Qr!TsO3 z>#LC)uiqFL&t%bXS-oP}!kk|{`3LG7uSfAc^nePU%L{*R7H_}ujwL;B@6qPR{(3R{ z+NGRt-FokXl~tELvTxsgk(D)NYX86>GkKGE=`s=#jh17_dFJ^8EL**vP&9#IyJWI9 zt1H6nYO2+){Nfivt;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!-lb zBQrjDe_PxB4*~0v718i;`(UiFT21wjH*VX$A)rWum<~b+4jej$ncR$U=A@tdTS6j) zgXdVxIcL zD=FmATP++slZ9|{7Qm4RMwaC>3HskK+oLj zRlxgKMX5VF($VJ0p#5I^SW{|rLM(fVIJ3w645- z?T#fS)tmHCVTGawA{vVBdYBrizxNK_x%$%Vr_|eZ4Ki90000 + +#include "private.h" + +typedef struct _Elm_Params_Map +{ + const char *map_source; + const char *zoom_mode; + double zoom; + Eina_Bool zoom_set:1; +} Elm_Params_Map; + +static const char *zoom_choices[] = {"manual", "auto fit", "auto fill"}; + +static const char *source_choices[] = + {"Mapnik", "Osmarender", "Cycle Map", "Maplint", + "Custom 1", "Custom 2", "Custom 3", "Custom 4", + "Custom 5", "Custom 6", "Custom 7"}; + +static Elm_Map_Zoom_Mode +_zoom_mode_get(const char *map_src) +{ + unsigned int i; + + assert(sizeof(zoom_choices)/sizeof(zoom_choices[0]) == + ELM_MAP_ZOOM_MODE_LAST); + + for (i = 0; i < sizeof(zoom_choices); i++) + if (strcmp(map_src, zoom_choices[i]) == 0) return i; + + 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]) == 0) 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__) +{ + const Elm_Params_Map *p; + + if (to_params) p = to_params; + else if (from_params) p = from_params; + else return; + + 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); + } + if (p->zoom_mode) + { + Elm_Map_Zoom_Mode set = _zoom_mode_get(p->zoom_mode); + if (set == ELM_MAP_ZOOM_MODE_LAST) return; + elm_map_zoom_mode_set(obj, set); + } + if (p->zoom_set && p->zoom) elm_map_zoom_set(obj, p->zoom); +} + +static Eina_Bool +external_map_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) +{ + if (!strcmp(param->name, "map source")) + { + 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); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "zoom mode")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) + { + Elm_Map_Zoom_Mode set = _zoom_mode_get(param->s); + if (set == ELM_MAP_ZOOM_MODE_LAST) return EINA_FALSE; + elm_map_zoom_mode_set(obj, set); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "zoom level")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + { + elm_map_zoom_set(obj, param->d); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static Eina_Bool +external_map_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) +{ + if (!strcmp(param->name, "map source")) + { + 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]; + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "zoom mode")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) + { + Elm_Map_Zoom_Mode set = elm_map_zoom_mode_get(obj); + if (set == ELM_MAP_ZOOM_MODE_LAST) return EINA_FALSE; + param->s = zoom_choices[set]; + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "zoom level")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + { + param->d = elm_map_zoom_get(obj); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static void * +external_map_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) +{ + Elm_Params_Map *mem; + Edje_External_Param *param; + const Eina_List *l; + + mem = calloc(1, sizeof(Elm_Params_Map)); + if (!mem) + return NULL; + + EINA_LIST_FOREACH(params, l, param) + { + if (!strcmp(param->name, "map source")) + mem->map_source = eina_stringshare_add(param->s); + if (!strcmp(param->name, "zoom mode")) + mem->zoom_mode = eina_stringshare_add(param->s); + else if (!strcmp(param->name, "zoom level")) + { + mem->zoom = param->d; + mem->zoom_set = EINA_TRUE; + } + } + + return mem; +} + +static void +external_map_params_free(void *params) +{ + Elm_Params_Map *mem = params; + + if (mem->map_source) + eina_stringshare_del(mem->map_source); + if (mem->zoom_mode) + eina_stringshare_del(mem->zoom_mode); + free(mem); +} + +static Edje_External_Param_Info external_map_params[] = + { + 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 + }; + +DEFINE_EXTERNAL_ICON_ADD(map, "map") +DEFINE_EXTERNAL_TYPE_SIMPLE(map, "Map") + diff --git a/src/edje_externals/modules.inc b/src/edje_externals/modules.inc index 3f171a1..00ec4d0 100644 --- a/src/edje_externals/modules.inc +++ b/src/edje_externals/modules.inc @@ -6,6 +6,7 @@ DEFINE_TYPE(check) DEFINE_TYPE(clock) DEFINE_TYPE(fileselector) DEFINE_TYPE(hoversel) +DEFINE_TYPE(map) DEFINE_TYPE(notepad) DEFINE_TYPE(photocam) DEFINE_TYPE(progressbar) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index c0373b6..8a26526 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -1168,8 +1168,10 @@ extern "C" { { ELM_MAP_ZOOM_MODE_MANUAL, ELM_MAP_ZOOM_MODE_AUTO_FIT, - ELM_MAP_ZOOM_MODE_AUTO_FILL + ELM_MAP_ZOOM_MODE_AUTO_FILL, + ELM_MAP_ZOOM_MODE_LAST } Elm_Map_Zoom_Mode; + typedef enum _Elm_Map_Sources { ELM_MAP_SOURCE_MAPNIK, @@ -1182,8 +1184,10 @@ extern "C" { ELM_MAP_SOURCE_CUSTOM_4, ELM_MAP_SOURCE_CUSTOM_5, ELM_MAP_SOURCE_CUSTOM_6, - ELM_MAP_SOURCE_CUSTOM_7 + ELM_MAP_SOURCE_CUSTOM_7, + ELM_MAP_SOURCE_LAST } Elm_Map_Sources; + typedef struct _Elm_Map_Marker Elm_Map_Marker; typedef struct _Elm_Map_Marker_Class Elm_Map_Marker_Class; typedef struct _Elm_Map_Group_Class Elm_Map_Group_Class; -- 2.7.4