EAPI const char *elm_slider_unit_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI void elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator) EINA_ARG_NONNULL(1);
EAPI const char *elm_slider_indicator_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
- EAPI void elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val)) EINA_ARG_NONNULL(1);
+ EAPI void elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str)) EINA_ARG_NONNULL(1);
+ EAPI void elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str)) EINA_ARG_NONNULL(1);
EAPI void elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) EINA_ARG_NONNULL(1);
EAPI Eina_Bool elm_slider_horizontal_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI void elm_slider_min_max_set(Evas_Object *obj, double min, double max) EINA_ARG_NONNULL(1);
Evas_Object *icon;
Evas_Object *end;
Evas_Object *spacer;
+
+ Ecore_Timer *delay;
+
const char *label;
const char *units;
const char *indicator;
+
const char *(*indicator_format_func)(double val);
+ void (*indicator_format_free)(const char *str);
+
+ const char *(*units_format_func)(double val);
+ void (*units_format_free)(const char *str);
+
+ double val, val_min, val_max;
+ Evas_Coord size;
+
Eina_Bool horizontal : 1;
Eina_Bool inverted : 1;
Eina_Bool indicator_show : 1;
- double val, val_min, val_max;
- Ecore_Timer *delay;
- Evas_Coord size;
};
#define ELM_SLIDER_INVERTED_FACTOR (-1.0)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- if (wd->units)
+ if (wd->units_format_func)
+ {
+ const char *buf;
+ buf = wd->units_format_func(wd->val);
+ edje_object_part_text_set(wd->slider, "elm.units", buf);
+ if (wd->units_format_free) wd->units_format_free(buf);
+ }
+ else if (wd->units)
{
char buf[1024];
const char *buf;
buf = wd->indicator_format_func(wd->val);
edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
+ if (wd->indicator_format_free) wd->indicator_format_free(buf);
}
else if (wd->indicator)
{
}
/**
- * Set the format function pointer for the inducator area
+ * Set the format function pointer for the indicator area
*
* Set the callback function to format the indicator string.
* See elm_slider_indicator_format_set() for more info on how this works.
* @param obj The slider object
* @param indicator The format string for the indicator display
* @param func The indicator format function
+ * @param free_func The freeing function for the format string
*
* @ingroup Slider
*/
EAPI void
-elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
+elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->indicator_format_func = func;
+ wd->indicator_format_free = free_func;
+ _indicator_set(obj);
+}
+
+/**
+ * Set the format function pointer for the units area
+ *
+ * Set the callback function to format the indicator string.
+ * See elm_slider_units_format_set() for more info on how this works.
+ *
+ * @param obj The slider object
+ * @param indicator The format string for the units display
+ * @param func The units format function
+ * @param free_func The freeing function for the format string
+ *
+ * @ingroup Slider
+ */
+EAPI void
+elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ wd->units_format_func = func;
+ wd->units_format_free = free_func;
_indicator_set(obj);
}