fixed to calcurate minimal hit area of the marker 69/79169/1
authorchanywa <cbible.kim@samsung.com>
Fri, 8 Jul 2016 12:25:21 +0000 (21:25 +0900)
committerchanywa <cbible.kim@samsung.com>
Fri, 8 Jul 2016 12:25:21 +0000 (21:25 +0900)
Change-Id: I2ba61fff95e6dd2050168ec02a12d20b94ea0cc2

src/api/maps_view.cpp
src/maps_util.cpp
src/maps_util.h

index 62ab58d..f5abb22 100644 (file)
@@ -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;
index b7738eb..41c8871 100644 (file)
@@ -17,6 +17,9 @@
 #include "maps_util.h"
 #include "maps_error.h"
 #include <glib.h>
+#include <system_info.h>
+
+#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;
+}
index 92634cc..cade33a 100755 (executable)
@@ -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 T> class vector {