Fixed slider issue shape issue [TIZENIOT-1748] 10/238610/1
authoraman.jeph <aman.jeph@samsung.com>
Wed, 15 Jul 2020 11:38:31 +0000 (17:08 +0530)
committeraman.jeph <aman.jeph@samsung.com>
Wed, 15 Jul 2020 11:38:31 +0000 (17:08 +0530)
Change-Id: Ieb219697d36b54f83fb87863c408d22070a7e9e0
Signed-off-by: aman.jeph <aman.jeph@samsung.com>
src/device/brightness.c
src/device/volume.c

index afd8e116af57c29be8156f3efa2566a9a48ed064..ba031fc118fc4c7d896edadf132fe88f5b15f3c8 100755 (executable)
@@ -53,6 +53,8 @@
 #define SLIDER_HEIGHT_ADJUSTMENT 9
 #define SLIDER_LAYOUT_WIDTH ELM_SCALE_SIZE(VOLUME_BRIGHTNESS_SLIDER_LAYOUT_W)
 #define SLIDER_LAYOUT_HEIGHT ELM_SCALE_SIZE(VOLUME_BRIGHTNESS_SLIDER_LAYOUT_H)
+#define SLIDER_HEIGHT 32
+
 
 
 typedef struct _brightness_ctrl_obj {
@@ -446,9 +448,23 @@ static void _slider_vg_resize_cb(void *data , Evas *e EINA_UNUSED, Evas_Object *
        Evas_Coord w, h;
        Efl_VG *shape = data;
        evas_object_geometry_get(obj, NULL, NULL, &w, &h);
-       double radius = w > h ? h/2.0 : w/2.0;
+       double radius = 0.0;
+       int x = 0, y = 0;
+       if(w<=16)
+       {
+               /* We need to calculate the height of slider curve based on width and radius
+                * we are considering radius of curve 16px and based on width we calculate half size of chords in curve.
+                */
+               radius = ((double)SLIDER_HEIGHT)/ 2.0;
+               int h_new = 2*(sqrt(256-((16-w)*(16-w))));
+               y = (SLIDER_HEIGHT-h_new)/2;
+               h = h_new;
+       } else {
+               //radius = w > h ? h/2.0 : w/2.0;
+               radius = ((double)SLIDER_HEIGHT)/ 2.0;
+       }
        evas_vg_shape_reset(shape);
-       evas_vg_shape_append_rect(shape, 0, 0, w, h, radius, radius);
+       evas_vg_shape_append_rect(shape, x, y, w, h, radius, radius);
 }
 
 static Evas_Object* _slider_vg_object_create(Evas_Object *parent, int r, int g, int b, int a)
index 2a966d90de720dcf1d82739cd78ad299246fc2f7..f7cad6d13810f1fa5032b2e90a65bcf2869b8779 100755 (executable)
@@ -27,6 +27,7 @@
 #include <app_control.h>
 #include <tzsh.h>
 #include <tzsh_quickpanel_service.h>
+#include <math.h>
 
 #include "common.h"
 #include "volume.h"
 #define SLIDER_HEIGHT_ADJUSTMENT 9
 #define SLIDER_LAYOUT_WIDTH ELM_SCALE_SIZE(VOLUME_BRIGHTNESS_SLIDER_LAYOUT_W)
 #define SLIDER_LAYOUT_HEIGHT ELM_SCALE_SIZE(VOLUME_BRIGHTNESS_SLIDER_LAYOUT_H)
+#define SLIDER_HEIGHT 32
+
+#define SLIDER_1_COMPARE 1.000001
+#define SLIDER_9_COMPARE 9.000001
+
 
 
 #define VCONF_KEY_MUTE_TYPE_SYSTEM             VCONF_KEY_MUTE_PREFIX"/system"
@@ -191,7 +197,7 @@ static void _volume_view_update(void);
 static void _volume_register_event_cb(volume_ctrl_obj *ctrl_obj);
 static void _volume_deregister_event_cb(volume_ctrl_obj *ctrl_obj);
 
-static void _volume_set_image(int level);
+static void _volume_set_image(double level);
 static void _refresh(void *data);
 
 QP_Module volume_ctrl = {
@@ -479,7 +485,7 @@ static void _volume_ctrl_slider_changed_cb(void *data, Evas_Object *obj, void *e
        DBG("*** val == %lf ***",val);
        value = (int)(val + 0.5);
        DBG("*** value == %d ***",value);
-       _volume_set_image(value);
+       _volume_set_image(val);
        volume_sound_change_set(value);
 }
 
@@ -498,10 +504,10 @@ static void _volume_slider_drag_stop_cb(void *data, Evas_Object *obj, void *even
        double val = 0;
 
        val = elm_slider_value_get(slider);
-       val += 0.5;
-       DBG("**** slider value : %d ***", (int)val);
+       DBG("**** slider value : %f ***", val);
+       int value = (int)(val + 0.5);
        _volume_set_image(val);
-       volume_sound_change_set((int)val);
+       volume_sound_change_set(value);
 }
 
 /*!
@@ -586,7 +592,7 @@ static Evas_Object *_volume_view_create(Evas_Object *list)
        return view_wrapper;
 }
 
-static void _volume_set_image(int level)
+static void _volume_set_image(double level)
 {
        int mapped_level;
        DBG("******_volume_set_image level = %d *********",level);
@@ -594,10 +600,11 @@ static void _volume_set_image(int level)
                ERR("Ctrl Obj is not defined");
                return;
        }
-       if (level <= 1)
+
+       if (level < SLIDER_1_COMPARE)
                mapped_level = 0;
 
-       else if (level > 1 && level <= 9)
+       else if (level > SLIDER_1_COMPARE && level <= SLIDER_9_COMPARE)
                mapped_level = 1;
 
        else
@@ -618,9 +625,23 @@ static void _slider_vg_resize_cb(void *data , Evas *e EINA_UNUSED, Evas_Object *
        Evas_Coord w, h;
        Efl_VG *shape = data;
        evas_object_geometry_get(obj, NULL, NULL, &w, &h);
-       double radius = w > h ? h/2.0 : w/2.0;
+       double radius = 0.0;
+       int x = 0, y = 0;
+       if(w<=16)
+       {
+               /* We need to calculate the height of slider curve based on width and radius
+                * we are considering radius of curve 16px and based on width we calculate half size of chords in curve.
+                */
+               radius = ((double)SLIDER_HEIGHT)/ 2.0;
+               int h_new = 2*(sqrt(256-((16-w)*(16-w))));
+               y = (SLIDER_HEIGHT-h_new)/2;
+               h = h_new;
+       } else {
+               //radius = w > h ? h/2.0 : w/2.0;
+               radius = ((double)SLIDER_HEIGHT)/ 2.0;
+       }
        evas_vg_shape_reset(shape);
-       evas_vg_shape_append_rect(shape, 0, 0, w, h, radius, radius);
+       evas_vg_shape_append_rect(shape, x, y, w, h, radius, radius);
 }
 
 static Evas_Object* _slider_vg_object_create(Evas_Object *parent, int r, int g, int b, int a)