e_desk: add zoom rectangle cxcy getting API 17/221317/5
authorJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 31 Dec 2019 05:29:21 +0000 (14:29 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 8 Jan 2020 08:54:13 +0000 (08:54 +0000)
can get cx cy with zoom vector and rectangle's left-top x y values.

Change-Id: Ia32742c19769bd9e12ddf2db17fe881b947061b5
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/e_desk.c
src/bin/e_desk.h

index f89a381..f402095 100644 (file)
@@ -1011,6 +1011,52 @@ e_desk_zoom_get(E_Desk *desk, double *zoomx, double *zoomy, int *cx, int *cy)
    return res;
 }
 
+E_API Eina_Bool
+e_desk_zoom_get_center_coordinate(E_Desk *desk, double zoomx, double zoomy, int rectx, int recty, int *cx, int *cy)
+{
+   E_Zone *zone = NULL;
+   E_Output *eout = NULL;
+   int w, h;
+   int zoomw, zoomh;
+
+   E_OBJECT_CHECK_RETURN(desk, EINA_FALSE);
+   E_OBJECT_TYPE_CHECK_RETURN(desk, E_DESK_TYPE, EINA_FALSE);
+
+   zone = desk->zone;
+   eout = e_output_find(zone->output_id);
+
+   e_output_size_get(eout, &w, &h);
+
+   zoomw = w / zoomx;
+   zoomh = h / zoomy;
+
+   if (e_config->use_pp_zoom)
+     {
+        if (zoomx == 1 || rectx < 0 || zoomw + rectx >= w)
+          return EINA_FALSE;
+
+        if (zoomy == 1 || recty < 0 || zoomh + recty >= h)
+          return EINA_FALSE;
+     }
+   else
+     {
+        if (zoomx == 1 || zoomy == 1)
+          return EINA_FALSE;
+     }
+
+   if (rectx == 0)
+     *cx = 0;
+   else
+     *cx = (int)((zoomx * (double)rectx) / (zoomx - 1.0));
+
+   if (recty == 0)
+     *cy = 0;
+   else
+     *cy = (int)((zoomy * (double)recty) / (zoomy - 1.0));
+
+   return EINA_TRUE;
+}
+
 E_API void
 e_desk_zoom_unset(E_Desk *desk)
 {
index 05e5009..06ae139 100644 (file)
@@ -95,6 +95,7 @@ E_API unsigned int e_desks_count(void);
 E_API void         e_desk_geometry_set(E_Desk *desk, int x, int y, int w, int h);
 E_API void         e_desk_zoom_set(E_Desk *desk, double zoomx, double zoomy, int cx, int cy);
 E_API Eina_Bool    e_desk_zoom_get(E_Desk *desk, double *zoomx, double *zoomy, int *cx, int *cy);
+E_API Eina_Bool    e_desk_zoom_get_center_coordinate(E_Desk *desk, double zoomx, double zoomy, int rectx, int recty, int *cx, int *cy);
 E_API void         e_desk_zoom_unset(E_Desk *desk);
 
 E_API void         e_desk_smart_member_add(E_Desk *desk, Evas_Object *obj);