summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_slider.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/efl_ui_slider.c')
-rw-r--r--src/lib/elementary/efl_ui_slider.c202
1 files changed, 137 insertions, 65 deletions
diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c
index 919e0b7..8362b06 100644
--- a/src/lib/elementary/efl_ui_slider.c
+++ b/src/lib/elementary/efl_ui_slider.c
@@ -12,6 +12,8 @@
12#include "elm_priv.h" 12#include "elm_priv.h"
13#include "efl_ui_slider_private.h" 13#include "efl_ui_slider_private.h"
14#include "elm_widget_layout.h" 14#include "elm_widget_layout.h"
15
16#include "efl_ui_slider_part.eo.h"
15#include "elm_part_helper.h" 17#include "elm_part_helper.h"
16 18
17#define MY_CLASS EFL_UI_SLIDER_CLASS 19#define MY_CLASS EFL_UI_SLIDER_CLASS
@@ -260,54 +262,35 @@ _indicator_set(Evas_Object *obj)
260{ 262{
261 EFL_UI_SLIDER_DATA_GET(obj, sd); 263 EFL_UI_SLIDER_DATA_GET(obj, sd);
262 264
263 if (sd->indicator_format_func) 265 Eina_Value val;
264 { 266 const char *str;
265 char *buf;
266 267
267 buf = sd->indicator_format_func(sd->val); 268 if (!sd->indi_format_cb) return;
268 elm_layout_text_set(obj, "elm.indicator", buf);
269 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf);
270 if (sd->popup)
271 edje_object_part_text_set(sd->popup, "elm.indicator", buf);
272 if (sd->popup2)
273 {
274 if (sd->indicator_format_free) sd->indicator_format_free(buf);
275 buf = sd->indicator_format_func(sd->intvl_to);
276 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf);
277 edje_object_part_text_set(sd->popup2, "elm.indicator", buf);
278 }
279 269
280 if (sd->indicator_format_free) sd->indicator_format_free(buf); 270 eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
281 } 271 eina_strbuf_reset(sd->indi_format_strbuf);
282 else if (sd->indicator)
283 {
284 char buf[1024];
285 272
286 snprintf(buf, sizeof(buf), sd->indicator, sd->val); 273 eina_value_set(&val, sd->val);
287 elm_layout_text_set(obj, "elm.indicator", buf); 274 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val);
288 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf); 275
289 if (sd->popup) 276 str = eina_strbuf_string_get(sd->indi_format_strbuf);
290 edje_object_part_text_set(sd->popup, "elm.indicator", buf); 277
291 if (sd->popup2) 278 elm_layout_text_set(obj, "elm.indicator", str);
292 { 279 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", str);
293 memset(buf, 0, 1024); 280 if (sd->popup)
294 snprintf(buf, sizeof(buf), sd->indicator, sd->intvl_to); 281 edje_object_part_text_set(sd->popup, "elm.indicator", str);
295 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf); 282
296 edje_object_part_text_set(sd->popup2, "elm.indicator", buf); 283 if (sd->popup2)
297 }
298 }
299 else
300 { 284 {
301 elm_layout_text_set(obj, "elm.indicator", NULL); 285 eina_strbuf_reset(sd->indi_format_strbuf);
302 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", NULL); 286 eina_value_set(&val, sd->intvl_to);
303 if (sd->popup) 287 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val);
304 edje_object_part_text_set(sd->popup, "elm.indicator", NULL); 288 str = eina_strbuf_string_get(sd->indi_format_strbuf);
305 if (sd->popup2) 289 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", str);
306 { 290 edje_object_part_text_set(sd->popup2, "elm.indicator", str);
307 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", NULL);
308 edje_object_part_text_set(sd->popup2, "elm.indicator", NULL);
309 }
310 } 291 }
292
293 eina_value_flush(&val);
311} 294}
312 295
313static void 296static void
@@ -1171,12 +1154,14 @@ _efl_ui_slider_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Slider_Data *priv)
1171EOLIAN static void 1154EOLIAN static void
1172_efl_ui_slider_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Slider_Data *sd) 1155_efl_ui_slider_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Slider_Data *sd)
1173{ 1156{
1174 eina_stringshare_del(sd->indicator);
1175 ecore_timer_del(sd->delay); 1157 ecore_timer_del(sd->delay);
1176 ecore_timer_del(sd->wheel_indicator_timer); 1158 ecore_timer_del(sd->wheel_indicator_timer);
1177 evas_object_del(sd->popup); 1159 evas_object_del(sd->popup);
1178 evas_object_del(sd->popup2); 1160 evas_object_del(sd->popup2);
1179 1161
1162 ELM_SAFE_FREE(sd->indi_template, eina_stringshare_del);
1163 eina_strbuf_free(sd->indi_format_strbuf);
1164
1180 efl_ui_format_cb_set(obj, NULL, NULL, NULL); 1165 efl_ui_format_cb_set(obj, NULL, NULL, NULL);
1181 eina_strbuf_free(sd->format_strbuf); 1166 eina_strbuf_free(sd->format_strbuf);
1182 1167
@@ -1209,19 +1194,6 @@ _efl_ui_slider_efl_ui_direction_direction_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider
1209} 1194}
1210 1195
1211EOLIAN static void 1196EOLIAN static void
1212_efl_ui_slider_indicator_format_set(Eo *obj, Efl_Ui_Slider_Data *sd, const char *indicator)
1213{
1214 eina_stringshare_replace(&sd->indicator, indicator);
1215 evas_object_smart_changed(obj);
1216}
1217
1218EOLIAN static const char*
1219_efl_ui_slider_indicator_format_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd)
1220{
1221 return sd->indicator;
1222}
1223
1224EOLIAN static void
1225_efl_ui_slider_efl_ui_range_range_min_max_set(Eo *obj, Efl_Ui_Slider_Data *sd, double min, double max) 1197_efl_ui_slider_efl_ui_range_range_min_max_set(Eo *obj, Efl_Ui_Slider_Data *sd, double min, double max)
1226{ 1198{
1227 if ((sd->val_min == min) && (sd->val_max == max)) return; 1199 if ((sd->val_min == min) && (sd->val_max == max)) return;
@@ -1260,14 +1232,6 @@ _efl_ui_slider_efl_ui_range_range_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_D
1260} 1232}
1261 1233
1262EOLIAN static void 1234EOLIAN static void
1263_efl_ui_slider_indicator_format_function_set(Eo *obj, Efl_Ui_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func)
1264{
1265 sd->indicator_format_func = func;
1266 sd->indicator_format_free = free_func;
1267 evas_object_smart_changed(obj);
1268}
1269
1270EOLIAN static void
1271_efl_ui_slider_indicator_show_set(Eo *obj, Efl_Ui_Slider_Data *sd, Eina_Bool show) 1235_efl_ui_slider_indicator_show_set(Eo *obj, Efl_Ui_Slider_Data *sd, Eina_Bool show)
1272{ 1236{
1273 if (show) 1237 if (show)
@@ -1477,6 +1441,89 @@ _slider_span_size_set(Eo *obj, Efl_Ui_Slider_Data *sd, int size)
1477 evas_object_smart_changed(obj); 1441 evas_object_smart_changed(obj);
1478} 1442}
1479 1443
1444/* Efl.Part begin */
1445
1446EOLIAN static Eo *
1447_efl_ui_slider_efl_part_part(const Eo *obj, Efl_Ui_Slider_Data *sd EINA_UNUSED, const char *part)
1448{
1449 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
1450
1451 if (eina_streq(part, "indicator"))
1452 return ELM_PART_IMPLEMENT(EFL_UI_SLIDER_PART_CLASS, obj, part);
1453
1454 return efl_part(efl_super(obj, MY_CLASS), part);
1455}
1456
1457EOLIAN static void
1458_efl_ui_slider_part_efl_ui_format_format_cb_set(Eo *obj, void *_pd EINA_UNUSED, void *func_data, Efl_Ui_Format_Func_Cb func, Eina_Free_Cb func_free_cb)
1459{
1460 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
1461 Efl_Ui_Slider_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_SLIDER_CLASS);
1462
1463 if (sd->indi_format_cb_data == func_data && sd->indi_format_cb == func)
1464 return;
1465
1466 if (sd->indi_format_cb_data && sd->indi_format_free_cb)
1467 sd->indi_format_free_cb(sd->format_cb_data);
1468
1469 sd->indi_format_cb = func;
1470 sd->indi_format_cb_data = func_data;
1471 sd->indi_format_free_cb = func_free_cb;
1472 if (!sd->indi_format_strbuf) sd->indi_format_strbuf = eina_strbuf_new();
1473
1474 efl_canvas_group_change(pd->obj);
1475}
1476
1477static void
1478_indi_default_format_cb(void *data, Eina_Strbuf *str, const Eina_Value value)
1479{
1480 const Eina_Value_Type *type = eina_value_type_get(&value);
1481 Efl_Ui_Slider_Data *sd = data;
1482 double v;
1483
1484 if (type != EINA_VALUE_TYPE_DOUBLE) return;
1485
1486 eina_value_get(&value, &v);
1487 eina_strbuf_append_printf(str, sd->indi_template, v);
1488}
1489
1490static void
1491_indi_default_format_free_cb(void *data)
1492{
1493 Efl_Ui_Slider_Data *sd = data;
1494
1495 if (sd && sd->indi_template)
1496 {
1497 eina_stringshare_del(sd->indi_template);
1498 sd->indi_template = NULL;
1499 }
1500}
1501
1502EOLIAN static void
1503_efl_ui_slider_part_efl_ui_format_format_string_set(Eo *obj, void *_pd EINA_UNUSED, const char *template)
1504{
1505 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
1506 Efl_Ui_Slider_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_SLIDER_CLASS);
1507
1508 if (!template) return;
1509 eina_stringshare_replace(&sd->indi_template, template);
1510
1511 efl_ui_format_cb_set(efl_part(pd->obj, "indicator"), sd, _indi_default_format_cb, _indi_default_format_free_cb);
1512}
1513
1514EOLIAN static const char *
1515_efl_ui_slider_part_efl_ui_format_format_string_get(Eo *obj, void *_pd EINA_UNUSED)
1516{
1517 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
1518 Efl_Ui_Slider_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_SLIDER_CLASS);
1519
1520 return sd->indi_template;
1521}
1522
1523#include "efl_ui_slider_part.eo.c"
1524
1525/* Efl.Part end */
1526
1480/* Legacy APIs */ 1527/* Legacy APIs */
1481 1528
1482EAPI Evas_Object * 1529EAPI Evas_Object *
@@ -1670,6 +1717,31 @@ elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
1670 efl_ui_range_min_max_get(obj, min, max); 1717 efl_ui_range_min_max_get(obj, min, max);
1671} 1718}
1672 1719
1720EAPI void
1721elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
1722{
1723 efl_ui_format_string_set(efl_part(obj, "indicator"), indicator);
1724}
1725
1726EAPI const char *
1727elm_slider_indicator_format_get(const Evas *obj)
1728{
1729 return efl_ui_format_string_get(efl_part(obj, "indicator"));
1730}
1731
1732EAPI void
1733elm_slider_indicator_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func)
1734{
1735 Slider_Format_Wrapper_Data *sfwd = malloc(sizeof(Slider_Format_Wrapper_Data));
1736
1737 sfwd->format_cb = func;
1738 sfwd->format_free_cb = free_func;
1739
1740 efl_ui_format_cb_set(efl_part(obj, "indicator"), sfwd,
1741 _format_legacy_to_format_eo_cb,
1742 _format_legacy_to_format_eo_free_cb);
1743}
1744
1673/* Internal EO APIs and hidden overrides */ 1745/* Internal EO APIs and hidden overrides */
1674 1746
1675ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(efl_ui_slider) 1747ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(efl_ui_slider)