circle_slider: dynamic calculation of circle slider's center point. 57/215157/2
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 2 Oct 2019 05:46:15 +0000 (14:46 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Wed, 30 Oct 2019 12:48:24 +0000 (21:48 +0900)
Change-Id: Ie4af8d110fa79a92d83cacaf3b2dcd0e960ba7e9
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/wearable/circle/efl_extension_circle_object_slider.c

index c4a8d8ad71366a8b2111928c2a914ab76f0d9f5e..41efa32be8bce7f15fb5823034c499b693bd864d 100644 (file)
@@ -29,7 +29,6 @@
 #define SLIDER_TOUCH_AREA_SIZE 50
 #define SLIDER_WIDTH_SIZE 6
 #define SLIDER_RADIUS_SIZE 174
-#define SLIDER_CENTER_POINT 180
 #define SLIDER_CUE_SIZE 0.1
 #define SLIDER_CUE_OFFSET 0.05
 #define SLIDER_CUE_SHOWN_WIDTH 56
@@ -87,8 +86,11 @@ _angle_calculate(Evas_Object *obj, Evas_Coord mouse_x, Evas_Coord mouse_y)
 {
    const double radian_value = 180.0/M_PI; // 1 radian
    Evas_Coord_Point center = {0,0};
-   center.x = SLIDER_CENTER_POINT;
-   center.y = SLIDER_CENTER_POINT;
+   Evas_Coord x = 0, y = 0, w = 0, h = 0;
+   evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+   center.x = x + w / 2;
+   center.y = y + h / 2;
 
    double default_angle = 0.0;
    Evas_Coord dx = abs(center.x - mouse_x);
@@ -296,14 +298,17 @@ _mouse_down_cb(void *data,
 
    int radius = eext_circle_object_radius_get(img_obj);
    Evas_Coord_Point center = {0,0};
-   center.x = SLIDER_CENTER_POINT;
-   center.y = SLIDER_CENTER_POINT;
+   Evas_Coord x = 0, y = 0, w = 0, h = 0;
+   evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+   center.x = x + w / 2;
+   center.y = y + h / 2;
 
    int point = sqrt(pow(center.x - ev->canvas.x, 2) + pow(center.y - ev->canvas.y, 2));
 
    if ((point <= radius) && (point >= (radius - SLIDER_TOUCH_AREA_SIZE)))
      {
-        double new_angle = _angle_calculate(img_obj, ev->canvas.x, ev->canvas.y);
+        double new_angle = _angle_calculate(obj, ev->canvas.x, ev->canvas.y);
         double current_angle = eext_circle_object_angle_get(img_obj);
 
         double angle_difference = fabs(new_angle - current_angle);
@@ -359,13 +364,16 @@ _mouse_move_cb(void *data,
      {
         int radius = eext_circle_object_radius_get(img_obj);
         Evas_Coord_Point center = {0,0};
-        center.x = SLIDER_CENTER_POINT;
-        center.y = SLIDER_CENTER_POINT;
+        Evas_Coord x = 0, y = 0, w = 0, h = 0;
+        evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+        center.x = x + w / 2;
+        center.y = y + h / 2;
 
         int point = sqrt(pow(center.x - ev->cur.canvas.x, 2) + pow(center.y - ev->cur.canvas.y, 2));
 
         if ((point <= radius) && (point >= (radius - SLIDER_TOUCH_AREA_SIZE)))
-          _angle_drag_set(img_obj, _angle_calculate(img_obj, ev->cur.canvas.x, ev->cur.canvas.y));
+          _angle_drag_set(img_obj, _angle_calculate(obj, ev->cur.canvas.x, ev->cur.canvas.y));
      }
 }
 
@@ -395,7 +403,7 @@ _mouse_up_cb(void *data,
      {
         int gap = sqrt(pow(widget_data->pressed_point.x - ev->canvas.x, 2) + pow(widget_data->pressed_point.y - ev->canvas.y, 2));
         if (gap < elm_config_scroll_thumbscroll_threshold_get())
-          _angle_tap_set(img_obj, _angle_calculate(img_obj, ev->canvas.x, ev->canvas.y));
+          _angle_tap_set(img_obj, _angle_calculate(obj, ev->canvas.x, ev->canvas.y));
 
         widget_data->tap = EINA_FALSE;
      }