Efl.Ui.Progressbar: fix val to be val when legacy format_function_set() is called
authorAmitesh Singh <amitesh.sh@samsung.com>
Fri, 27 Oct 2017 02:48:10 +0000 (11:48 +0900)
committerAmitesh Singh <amitesh.sh@samsung.com>
Fri, 27 Oct 2017 02:56:22 +0000 (11:56 +0900)
In Pb, the legacy units_format_set's user callback uses value to
be 100*value (0.0 to 100.0) and legacy format_function_set uses
value of range "0.0 to 1.0". This was broken after my patch.
Lets keep this behaviour in legacy APIs.

In case of new EO APIs, the value will be always from 0.0 to 1.0
in both format_string() and format_cb callbacks.

src/lib/elementary/efl_ui_progressbar.c
src/lib/elementary/efl_ui_progressbar_private.h

index 1b2042a..fdb8e2e 100644 (file)
@@ -109,9 +109,10 @@ _units_set(Evas_Object *obj)
         Eina_Value val;
 
         eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
-        if (!sd->is_legacy_format)
-          eina_value_set(&val, sd->val);
-        else // Keeping this bug since the legacy code was like that.
+        eina_value_set(&val, sd->val);
+
+        // Keeping this bug since the legacy code was like that.
+        if (sd->is_legacy_format_string && !sd->is_legacy_format_cb)
           eina_value_set(&val, 100 * sd->val);
 
         eina_strbuf_reset(sd->format_strbuf);
@@ -689,10 +690,12 @@ _format_legacy_to_format_eo_free_cb(void *data)
 EAPI void
 elm_progressbar_unit_format_function_set(Evas_Object *obj, progressbar_func_type func, progressbar_freefunc_type free_func)
 {
+   EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
    Pb_Format_Wrapper_Data *pfwd = malloc(sizeof(Pb_Format_Wrapper_Data));
 
    pfwd->format_cb = func;
    pfwd->format_free_cb = free_func;
+   sd->is_legacy_format_cb = EINA_TRUE;
 
    efl_ui_format_cb_set(obj, pfwd, _format_legacy_to_format_eo_cb,
                         _format_legacy_to_format_eo_free_cb);
@@ -715,10 +718,9 @@ elm_progressbar_span_size_get(const Evas_Object *obj)
 EAPI void
 elm_progressbar_unit_format_set(Evas_Object *obj, const char *units)
 {
-  EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
-
-  sd->is_legacy_format = EINA_TRUE;
+   EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
 
+   sd->is_legacy_format_string = EINA_TRUE;
    efl_ui_format_string_set(obj, units);
 }
 
index 76ce990..c9b0c9b 100644 (file)
@@ -44,7 +44,8 @@ struct _Efl_Ui_Progressbar_Data
 
    Eina_Bool             pulse : 1; /**< Whether object is put in the pulsing mode */
    Eina_Bool             pulse_state : 1; /**< To start the pulsing animation, otherwise to stop it */
-   Eina_Bool             is_legacy_format : 1;
+   Eina_Bool             is_legacy_format_string : 1;
+   Eina_Bool             is_legacy_format_cb : 1;
 };
 
 struct _Efl_Ui_Progress_Status