From: chanywa Date: Fri, 8 Jul 2016 12:25:21 +0000 (+0900) Subject: fixed to calcurate minimal hit area of the marker X-Git-Tag: submit/tizen/20160805.024428~15^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09140e0487ea810ecf18315e6764a7f3363522e7;p=platform%2Fcore%2Fapi%2Fmaps-service.git fixed to calcurate minimal hit area of the marker Change-Id: I2ba61fff95e6dd2050168ec02a12d20b94ea0cc2 --- diff --git a/src/api/maps_view.cpp b/src/api/maps_view.cpp index 62ab58d..f5abb22 100644 --- a/src/api/maps_view.cpp +++ b/src/api/maps_view.cpp @@ -111,6 +111,10 @@ typedef struct _maps_view_s { bool public_transit_enabled; bool scalebar_enabled; + /* To check hit_test */ + int screen_dpi; + int min_hit_area; + void *maps_plugin_view_handle; } maps_view_s; @@ -599,6 +603,10 @@ EXPORT_API int maps_view_create(maps_service_h maps, Evas_Object *obj, maps_view v->traffic_enabled = false; v->public_transit_enabled = false; + /* To check hit_test */ + v->screen_dpi = maps_get_display_dpi(); + v->min_hit_area = MAX(20, v->screen_dpi / 5); + return MAPS_ERROR_NONE; } @@ -1780,12 +1788,16 @@ static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h obj y -= h / 2; /* Add some margin of the hit-area. */ - if (w < 30) w = 30; - if (h < 30) h = 30; + w = MAX(w, htd->v->min_hit_area); + h = MAX(h, htd->v->min_hit_area); + + /* Gets a half range to check hit-area */ + int hw = (int)(w / 2. + .5); + int hh = (int)(h / 2. + .5); /* Check hit-area */ - if ((x > (htd->x - w)) && (x < (htd->x + w)) - && (y > (htd->y - h)) && (y < (htd->y + h))) { + if ((x > (htd->x - hw)) && (x < (htd->x + hw)) + && (y > (htd->y - hh)) && (y < (htd->y + hh))) { htd->object = object; } break; diff --git a/src/maps_util.cpp b/src/maps_util.cpp index b7738eb..41c8871 100644 --- a/src/maps_util.cpp +++ b/src/maps_util.cpp @@ -17,6 +17,9 @@ #include "maps_util.h" #include "maps_error.h" #include +#include + +#define DEFAULT_UNKNOWN_DPI 132 int maps_set_string(const char *src, const int max_length, char **dst) { @@ -35,3 +38,10 @@ int maps_get_string(const char *src, const int max_length, char **dst) *dst = g_strndup(src, max_length); return MAPS_ERROR_NONE; } + +int maps_get_display_dpi() +{ + int dpi = DEFAULT_UNKNOWN_DPI; + system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi); + return dpi; +} diff --git a/src/maps_util.h b/src/maps_util.h index 92634cc..cade33a 100755 --- a/src/maps_util.h +++ b/src/maps_util.h @@ -98,6 +98,8 @@ int maps_set_string(const char *src, const int max_length, char **dst); */ int maps_get_string(const char *src, const int max_length, char **dst); +int maps_get_display_dpi(); + /* Prevent utility highlights defects in std::vector and std::string, so * simplified versions of that classes are implemented */ template class vector {