summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-10-24 16:36:03 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-10-25 16:18:54 +0900
commit8661fe234c7e68b6e69a20f133f8ffd568e12570 (patch)
treeb168d41453b712aac4ac7d6f30739010a89aeb25
parent9d1fad8dc163684a74c31f552ba6b1b603273c49 (diff)
Efl.Ui.Slider: implement format_cb for units
Ref T6204
-rw-r--r--src/lib/elementary/efl_ui_slider.c67
-rw-r--r--src/lib/elementary/efl_ui_slider.eo1
-rw-r--r--src/lib/elementary/efl_ui_slider_private.h5
3 files changed, 56 insertions, 17 deletions
diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c
index 0974e504f1..e7a4f4c389 100644
--- a/src/lib/elementary/efl_ui_slider.c
+++ b/src/lib/elementary/efl_ui_slider.c
@@ -216,30 +216,29 @@ _units_set(Evas_Object *obj)
216{ 216{
217 EFL_UI_SLIDER_DATA_GET(obj, sd); 217 EFL_UI_SLIDER_DATA_GET(obj, sd);
218 218
219 if (sd->units_format_func) 219 if (sd->format_cb)
220 { 220 {
221 char *buf; 221 Eina_Value val;
222
223 eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
224 eina_value_set(&val, sd->val);
225
226 eina_strbuf_reset(sd->format_strbuf);
222 227
223 buf = sd->units_format_func(sd->val); 228 sd->format_cb(sd->format_cb_data, sd->format_strbuf, val);
224 if (buf) 229
230 elm_layout_text_set(obj, "elm.units", eina_strbuf_string_get(sd->format_strbuf));
231 if (!sd->units_show)
225 { 232 {
226 elm_layout_text_set(obj, "elm.units", buf); 233 elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
227 if (!sd->units_show) 234 sd->units_show = EINA_TRUE;
228 {
229 elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
230 sd->units_show = EINA_TRUE;
231 }
232 } 235 }
233 else 236 else
234 { 237 {
235 elm_layout_text_set(obj, "elm.units", NULL); 238 elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm");
236 if (sd->units_show) 239 sd->units_show = EINA_FALSE;
237 {
238 elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm");
239 sd->units_show = EINA_FALSE;
240 }
241 } 240 }
242 if (sd->units_format_free) sd->units_format_free(buf); 241 if (sd->format_free_cb) sd->format_free_cb(sd->format_cb_data);
243 } 242 }
244 else if (sd->units) 243 else if (sd->units)
245 { 244 {
@@ -1204,6 +1203,9 @@ _efl_ui_slider_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Slider_Data *sd)
1204 evas_object_del(sd->popup); 1203 evas_object_del(sd->popup);
1205 evas_object_del(sd->popup2); 1204 evas_object_del(sd->popup2);
1206 1205
1206 efl_ui_format_cb_set(obj, NULL, NULL, NULL);
1207 eina_strbuf_free(sd->format_strbuf);
1208
1207 efl_canvas_group_del(efl_super(obj, MY_CLASS)); 1209 efl_canvas_group_del(efl_super(obj, MY_CLASS));
1208} 1210}
1209 1211
@@ -1462,6 +1464,23 @@ _efl_ui_slider_efl_ui_format_format_string_get(Eo *obj EINA_UNUSED, Efl_Ui_Slide
1462 return sd->units; 1464 return sd->units;
1463} 1465}
1464 1466
1467EOLIAN static void
1468_efl_ui_slider_efl_ui_format_format_cb_set(Eo *obj, Efl_Ui_Slider_Data *sd, void *func_data, Efl_Ui_Format_Func_Cb func, Eina_Free_Cb func_free_cb)
1469{
1470 if (sd->format_cb_data == func_data && sd->format_cb == func)
1471 return;
1472
1473 if (sd->format_cb_data && sd->format_free_cb)
1474 sd->format_free_cb(sd->format_cb_data);
1475
1476 sd->format_cb = func;
1477 sd->format_cb_data = func_data;
1478 sd->format_free_cb = func_free_cb;
1479 if (!sd->format_strbuf) sd->format_strbuf = eina_strbuf_new();
1480
1481 efl_canvas_group_change(obj);
1482}
1483
1465EOLIAN const Elm_Atspi_Action * 1484EOLIAN const Elm_Atspi_Action *
1466_efl_ui_slider_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *pd EINA_UNUSED) 1485_efl_ui_slider_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *pd EINA_UNUSED)
1467{ 1486{
@@ -1595,6 +1614,18 @@ elm_slider_inverted_get(const Evas_Object *obj)
1595 return _is_inverted(dir); 1614 return _is_inverted(dir);
1596} 1615}
1597 1616
1617static void
1618_format_legacy_to_format_eo_cb(void *data, Eina_Strbuf *str, const Eina_Value value EINA_UNUSED)
1619{
1620 Efl_Ui_Slider_Data *sd = data;
1621 char *buf;
1622
1623 buf = sd->units_format_func(sd->val);
1624 if (buf)
1625 eina_strbuf_append(str, buf);
1626 if (sd->units_format_free) sd->units_format_free(buf);
1627}
1628
1598EAPI void 1629EAPI void
1599elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func) 1630elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func)
1600{ 1631{
@@ -1603,6 +1634,8 @@ elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, sl
1603 sd->units_format_func = func; 1634 sd->units_format_func = func;
1604 sd->units_format_free = free_func; 1635 sd->units_format_free = free_func;
1605 1636
1637 efl_ui_format_cb_set(obj, sd, _format_legacy_to_format_eo_cb, NULL);
1638
1606 evas_object_smart_changed(obj); 1639 evas_object_smart_changed(obj);
1607} 1640}
1608 1641
diff --git a/src/lib/elementary/efl_ui_slider.eo b/src/lib/elementary/efl_ui_slider.eo
index 04e1fcfe3b..1283e0a86b 100644
--- a/src/lib/elementary/efl_ui_slider.eo
+++ b/src/lib/elementary/efl_ui_slider.eo
@@ -129,6 +129,7 @@ class Efl.Ui.Slider (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Direction,
129 Efl.Text.text { get; set; } 129 Efl.Text.text { get; set; }
130 Efl.Text.Markup.markup { get; set; } 130 Efl.Text.Markup.markup { get; set; }
131 Efl.Ui.Format.format_string { get; set; } 131 Efl.Ui.Format.format_string { get; set; }
132 Efl.Ui.Format.format_cb { set; }
132 Efl.Ui.Translatable.translatable_text { get; set; } 133 Efl.Ui.Translatable.translatable_text { get; set; }
133 } 134 }
134 events { 135 events {
diff --git a/src/lib/elementary/efl_ui_slider_private.h b/src/lib/elementary/efl_ui_slider_private.h
index a81425e4b6..03ac83bb4f 100644
--- a/src/lib/elementary/efl_ui_slider_private.h
+++ b/src/lib/elementary/efl_ui_slider_private.h
@@ -51,6 +51,11 @@ struct _Efl_Ui_Slider_Data
51 51
52 double intvl_from, intvl_to; 52 double intvl_from, intvl_to;
53 53
54 Efl_Ui_Format_Func_Cb format_cb;
55 Eina_Free_Cb format_free_cb;
56 void *format_cb_data;
57 Eina_Strbuf *format_strbuf;
58
54 Eina_Bool indicator_show : 1; 59 Eina_Bool indicator_show : 1;
55 Eina_Bool spacer_down : 1; 60 Eina_Bool spacer_down : 1;
56 Eina_Bool frozen : 1; 61 Eina_Bool frozen : 1;