elementary: made a min_max func calc. Need to call it in min_max_set units_format_set units_format_function_set (Ho ooops a bug here, now fixed :P)
SVN revision: 69272
This commit is contained in:
parent
0bba0aa664
commit
5daadd979a
|
@ -744,6 +744,41 @@ _hash_labels_free_cb(void* label)
|
|||
eina_stringshare_del(label);
|
||||
}
|
||||
|
||||
static void
|
||||
_min_max_set(Evas_Object *obj)
|
||||
{
|
||||
const char *buf_min = NULL;
|
||||
const char *buf_max = NULL;
|
||||
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if (wd->units_format_func)
|
||||
{
|
||||
buf_min = wd->units_format_func(wd->val_min);
|
||||
buf_max = wd->units_format_func(wd->val_max);
|
||||
}
|
||||
else if (wd->units)
|
||||
{
|
||||
int length = strlen(wd->units);
|
||||
|
||||
buf_min = alloca(length + 128);
|
||||
buf_max = alloca(length + 128);
|
||||
|
||||
snprintf((char*) buf_min, length + 128, wd->units, wd->val_min);
|
||||
snprintf((char*) buf_max, length + 128, wd->units, wd->val_max);
|
||||
}
|
||||
|
||||
edje_object_part_text_set(wd->slider, "elm.units.min", buf_min);
|
||||
edje_object_part_text_set(wd->slider, "elm.units.max", buf_max);
|
||||
|
||||
if (wd->units_format_func && wd->units_format_free)
|
||||
{
|
||||
wd->units_format_free(buf_min);
|
||||
wd->units_format_free(buf_max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_slider_add(Evas_Object *parent)
|
||||
{
|
||||
|
@ -852,6 +887,7 @@ elm_slider_unit_format_set(Evas_Object *obj, const char *units)
|
|||
edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
|
||||
edje_object_message_signal_process(wd->slider);
|
||||
}
|
||||
_min_max_set(obj);
|
||||
_units_set(obj);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
@ -908,43 +944,15 @@ elm_slider_horizontal_get(const Evas_Object *obj)
|
|||
EAPI void
|
||||
elm_slider_min_max_set(Evas_Object *obj, double min, double max)
|
||||
{
|
||||
const char *buf_min = NULL;
|
||||
const char *buf_max = NULL;
|
||||
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if ((wd->val_min == min) && (wd->val_max == max)) return;
|
||||
wd->val_min = min;
|
||||
wd->val_max = max;
|
||||
|
||||
if (wd->units_format_func)
|
||||
{
|
||||
buf_min = wd->units_format_func(wd->val_min);
|
||||
buf_max = wd->units_format_func(wd->val_max);
|
||||
}
|
||||
else if (wd->units)
|
||||
{
|
||||
int length = strlen(wd->units);
|
||||
|
||||
buf_min = alloca(length + 128);
|
||||
buf_max = alloca(length + 128);
|
||||
|
||||
snprintf((char*) buf_min, length + 128, wd->units, wd->val_min);
|
||||
snprintf((char*) buf_max, length + 128, wd->units, wd->val_max);
|
||||
}
|
||||
|
||||
edje_object_part_text_set(wd->slider, "elm.units.min", buf_min);
|
||||
edje_object_part_text_set(wd->slider, "elm.units.max", buf_max);
|
||||
|
||||
if (wd->units_format_func && wd->units_format_free)
|
||||
{
|
||||
wd->units_format_free(buf_min);
|
||||
wd->units_format_free(buf_max);
|
||||
}
|
||||
|
||||
if (wd->val < wd->val_min) wd->val = wd->val_min;
|
||||
if (wd->val > wd->val_max) wd->val = wd->val_max;
|
||||
_min_max_set(obj);
|
||||
_val_set(obj);
|
||||
_units_set(obj);
|
||||
_indicator_set(obj);
|
||||
|
@ -1033,7 +1041,8 @@ elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(doubl
|
|||
if (!wd) return;
|
||||
wd->units_format_func = func;
|
||||
wd->units_format_free = free_func;
|
||||
_indicator_set(obj);
|
||||
_min_max_set(obj);
|
||||
_units_set(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
Loading…
Reference in New Issue