From 9d843fc818307a556b1b105d5ed6f995247b6892 Mon Sep 17 00:00:00 2001 From: Amitesh Singh Date: Mon, 12 Jun 2017 16:06:22 +0900 Subject: elm: rename elm slider to Efl.Ui.Slider ref T5361 --- po/POTFILES.in | 2 +- src/Makefile_Elementary.am | 8 +- src/bin/elementary/test_evas_snapshot.c | 4 +- src/bin/elementary/test_ui_box.c | 10 +- src/bin/elementary/test_ui_grid.c | 8 +- src/lib/elementary/efl_ui_slider.c | 1691 ++++++++++++++++++++++++++++ src/lib/elementary/efl_ui_slider.eo | 190 ++++ src/lib/elementary/efl_ui_slider_eo.h | 1 + src/lib/elementary/efl_ui_slider_private.h | 91 ++ src/lib/elementary/elc_player.c | 8 +- src/lib/elementary/elm_slider.c | 1691 ---------------------------- src/lib/elementary/elm_slider.eo | 192 ---- src/lib/elementary/elm_slider.h | 2 +- src/lib/elementary/elm_slider_eo.h | 1 - src/lib/elementary/elm_slider_legacy.h | 2 +- src/lib/elementary/elm_widget_slider.h | 91 -- src/modules/elementary/prefs/elm_slider.c | 2 +- 17 files changed, 1996 insertions(+), 1998 deletions(-) create mode 100644 src/lib/elementary/efl_ui_slider.c create mode 100644 src/lib/elementary/efl_ui_slider.eo create mode 100644 src/lib/elementary/efl_ui_slider_eo.h create mode 100644 src/lib/elementary/efl_ui_slider_private.h delete mode 100644 src/lib/elementary/elm_slider.c delete mode 100644 src/lib/elementary/elm_slider.eo delete mode 100644 src/lib/elementary/elm_slider_eo.h delete mode 100644 src/lib/elementary/elm_widget_slider.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 43f559739a..08a4de46b9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -156,7 +156,7 @@ src/lib/elementary/elm_route.c src/lib/elementary/elm_scroller.c src/lib/elementary/elm_segment_control.c src/lib/elementary/elm_separator.c -src/lib/elementary/elm_slider.c +src/lib/elementary/efl_ui_slider.c src/lib/elementary/elm_slideshow.c src/lib/elementary/elm_spinner.c src/lib/elementary/elm_store.c diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 764fba46e4..e5c6704da7 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -61,7 +61,7 @@ elm_public_eolian_files = \ lib/elementary/efl_ui_radio.eo \ lib/elementary/elm_route.eo \ lib/elementary/elm_scroller.eo \ - lib/elementary/elm_slider.eo \ + lib/elementary/efl_ui_slider.eo \ lib/elementary/elm_spinner.eo \ lib/elementary/elm_sys_notify_interface.eo \ lib/elementary/elm_sys_notify.eo \ @@ -272,7 +272,7 @@ includesunstable_HEADERS = \ lib/elementary/elm_widget_scroller.h \ lib/elementary/elm_widget_segment_control.h \ lib/elementary/elm_widget_separator.h \ - lib/elementary/elm_widget_slider.h \ + lib/elementary/efl_ui_slider_private.h \ lib/elementary/elm_widget_slideshow.h \ lib/elementary/elm_widget_spinner.h \ lib/elementary/elm_widget_table.h \ @@ -492,7 +492,7 @@ includesub_HEADERS = \ lib/elementary/elm_separator_legacy.h \ lib/elementary/elm_slider.h \ lib/elementary/elm_slider_common.h \ - lib/elementary/elm_slider_eo.h \ + lib/elementary/efl_ui_slider_eo.h \ lib/elementary/elm_slider_legacy.h \ lib/elementary/elm_slideshow.h \ lib/elementary/elm_slideshow_common.h \ @@ -640,7 +640,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/elm_scroller.c \ lib/elementary/elm_segment_control.c \ lib/elementary/elm_separator.c \ - lib/elementary/elm_slider.c \ + lib/elementary/efl_ui_slider.c \ lib/elementary/elm_slideshow.c \ lib/elementary/elm_spinner.c \ lib/elementary/elm_store.c \ diff --git a/src/bin/elementary/test_evas_snapshot.c b/src/bin/elementary/test_evas_snapshot.c index d7aa804efb..e1857ff417 100644 --- a/src/bin/elementary/test_evas_snapshot.c +++ b/src/bin/elementary/test_evas_snapshot.c @@ -174,7 +174,7 @@ test_evas_snapshot(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_pack_grid(grid, o, 0, 0, GRID_SIZE, GRID_SIZE); // Controls - efl_add(ELM_SLIDER_CLASS, win, + efl_add(EFL_UI_SLIDER_CLASS, win, elm_object_text_set(efl_added, "Blur radius: "), elm_slider_min_max_set(efl_added, 0, 64), elm_slider_value_set(efl_added, 5), @@ -182,7 +182,7 @@ test_evas_snapshot(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0), efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), efl_pack_grid(grid, efl_added, 0, GRID_SIZE, GRID_SIZE, 1), - efl_event_callback_add(efl_added, ELM_SLIDER_EVENT_CHANGED, _radius_set, win), + efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED, _radius_set, win), efl_gfx_visible_set(efl_added, 1)); box = efl_add(EFL_UI_BOX_CLASS, win, diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c index 5b418205eb..beeb7318c0 100644 --- a/src/bin/elementary/test_ui_box.c +++ b/src/bin/elementary/test_ui_box.c @@ -372,7 +372,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, user_min_slider_cb, NULL); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, user_min_slider_cb, NULL); elm_slider_min_max_set(o, 0, 250); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 0); @@ -399,7 +399,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, padding_slider_cb, win); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, padding_slider_cb, win); elm_slider_min_max_set(o, 0, 40); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 10); @@ -426,7 +426,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, margin_slider_cb, win); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, margin_slider_cb, win); elm_slider_min_max_set(o, 0, 40); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 10); @@ -453,7 +453,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, alignv_slider_cb, win); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, alignv_slider_cb, win); elm_slider_min_max_set(o, -0.1, 1.0); elm_slider_step_set(o, 0.1); elm_slider_value_set(o, 0.5); @@ -467,7 +467,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 0); efl_gfx_size_hint_min_set(o, 100, 0); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, alignh_slider_cb, win); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, alignh_slider_cb, win); elm_slider_min_max_set(o, -0.1, 1.0); elm_slider_step_set(o, 0.1); elm_slider_value_set(o, 0.5); diff --git a/src/bin/elementary/test_ui_grid.c b/src/bin/elementary/test_ui_grid.c index 62dd81391f..baa17ae621 100644 --- a/src/bin/elementary/test_ui_grid.c +++ b/src/bin/elementary/test_ui_grid.c @@ -286,7 +286,7 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, user_min_slider_cb, NULL); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, user_min_slider_cb, NULL); elm_slider_min_max_set(o, 0, 250); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 0); @@ -313,7 +313,7 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, padding_slider_cb, grid); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, padding_slider_cb, grid); elm_slider_min_max_set(o, 0, 40); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 10); @@ -340,7 +340,7 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, margin_slider_cb, grid); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, margin_slider_cb, grid); elm_slider_min_max_set(o, 0, 40); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 10); @@ -367,7 +367,7 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i elm_slider_horizontal_set(o, 0); efl_gfx_size_hint_align_set(o, 0.5, -1); efl_gfx_size_hint_weight_set(o, 1, 1); - efl_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, btnmargins_slider_cb, grid); + efl_event_callback_add(o, EFL_UI_SLIDER_EVENT_CHANGED, btnmargins_slider_cb, grid); elm_slider_min_max_set(o, 0, 40); elm_slider_inverted_set(o, 1); elm_slider_value_set(o, 10); diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c new file mode 100644 index 0000000000..4264a2cefc --- /dev/null +++ b/src/lib/elementary/efl_ui_slider.c @@ -0,0 +1,1691 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED +#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED +#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED +#define ELM_LAYOUT_PROTECTED + +#include + +#include "elm_priv.h" +#include "efl_ui_slider_private.h" +#include "elm_widget_layout.h" + +#define MY_CLASS EFL_UI_SLIDER_CLASS + +#define MY_CLASS_NAME "Efl.Ui.Slider" +#define MY_CLASS_NAME_LEGACY "elm_slider" +#define SLIDER_DELAY_CHANGED_INTERVAL 0.2 +#define SLIDER_STEP 0.05 + +static const Elm_Layout_Part_Alias_Description _content_aliases[] = +{ + {"icon", "elm.swallow.icon"}, + {"end", "elm.swallow.end"}, + {NULL, NULL} +}; + +static const Elm_Layout_Part_Alias_Description _text_aliases[] = +{ + {"default", "elm.text"}, + {NULL, NULL} +}; + +static const char SIG_CHANGED[] = "changed"; +static const char SIG_DELAY_CHANGED[] = "delay,changed"; +static const char SIG_DRAG_START[] = "slider,drag,start"; +static const char SIG_DRAG_STOP[] = "slider,drag,stop"; +static const Evas_Smart_Cb_Description _smart_callbacks[] = { + {SIG_CHANGED, ""}, + {SIG_DELAY_CHANGED, ""}, + {SIG_DRAG_START, ""}, + {SIG_DRAG_STOP, ""}, + {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */ + {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */ + {SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */ + {SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */ + {NULL, NULL} +}; + +static void _min_max_set(Evas_Object *obj); + +static Eina_Bool _key_action_drag(Evas_Object *obj, const char *params); + +static const Elm_Action key_actions[] = { + {"drag", _key_action_drag}, + {NULL, NULL} +}; + +static Eina_Bool +_delay_change(void *data) +{ + ELM_SLIDER_DATA_GET(data, sd); + + sd->delay = NULL; + efl_event_callback_legacy_call(data, EFL_UI_SLIDER_EVENT_DELAY_CHANGED, NULL); + + if (_elm_config->atspi_mode) + elm_interface_atspi_accessible_value_changed_signal_emit(data); + + return ECORE_CALLBACK_CANCEL; +} + +static inline Eina_Bool +_is_horizontal(Efl_Orient orientation) +{ + if (orientation == EFL_ORIENT_LEFT || + orientation == EFL_ORIENT_RIGHT) + return EINA_TRUE; + + return EINA_FALSE; +} + +static inline Eina_Bool +_is_inverted(Efl_Orient orientation) +{ + if (orientation == EFL_ORIENT_LEFT || + orientation == EFL_ORIENT_UP) + return EINA_TRUE; + + return EINA_FALSE; +} + +static Efl_Orient +_orientation_get(Eina_Bool horizontal, Eina_Bool inverted) +{ + if (horizontal) + { + if (inverted) + return EFL_ORIENT_LEFT; + else + return EFL_ORIENT_RIGHT; + } + else + { + if (inverted) + return EFL_ORIENT_UP; + else + return EFL_ORIENT_DOWN; + } +} + +static void +_val_fetch(Evas_Object *obj, Eina_Bool user_event) +{ + Eina_Bool rtl; + double posx = 0.0, posy = 0.0, pos = 0.0, val; + double posx2 = 0.0, posy2 = 0.0, pos2 = 0.0, val2; + + ELM_SLIDER_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + edje_object_part_drag_value_get + (wd->resize_obj, "elm.dragable.slider", &posx, &posy); + if (_is_horizontal(sd->orientation)) pos = posx; + else pos = posy; + + edje_object_part_drag_value_get + (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); + if (_is_horizontal(sd->orientation)) pos2 = posx2; + else pos2 = posy2; + + rtl = elm_widget_mirrored_get(obj); + if ((!rtl && _is_inverted(sd->orientation)) || + (rtl && ((sd->orientation == EFL_ORIENT_UP) || + (sd->orientation == EFL_ORIENT_RIGHT)))) + { + pos = 1.0 - pos; + pos2 = 1.0 - pos2; + } + + val = (pos * (sd->val_max - sd->val_min)) + sd->val_min; + val2 = (pos2 * (sd->val_max - sd->val_min)) + sd->val_min; + + if (fabs(val - sd->val) > DBL_EPSILON) + { + sd->val = val; + sd->range_from = val; + if (user_event) + { + efl_event_callback_legacy_call(obj, EFL_UI_SLIDER_EVENT_CHANGED, NULL); + ecore_timer_del(sd->delay); + sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj); + } + } + if (fabs(val2 - sd->range_to) > DBL_EPSILON) + { + sd->range_to = val2; + if (user_event) + { + efl_event_callback_legacy_call(obj, EFL_UI_SLIDER_EVENT_CHANGED, NULL); + ecore_timer_del(sd->delay); + sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj); + } + } +} + +static void +_val_set(Evas_Object *obj) +{ + Eina_Bool rtl; + double pos, pos2; + + ELM_SLIDER_DATA_GET(obj, sd); + + if (sd->val_max > sd->val_min) + { + pos = (sd->val - sd->val_min) / (sd->val_max - sd->val_min); + pos2 = (sd->range_to - sd->val_min) / (sd->val_max - sd->val_min); + } + else + { + pos = 0.0; + pos2 = 0.0; + } + + if (pos < 0.0) pos = 0.0; + else if (pos > 1.0) + pos = 1.0; + if (pos2 < 0.0) pos2 = 0.0; + else if (pos2 > 1.0) + pos2 = 1.0; + + rtl = elm_widget_mirrored_get(obj); + if ((!rtl && _is_inverted(sd->orientation)) || + (rtl && ((sd->orientation == EFL_ORIENT_UP) || + (sd->orientation == EFL_ORIENT_RIGHT)))) + { + pos = 1.0 - pos; + pos2 = 1.0 - pos2; + } + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable.slider", pos, pos); + + if (sd->range_enable) + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable2.slider", pos2, pos2); + + // emit accessiblity event also if value was chagend by API + if (_elm_config->atspi_mode) + elm_interface_atspi_accessible_value_changed_signal_emit(obj); +} + +static void +_units_set(Evas_Object *obj) +{ + ELM_SLIDER_DATA_GET(obj, sd); + + if (sd->units_format_func) + { + char *buf; + + buf = sd->units_format_func(sd->val); + if (buf) + { + elm_layout_text_set(obj, "elm.units", buf); + if (!sd->units_show) + { + elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); + sd->units_show = EINA_TRUE; + } + } + else + { + elm_layout_text_set(obj, "elm.units", NULL); + if (sd->units_show) + { + elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); + sd->units_show = EINA_FALSE; + } + } + if (sd->units_format_free) sd->units_format_free(buf); + } + else if (sd->units) + { + char buf[1024]; + + if (!sd->range_enable) + snprintf(buf, sizeof(buf), sd->units, sd->val); + else + { + double v1, v2; + + elm_slider_range_get(obj, &v1, &v2); + snprintf(buf, sizeof(buf), sd->units, v2 - v1); + } + + elm_layout_text_set(obj, "elm.units", buf); + if (!sd->units_show) + { + elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); + sd->units_show = EINA_TRUE; + } + } + else + { + elm_layout_text_set(obj, "elm.units", NULL); + if (sd->units_show) + { + elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); + sd->units_show = EINA_FALSE; + } + } +} + +static void +_indicator_set(Evas_Object *obj) +{ + ELM_SLIDER_DATA_GET(obj, sd); + + if (sd->indicator_format_func) + { + char *buf; + + buf = sd->indicator_format_func(sd->val); + elm_layout_text_set(obj, "elm.indicator", buf); + elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf); + if (sd->popup) + edje_object_part_text_set(sd->popup, "elm.indicator", buf); + if (sd->popup2) + { + if (sd->indicator_format_free) sd->indicator_format_free(buf); + buf = sd->indicator_format_func(sd->range_to); + elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf); + edje_object_part_text_set(sd->popup2, "elm.indicator", buf); + } + + if (sd->indicator_format_free) sd->indicator_format_free(buf); + } + else if (sd->indicator) + { + char buf[1024]; + + snprintf(buf, sizeof(buf), sd->indicator, sd->val); + elm_layout_text_set(obj, "elm.indicator", buf); + elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf); + if (sd->popup) + edje_object_part_text_set(sd->popup, "elm.indicator", buf); + if (sd->popup2) + { + memset(buf, 0, 1024); + snprintf(buf, sizeof(buf), sd->indicator, sd->range_to); + elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf); + edje_object_part_text_set(sd->popup2, "elm.indicator", buf); + } + } + else + { + elm_layout_text_set(obj, "elm.indicator", NULL); + elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", NULL); + if (sd->popup) + edje_object_part_text_set(sd->popup, "elm.indicator", NULL); + if (sd->popup2) + { + elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", NULL); + edje_object_part_text_set(sd->popup2, "elm.indicator", NULL); + } + } +} + +static void +_slider_update(Evas_Object *obj, Eina_Bool user_event) +{ + _val_fetch(obj, user_event); + evas_object_smart_changed(obj); +} + +static void +_drag(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + _slider_update(data, EINA_TRUE); +} + +static void +_drag_start(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + if (!elm_widget_focus_get(data)) + elm_object_focus_set(data, EINA_TRUE); + _slider_update(data, EINA_TRUE); + efl_event_callback_legacy_call(data, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_START, NULL); + elm_widget_scroll_freeze_push(data); +} + +static void +_drag_stop(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + _slider_update(data, EINA_TRUE); + efl_event_callback_legacy_call(data, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); + elm_widget_scroll_freeze_pop(data); +} + +static void +_drag_step(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + _slider_update(data, EINA_TRUE); +} + +static void +_drag_up(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + double step; + + ELM_SLIDER_DATA_GET(data, sd); + step = sd->step; + + if (_is_inverted(sd->orientation)) step *= -1.0; + + ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); + edje_object_part_drag_step + (wd->resize_obj, "elm.dragable.slider", step, step); +} + +static void +_drag_down(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + double step; + + ELM_SLIDER_DATA_GET(data, sd); + step = -sd->step; + + if (_is_inverted(sd->orientation)) step *= -1.0; + + ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); + edje_object_part_drag_step + (wd->resize_obj, "elm.dragable.slider", step, step); +} + +static void +_popup_show(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + ELM_SLIDER_DATA_GET(data, sd); + if (sd->popup && + (sd->indicator_visible_mode != ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE)) + { + evas_object_raise(sd->popup); + evas_object_show(sd->popup); + sd->popup_visible = EINA_TRUE; + edje_object_signal_emit(sd->popup, "popup,show", "elm"); // XXX: for compat + edje_object_signal_emit(sd->popup, "elm,popup,show", "elm"); + } + if (sd->popup2 && + (sd->indicator_visible_mode != ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE)) + { + evas_object_raise(sd->popup2); + evas_object_show(sd->popup2); + edje_object_signal_emit(sd->popup2, "popup,show", "elm"); // XXX: for compat + edje_object_signal_emit(sd->popup2, "elm,popup,show", "elm"); + } + ELM_SAFE_FREE(sd->wheel_indicator_timer, ecore_timer_del); +} + +static void +_popup_hide(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + ELM_SLIDER_DATA_GET(data, sd); + + if (!sd->popup_visible || !sd->popup) return; + + if (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) return; + if ((sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS) && + elm_widget_focus_get(data)) + return; + + edje_object_signal_emit(sd->popup, "popup,hide", "elm"); // XXX: for compat + edje_object_signal_emit(sd->popup, "elm,popup,hide", "elm"); + + if (sd->popup2) + { + edje_object_signal_emit(sd->popup2, "popup,hide", "elm"); // XXX: for compat + edje_object_signal_emit(sd->popup2, "elm,popup,hide", "elm"); + } +} + +static void +_popup_hide_done(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission EINA_UNUSED, + const char *source EINA_UNUSED) +{ + ELM_SLIDER_DATA_GET(data, sd); + if (sd->popup) + { + if (!((elm_widget_focus_get(data)) && + (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) + { + evas_object_hide(sd->popup); + sd->popup_visible = EINA_FALSE; + } + } + if (sd->popup2) + { + if (!((elm_widget_focus_get(data)) && + (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) + { + evas_object_hide(sd->popup2); + } + } +} + +static void +_popup_emit(void *data, + Evas_Object *obj EINA_UNUSED, + const char *emission, + const char *source) +{ + ELM_SLIDER_DATA_GET(data, sd); + if (sd->popup) + { + edje_object_signal_emit(sd->popup, emission, source); + } + if (sd->popup2) + { + edje_object_signal_emit(sd->popup2, emission, source); + } +} + +static Eina_Bool +_key_action_drag(Evas_Object *obj, const char *params) +{ + ELM_SLIDER_DATA_GET(obj, sd); + const char *dir = params; + + if (!strcmp(dir, "left")) + { + if (!_is_horizontal(sd->orientation)) + return EINA_FALSE; + if (!_is_inverted(sd->orientation)) + _drag_down(obj, NULL, NULL, NULL); + else _drag_up(obj, NULL, NULL, NULL); + } + else if (!strcmp(dir, "right")) + { + if (!_is_horizontal(sd->orientation)) + return EINA_FALSE; + if (!_is_inverted(sd->orientation)) + _drag_up(obj, NULL, NULL, NULL); + else _drag_down(obj, NULL, NULL, NULL); + } + else if (!strcmp(dir, "up")) + { + if (_is_horizontal(sd->orientation)) + return EINA_FALSE; + if (_is_inverted(sd->orientation)) + _drag_up(obj, NULL, NULL, NULL); + else _drag_down(obj, NULL, NULL, NULL); + } + else if (!strcmp(dir, "down")) + { + if (_is_horizontal(sd->orientation)) + return EINA_FALSE; + if (_is_inverted(sd->orientation)) + _drag_down(obj, NULL, NULL, NULL); + else _drag_up(obj, NULL, NULL, NULL); + } + else return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +_wheel_indicator_timer_cb(void *data) +{ + ELM_SLIDER_DATA_GET(data, sd); + sd->wheel_indicator_timer = NULL; + + _popup_hide(data, NULL, NULL, NULL); + return ECORE_CALLBACK_CANCEL; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_widget_widget_event(Eo *obj, Efl_Ui_Slider_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) +{ + (void) src; + + if (type == EVAS_CALLBACK_KEY_DOWN) + { + Evas_Event_Key_Down *ev = event_info; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; + + if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions)) + return EINA_FALSE; + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (type == EVAS_CALLBACK_KEY_UP) + { + _popup_hide(obj, NULL, NULL, NULL); + return EINA_FALSE; + } + else if (type == EVAS_CALLBACK_MOUSE_WHEEL) + { + Evas_Event_Mouse_Wheel *mev = event_info; + if (mev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; + + if (mev->z < 0) _drag_up(obj, NULL, NULL, NULL); + else _drag_down(obj, NULL, NULL, NULL); + mev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + _popup_show(obj, NULL, NULL, NULL); + _slider_update(obj, EINA_TRUE); + sd->wheel_indicator_timer = + ecore_timer_add(0.5, _wheel_indicator_timer_cb, obj); + return EINA_TRUE; + + } + else return EINA_FALSE; + + _popup_show(obj, NULL, NULL, NULL); + _slider_update(obj, EINA_TRUE); + + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_widget_activate(Eo *obj, Efl_Ui_Slider_Data *sd, Elm_Activate act) +{ + if (elm_widget_disabled_get(obj)) return EINA_FALSE; + if (act == ELM_ACTIVATE_DEFAULT) return EINA_FALSE; + + if ((act == ELM_ACTIVATE_UP) || + (act == ELM_ACTIVATE_RIGHT)) + { + if (!_is_inverted(sd->orientation)) + _drag_up(obj, NULL, NULL, NULL); + else _drag_down(obj, NULL, NULL, NULL); + } + else if ((act == ELM_ACTIVATE_DOWN) || + (act == ELM_ACTIVATE_LEFT)) + { + if (!_is_inverted(sd->orientation)) + _drag_down(obj, NULL, NULL, NULL); + else _drag_up(obj, NULL, NULL, NULL); + } + + _slider_update(obj, EINA_TRUE); + + return EINA_TRUE; +} + +static void +_visuals_refresh(Evas_Object *obj) +{ + _val_set(obj); + evas_object_smart_changed(obj); +} + +static void +_track_move_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Evas_Coord x, y; + + ELM_SLIDER_DATA_GET(data, sd); + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + evas_object_move(sd->popup, x, y); +} + +static void +_track2_move_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Evas_Coord x, y; + + ELM_SLIDER_DATA_GET(data, sd); + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + evas_object_move(sd->popup2, x, y); +} + +static void +_track_resize_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Evas_Coord w, h; + + ELM_SLIDER_DATA_GET(data, sd); + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + evas_object_resize(sd->popup, w, h); +} + +static void +_track2_resize_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Evas_Coord w, h; + + ELM_SLIDER_DATA_GET(data, sd); + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + evas_object_resize(sd->popup2, w, h); +} + +static void +_popup_add(Efl_Ui_Slider_Data *sd, Eo *obj, Evas_Object **popup, + Evas_Object **track, Eina_Bool is_range) +{ + /* if theme has an overlayed slider mode, then lets support it */ + if (!is_range + && !edje_object_part_exists(elm_layout_edje_get(obj), "elm.track.slider")) + return; + else if (is_range + && !edje_object_part_exists(elm_layout_edje_get(obj), "elm.track2.slider")) + return; + + // XXX popup needs to adapt to theme etc. + *popup = edje_object_add(evas_object_evas_get(obj)); + evas_object_smart_member_add(*popup, obj); + if (_is_horizontal(sd->orientation)) + _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "horizontal/popup", elm_widget_style_get(obj)); + else + _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "vertical/popup", elm_widget_style_get(obj)); + edje_object_scale_set(*popup, efl_ui_scale_get(obj) * + elm_config_scale_get()); + edje_object_signal_callback_add(*popup, "popup,hide,done", "elm", // XXX: for compat + _popup_hide_done, obj); + edje_object_signal_callback_add(*popup, "elm,popup,hide,done", "elm", + _popup_hide_done, obj); + + /* create a rectangle to track position+size of the dragable */ + *track = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_color_set(*track, 0, 0, 0, 0); + evas_object_pass_events_set(*track, EINA_TRUE); + if (!is_range) + { + evas_object_event_callback_add + (*track, EVAS_CALLBACK_MOVE, _track_move_cb, obj); + evas_object_event_callback_add + (*track, EVAS_CALLBACK_RESIZE, _track_resize_cb, obj); + elm_layout_content_set(obj, "elm.track.slider", *track); + } + else + { + evas_object_event_callback_add + (*track, EVAS_CALLBACK_MOVE, _track2_move_cb, obj); + evas_object_event_callback_add + (*track, EVAS_CALLBACK_RESIZE, _track2_resize_cb, obj); + elm_layout_content_set(obj, "elm.track2.slider", *track); + } +} + +EOLIAN static Elm_Theme_Apply +_efl_ui_slider_elm_widget_theme_apply(Eo *obj, Efl_Ui_Slider_Data *sd) +{ + Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED; + ELM_LAYOUT_DATA_GET(obj, ld); + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, ELM_THEME_APPLY_FAILED); + + if (_is_horizontal(sd->orientation)) + { + if (!sd->range_enable) + eina_stringshare_replace(&ld->group, "horizontal"); + else + eina_stringshare_replace(&ld->group, "range/horizontal"); + if (sd->popup) + _elm_theme_set(elm_widget_theme_get(obj), sd->popup, + "slider", "horizontal/popup", + elm_widget_style_get(obj)); + if (sd->popup2) + _elm_theme_set(elm_widget_theme_get(obj), sd->popup2, + "slider", "horizontal/popup", + elm_widget_style_get(obj)); + } + else + { + if (!sd->range_enable) + eina_stringshare_replace(&ld->group, "vertical"); + else + eina_stringshare_replace(&ld->group, "range/vertical"); + + if (sd->popup) + _elm_theme_set(elm_widget_theme_get(obj), sd->popup, + "slider", "vertical/popup", + elm_widget_style_get(obj)); + if (sd->popup2) + _elm_theme_set(elm_widget_theme_get(obj), sd->popup2, + "slider", "vertical/popup", + elm_widget_style_get(obj)); + } + + int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS)); + if (!int_ret) return ELM_THEME_APPLY_FAILED; + + if (sd->popup) + { + edje_object_scale_set(sd->popup, efl_ui_scale_get(obj) * + elm_config_scale_get()); + if (sd->range_enable && sd->popup2) + edje_object_scale_set(sd->popup2, efl_ui_scale_get(obj) * + elm_config_scale_get()); + else if (sd->range_enable && !sd->popup2) + _popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE); + } + else + { + _popup_add(sd, obj, &sd->popup, &sd->track, EINA_FALSE); + if (sd->range_enable && !sd->popup2) + _popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE); + } + + if (_is_horizontal(sd->orientation)) + evas_object_size_hint_min_set + (sd->spacer, (double)sd->size * efl_ui_scale_get(obj) * + elm_config_scale_get(), 1); + else + evas_object_size_hint_min_set + (sd->spacer, 1, (double)sd->size * efl_ui_scale_get(obj) * + elm_config_scale_get()); + + if (sd->range_enable) + elm_layout_signal_emit(obj, "elm,slider,range,enable", "elm"); + else + elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); + + if (_is_inverted(sd->orientation)) + { + elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,inverted,on", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,inverted,on", "elm"); + } + else + { + elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,inverted,off", "elm"); + } + + if (sd->indicator_show) + { + elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); + } + + _min_max_set(obj); + _units_set(obj); + _indicator_set(obj); + _visuals_refresh(obj); + + edje_object_message_signal_process(wd->resize_obj); + if (sd->popup) + edje_object_message_signal_process(sd->popup); + if (sd->popup2) + edje_object_message_signal_process(sd->popup2); + + evas_object_smart_changed(obj); + + return int_ret; +} + +EOLIAN static void +_efl_ui_slider_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + Evas_Coord minw = -1, minh = -1; + + elm_coords_finger_size_adjust(1, &minw, 1, &minh); + edje_object_size_min_restricted_calc + (wd->resize_obj, &minw, &minh, minw, minh); + evas_object_size_hint_min_set(obj, minw, minh); + evas_object_size_hint_max_set(obj, -1, -1); +} + +static void +_move_knob_on_mouse(Evas_Object *obj, double button_x, double button_y) +{ + ELM_SLIDER_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + if (!sd->range_enable) + { + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable.slider", + button_x, button_y); + } + else + { + double posx = 0.0, posy = 0.0, posx2 = 0.0, posy2 = 0.0, diff1, diff2; + + edje_object_part_drag_value_get + (wd->resize_obj, "elm.dragable.slider", &posx, &posy); + edje_object_part_drag_value_get + (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); + + if (_is_horizontal(sd->orientation)) + { + diff1 = fabs(button_x - posx); + diff2 = fabs(button_x - posx2); + } + else + { + diff1 = fabs(button_y - posy); + diff2 = fabs(button_y - posy2); + } + + if (diff1 < diff2) + { + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable.slider", + button_x, button_y); + } + else + { + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable2.slider", + button_x, button_y); + } + } + +} + +static void +_spacer_down_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + ELM_SLIDER_DATA_GET(data, sd); + + Evas_Event_Mouse_Down *ev = event_info; + Evas_Coord x, y, w, h; + double button_x = 0.0, button_y = 0.0; + + sd->spacer_down = EINA_TRUE; + sd->val2 = sd->val; + evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); + sd->downx = ev->canvas.x - x; + sd->downy = ev->canvas.y - y; + if (_is_horizontal(sd->orientation)) + { + button_x = ((double)ev->canvas.x - (double)x) / (double)w; + if (button_x > 1) button_x = 1; + if (button_x < 0) button_x = 0; + } + else + { + button_y = ((double)ev->canvas.y - (double)y) / (double)h; + if (button_y > 1) button_y = 1; + if (button_y < 0) button_y = 0; + } + + _move_knob_on_mouse(data, button_x, button_y); + + if (!elm_widget_focus_get(data)) + elm_object_focus_set(data, EINA_TRUE); + _slider_update(data, EINA_TRUE); + efl_event_callback_legacy_call(data, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_START, NULL); + elm_layout_signal_emit(data, "elm,state,indicator,show", "elm"); +} + +static void +_spacer_move_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + ELM_SLIDER_DATA_GET(data, sd); + + Evas_Coord x, y, w, h; + double button_x = 0.0, button_y = 0.0; + Evas_Event_Mouse_Move *ev = event_info; + + if (sd->spacer_down) + { + Evas_Coord d = 0; + + evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); + if (_is_horizontal(sd->orientation)) + d = abs(ev->cur.canvas.x - x - sd->downx); + else d = abs(ev->cur.canvas.y - y - sd->downy); + if (d > (_elm_config->thumbscroll_threshold - 1)) + { + if (!sd->frozen) + { + elm_widget_scroll_freeze_push(data); + sd->frozen = EINA_TRUE; + } + ev->event_flags &= ~EVAS_EVENT_FLAG_ON_HOLD; + } + + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) + { + if (sd->spacer_down) sd->spacer_down = EINA_FALSE; + _slider_update(data, EINA_TRUE); + efl_event_callback_legacy_call + (data, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); + if (sd->frozen) + { + elm_widget_scroll_freeze_pop(data); + sd->frozen = EINA_FALSE; + } + elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); + elm_slider_value_set(data, sd->val2); + return; + } + if (_is_horizontal(sd->orientation)) + { + button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w; + if (button_x > 1) button_x = 1; + if (button_x < 0) button_x = 0; + } + else + { + button_y = ((double)ev->cur.canvas.y - (double)y) / (double)h; + if (button_y > 1) button_y = 1; + if (button_y < 0) button_y = 0; + } + + _move_knob_on_mouse(data, button_x, button_y); + _slider_update(data, EINA_TRUE); + } +} + +static void +_spacer_up_cb(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + ELM_SLIDER_DATA_GET(data, sd); + + if (!sd->spacer_down) return; + if (sd->spacer_down) sd->spacer_down = EINA_FALSE; + + _slider_update(data, EINA_TRUE); + efl_event_callback_legacy_call(data, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); + + if (sd->frozen) + { + elm_widget_scroll_freeze_pop(data); + sd->frozen = EINA_FALSE; + } + elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); +} + +static void +_min_max_set(Evas_Object *obj) +{ + char *buf_min = NULL; + char *buf_max = NULL; + + ELM_SLIDER_DATA_GET(obj, sd); + + if (sd->units_format_func) + { + buf_min = sd->units_format_func(sd->val_min); + buf_max = sd->units_format_func(sd->val_max); + } + else if (sd->units) + { + int length = eina_stringshare_strlen(sd->units); + + buf_min = alloca(length + 128); + buf_max = alloca(length + 128); + + snprintf((char *)buf_min, length + 128, sd->units, sd->val_min); + snprintf((char *)buf_max, length + 128, sd->units, sd->val_max); + } + + elm_layout_text_set(obj, "elm.units.min", buf_min); + elm_layout_text_set(obj, "elm.units.max", buf_max); + + if (sd->units_format_func && sd->units_format_free) + { + sd->units_format_free(buf_min); + sd->units_format_free(buf_max); + } +} + +EOLIAN static void +_efl_ui_slider_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Slider_Data *sd) +{ + elm_layout_freeze(obj); + + if (_is_horizontal(sd->orientation)) + evas_object_size_hint_min_set + (sd->spacer, (double)sd->size * efl_ui_scale_get(obj) * + elm_config_scale_get(), 1); + else + evas_object_size_hint_min_set + (sd->spacer, 1, (double)sd->size * efl_ui_scale_get(obj) * + elm_config_scale_get()); + + _val_fetch(obj, EINA_FALSE); + _min_max_set(obj); + _units_set(obj); + _indicator_set(obj); + + elm_layout_thaw(obj); +} + +static char * +_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj) +{ + const char *txt = elm_widget_access_info_get(obj); + + if (!txt) txt = elm_layout_text_get(obj, NULL); + if (txt) return strdup(txt); + + return NULL; +} + +static char * +_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) +{ + char *ret; + Eina_Strbuf *buf = eina_strbuf_new(); + const char *txt = elm_layout_text_get(obj, "elm.units"); + + if (txt) eina_strbuf_append(buf, txt); + + if (elm_widget_disabled_get(obj)) + eina_strbuf_append(buf, " state: disabled"); + + if (eina_strbuf_length_get(buf)) + { + ret = eina_strbuf_string_steal(buf); + eina_strbuf_free(buf); + return ret; + } + + eina_strbuf_free(buf); + return NULL; +} + +static void +_on_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + ELM_SLIDER_DATA_GET(obj, sd); + if (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) + _popup_show(obj, NULL, NULL, NULL); +} + +EOLIAN static void +_efl_ui_slider_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Slider_Data *priv) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + efl_canvas_group_add(efl_super(obj, MY_CLASS)); + elm_widget_sub_object_parent_add(obj); + + priv->orientation = EFL_ORIENT_RIGHT; + priv->indicator_show = EINA_TRUE; + priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get(); + priv->val_max = 1.0; + //TODO: customize this time duration from api or theme data. + priv->wheel_indicator_duration = 0.25; + priv->step = SLIDER_STEP; + + if (!elm_layout_theme_set + (obj, "slider", "horizontal", elm_widget_style_get(obj))) + CRI("Failed to set layout!"); + + elm_layout_signal_callback_add(obj, "drag", "*", _drag, obj); + elm_layout_signal_callback_add(obj, "drag,start", "*", _drag_start, obj); + elm_layout_signal_callback_add(obj, "drag,stop", "*", _drag_stop, obj); + elm_layout_signal_callback_add(obj, "drag,step", "*", _drag_step, obj); + elm_layout_signal_callback_add(obj, "drag,page", "*", _drag_stop, obj); + elm_layout_signal_callback_add(obj, "popup,show", "elm", _popup_show, obj); // XXX: for compat + elm_layout_signal_callback_add(obj, "popup,hide", "elm", _popup_hide, obj); // XXX: for compat + elm_layout_signal_callback_add(obj, "elm,popup,show", "elm", _popup_show, obj); + elm_layout_signal_callback_add(obj, "elm,popup,hide", "elm", _popup_hide, obj); + elm_layout_signal_callback_add(obj, "*", "popup,emit", _popup_emit, obj); + edje_object_part_drag_value_set + (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0); + + priv->spacer = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_color_set(priv->spacer, 0, 0, 0, 0); + evas_object_pass_events_set(priv->spacer, EINA_TRUE); + elm_layout_content_set(obj, "elm.swallow.bar", priv->spacer); + + if (!priv->range_enable) + _popup_add(priv, obj, &priv->popup, &priv->track, priv->range_enable); + else + _popup_add(priv, obj, &priv->popup2, &priv->track2, priv->range_enable); + + evas_object_event_callback_add + (priv->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_down_cb, obj); + evas_object_event_callback_add + (priv->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj); + evas_object_event_callback_add + (priv->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj); + + evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL); + + elm_widget_can_focus_set(obj, EINA_TRUE); + + _elm_access_object_register(obj, wd->resize_obj); + _elm_access_text_set + (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("slider")); + _elm_access_callback_set + (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL); + _elm_access_callback_set + (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL); + + evas_object_smart_changed(obj); +} + +EOLIAN static void +_efl_ui_slider_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Slider_Data *sd) +{ + eina_stringshare_del(sd->indicator); + eina_stringshare_del(sd->units); + ecore_timer_del(sd->delay); + ecore_timer_del(sd->wheel_indicator_timer); + evas_object_del(sd->popup); + evas_object_del(sd->popup2); + + efl_canvas_group_del(efl_super(obj, MY_CLASS)); +} + +EOLIAN static const Elm_Layout_Part_Alias_Description* +_efl_ui_slider_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + return _text_aliases; +} + +EOLIAN static const Elm_Layout_Part_Alias_Description* +_efl_ui_slider_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + return _content_aliases; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_range_enabled_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *pd) +{ + return pd->range_enable; +} + +EOLIAN static void +_efl_ui_slider_range_enabled_set(Eo *obj, Efl_Ui_Slider_Data *sd, Eina_Bool enable) +{ + if (sd->range_enable == enable) return; + + sd->range_enable = enable; + + elm_obj_widget_theme_apply(obj); + if (sd->range_enable) + { + elm_layout_signal_emit(obj, "elm,slider,range,enable", "elm"); + if (sd->indicator_show) + edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); + } + else + { + elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); + ELM_SAFE_FREE(sd->popup2, evas_object_del); + } +} + +EOLIAN static void +_efl_ui_slider_range_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *pd, double *from, double *to) +{ + if (from) *from = fmin(pd->range_from, pd->range_to); + if (to) *to = fmax(pd->range_from, pd->range_to); +} + +EOLIAN static void +_efl_ui_slider_range_set(Eo *obj, Efl_Ui_Slider_Data *pd, double from, double to) +{ + pd->range_from = from; + //TODO: remove val later + pd->val = from; + pd->range_to = to; + + if (pd->range_from < pd->val_min) pd->range_from = pd->val_min; + if (pd->range_to > pd->val_max) pd->range_to = pd->val_max; + + _visuals_refresh(obj); +} + +EAPI Evas_Object * +elm_slider_add(Evas_Object *parent) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + Evas_Object *obj = efl_add(MY_CLASS, parent); + return obj; +} + +EOLIAN static Eo * +_efl_ui_slider_efl_object_constructor(Eo *obj, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + obj = efl_constructor(efl_super(obj, MY_CLASS)); + efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); + evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); + elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_SLIDER); + + return obj; +} + +EAPI void +elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size) +{ + efl_ui_progress_span_size_set(obj, size); +} + +EAPI Evas_Coord +elm_slider_span_size_get(const Evas_Object *obj) +{ + return efl_ui_progress_span_size_get(obj); +} + +EAPI void +elm_slider_unit_format_set(Evas_Object *obj, const char *units) +{ + efl_ui_progress_unit_format_set(obj, units); +} + +EAPI const char * +elm_slider_unit_format_get(const Evas_Object *obj) +{ + return efl_ui_progress_unit_format_get(obj); +} + +EAPI void +elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) +{ + Efl_Orient dir; + ELM_SLIDER_DATA_GET(obj, sd); + + dir = _orientation_get(horizontal, _is_inverted(sd->orientation)); + + efl_orientation_set(obj, dir); +} + +EAPI Eina_Bool +elm_slider_horizontal_get(const Evas_Object *obj) +{ + Efl_Orient dir; + dir = efl_orientation_get(obj); + + return _is_horizontal(dir); +} + +EAPI void +elm_slider_value_set(Evas_Object *obj, double val) +{ + efl_ui_progress_value_set(obj, val); +} + +EAPI double +elm_slider_value_get(const Evas_Object *obj) +{ + return efl_ui_progress_value_get(obj); +} + +EAPI void +elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted) +{ + Efl_Orient dir; + ELM_SLIDER_DATA_GET(obj, sd); + + dir = _orientation_get(_is_horizontal(sd->orientation), inverted); + + efl_orientation_set(obj, dir); +} + +EAPI Eina_Bool +elm_slider_inverted_get(const Evas_Object *obj) +{ + Efl_Orient dir; + dir = efl_orientation_get(obj); + + return _is_inverted(dir); +} + +EAPI void +elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func) +{ + ELM_SLIDER_DATA_GET(obj, sd); + + sd->units_format_func = func; + sd->units_format_free = free_func; + + evas_object_smart_changed(obj); +} + +EOLIAN static void +_efl_ui_slider_efl_orientation_orientation_set(Eo *obj, Efl_Ui_Slider_Data *sd, Efl_Orient dir) +{ + sd->orientation = dir; + + elm_obj_widget_theme_apply(obj); +} + +EOLIAN static Efl_Orient +_efl_ui_slider_efl_orientation_orientation_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->orientation; +} + +EOLIAN static void +_efl_ui_slider_efl_ui_progress_span_size_set(Eo *obj, Efl_Ui_Slider_Data *sd, Evas_Coord size) +{ + if (sd->size == size) return; + sd->size = size; + + if (sd->indicator_show) + { + elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); + } + else + { + elm_layout_signal_emit(obj, "elm,state,val,hide", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,val,hide", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,val,hide", "elm"); + } + + evas_object_smart_changed(obj); +} + +EOLIAN static Evas_Coord +_efl_ui_slider_efl_ui_progress_span_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->size; +} + +EOLIAN static void +_efl_ui_slider_efl_ui_progress_unit_format_set(Eo *obj, Efl_Ui_Slider_Data *sd, const char *units) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + eina_stringshare_replace(&sd->units, units); + if (units) + { + elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); + edje_object_message_signal_process(wd->resize_obj); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,units,visible", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,units,visible", "elm"); + } + else + { + elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); + edje_object_message_signal_process(wd->resize_obj); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,units,hidden", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,units,hidden", "elm"); + } + evas_object_smart_changed(obj); +} + +EOLIAN static const char * +_efl_ui_slider_efl_ui_progress_unit_format_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->units; +} + +EOLIAN static void +_efl_ui_slider_indicator_format_set(Eo *obj, Efl_Ui_Slider_Data *sd, const char *indicator) +{ + eina_stringshare_replace(&sd->indicator, indicator); + evas_object_smart_changed(obj); +} + +EOLIAN static const char* +_efl_ui_slider_indicator_format_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->indicator; +} + +EOLIAN static void +_efl_ui_slider_min_max_set(Eo *obj, Efl_Ui_Slider_Data *sd, double min, double max) +{ + if ((sd->val_min == min) && (sd->val_max == max)) return; + sd->val_min = min; + sd->val_max = max; + if (sd->val < sd->val_min) sd->val = sd->val_min; + if (sd->val > sd->val_max) sd->val = sd->val_max; + + _visuals_refresh(obj); +} + +EOLIAN static void +_efl_ui_slider_min_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double *min, double *max) +{ + if (min) *min = sd->val_min; + if (max) *max = sd->val_max; +} + +EOLIAN static void +_efl_ui_slider_efl_ui_progress_progress_value_set(Eo *obj, Efl_Ui_Slider_Data *sd, double val) +{ + if (sd->val == val) return; + sd->val = val; + sd->range_from = val; + + if (sd->val < sd->val_min) sd->val = sd->val_min; + if (sd->val > sd->val_max) sd->val = sd->val_max; + + _visuals_refresh(obj); +} + +EOLIAN static double +_efl_ui_slider_efl_ui_progress_progress_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->val; +} + +EOLIAN static void +_efl_ui_slider_indicator_format_function_set(Eo *obj, Efl_Ui_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func) +{ + sd->indicator_format_func = func; + sd->indicator_format_free = free_func; + evas_object_smart_changed(obj); +} + +EOLIAN static void +_efl_ui_slider_indicator_show_set(Eo *obj, Efl_Ui_Slider_Data *sd, Eina_Bool show) +{ + if (show) + { + sd->indicator_show = EINA_TRUE; + elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); + } + else + { + sd->indicator_show = EINA_FALSE; + elm_layout_signal_emit(obj, "elm,state,val,hide", "elm"); + if (sd->popup) + edje_object_signal_emit(sd->popup, "elm,state,val,hide", "elm"); + if (sd->popup2) + edje_object_signal_emit(sd->popup2, "elm,state,val,hide", "elm"); + } + + evas_object_smart_changed(obj); +} + +EOLIAN static Eina_Bool +_efl_ui_slider_indicator_show_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->indicator_show; +} + +EOLIAN static void +_efl_ui_slider_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double step) +{ + if (sd->step == step) return; + + if (step < 0.0) step = 0.0; + else if (step > 1.0) step = 1.0; + + sd->step = step; +} + +EOLIAN static double +_efl_ui_slider_step_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->step; +} + +EOLIAN static void +_efl_ui_slider_indicator_show_on_focus_set(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, Eina_Bool flag) +{ + if (flag) + sd->indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS; + else + sd->indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_indicator_show_on_focus_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS); +} + +EOLIAN static void +_efl_ui_slider_indicator_visible_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, Elm_Slider_Indicator_Visible_Mode indicator_visible_mode) +{ + if (sd->indicator_visible_mode == indicator_visible_mode) return; + sd->indicator_visible_mode = indicator_visible_mode; +} + +EOLIAN static Elm_Slider_Indicator_Visible_Mode +_efl_ui_slider_indicator_visible_mode_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->indicator_visible_mode; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_widget_on_focus(Eo *obj, Efl_Ui_Slider_Data *sd EINA_UNUSED, Elm_Object_Item *item EINA_UNUSED) +{ + Eina_Bool int_ret = EINA_FALSE; + + int_ret = elm_obj_widget_on_focus(efl_super(obj, MY_CLASS), NULL); + + if ((sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS) && elm_widget_focus_get(obj)) + _popup_show(obj, NULL, NULL, NULL); + else if (!elm_widget_focus_get(obj)) + _popup_hide(obj, NULL, NULL, NULL); + + return int_ret; +} + +EOLIAN static void +_efl_ui_slider_class_constructor(Efl_Class *klass) +{ + evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); +} + +// A11Y Accessibility + +EOLIAN static void +_efl_ui_slider_elm_interface_atspi_value_value_and_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double *value, const char **text) +{ + if (value) *value = sd->val; + if (text) *text = NULL; +} + +EOLIAN static Eina_Bool +_efl_ui_slider_elm_interface_atspi_value_value_and_text_set(Eo *obj, Efl_Ui_Slider_Data *sd, double value, const char *text EINA_UNUSED) +{ + double oldval = sd->val; + + if (value < sd->val_min) value = sd->val_min; + if (value > sd->val_max) value = sd->val_max; + + efl_event_callback_legacy_call(obj, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_START, NULL); + sd->val = value; + _visuals_refresh(obj); + sd->val = oldval; + _slider_update(obj, EINA_TRUE); + efl_event_callback_legacy_call(obj, EFL_UI_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); + + return EINA_TRUE; +} + +EOLIAN static void +_efl_ui_slider_elm_interface_atspi_value_range_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double *lower, double *upper, const char **descr) +{ + if (lower) *lower = sd->val_min; + if (upper) *upper = sd->val_max; + if (descr) *descr = NULL; +} + +EOLIAN static double +_efl_ui_slider_elm_interface_atspi_value_increment_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd) +{ + return sd->step; +} + +EOLIAN const Elm_Atspi_Action * +_efl_ui_slider_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *pd EINA_UNUSED) +{ + static Elm_Atspi_Action atspi_actions[] = { + { "drag,left", "drag", "left", _key_action_drag}, + { "drag,right", "drag", "right", _key_action_drag}, + { "drag,up", "drag", "up", _key_action_drag}, + { "drag,down", "drag", "down", _key_action_drag}, + { NULL, NULL, NULL, NULL} + }; + return &atspi_actions[0]; +} + +// A11Y Accessibility - END + +/* Internal EO APIs and hidden overrides */ + +#define EFL_UI_SLIDER_EXTRA_OPS \ + EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_slider) + +#include "efl_ui_slider.eo.c" diff --git a/src/lib/elementary/efl_ui_slider.eo b/src/lib/elementary/efl_ui_slider.eo new file mode 100644 index 0000000000..dbc8da2cfc --- /dev/null +++ b/src/lib/elementary/efl_ui_slider.eo @@ -0,0 +1,190 @@ +type slider_func_type: __undefined_type; [[Elementary slider function type]] +type slider_freefunc_type: __undefined_type; [[Elementary slider free function type]] + +class Efl.Ui.Slider (Elm.Layout, Efl.Ui.Progress, + Efl.Orientation, + Elm.Interface.Atspi.Value, + Elm.Interface.Atspi_Widget_Action) +{ + [[Elementary slider class]] + legacy_prefix: elm_slider; + methods { + @property indicator_format { + set { + [[Set the format string for the indicator label. + + The slider may display its value somewhere else then unit label, + for example, above the slider knob that is dragged around. This + function sets the format string used for this. + + If $null, indicator label won't be visible. If not it sets the + format string for the label text. To the label text is provided + a floating point value, so the label text can display up to 1 + floating point value. Note that this is optional. + + Use a format string such as "%1.2f meters" for example, and it + will display values like: "3.14 meters" for a value equal to + 3.14159. + + Default is indicator label disabled. + ]] + } + get { + [[Get the indicator label format of the slider. + + The slider may display its value somewhere else then unit label, + for example, above the slider knob that is dragged around. This + function gets the format string used for this. + ]] + } + values { + indicator: string @nullable; [[The format string for the indicator display.]] + } + } + @property indicator_show { + set { + [[Set whether to enlarge slider indicator (augmented knob) or not. + + By default, indicator will be bigger while dragged by the user. + + Warning: It won't display values set with @.indicator_format.set + if you disable indicator. + ]] + } + get { + [[Get whether a given slider widget's enlarging indicator or not.]] + } + values { + show: bool; [[$true will make it enlarge, $false will + let the knob always at default size.]] + } + } + @property min_max { + set { + [[Set the minimum and maximum values for the slider. + + Define the allowed range of values to be selected by the user. + + If actual value is less than $min, it will be updated to $min. + If it is bigger then $max, will be updated to $max. Actual value + can be get with @Efl.Ui.Progress.progress_value.get + + By default, min is equal to 0.0, and max is equal to 1.0. + + Warning: maximum must be greater than minimum, otherwise behavior + is undefined. + ]] + } + get { + [[Get the minimum and maximum values of the slider. + + Note: If only one value is needed, the other pointer can be passed + as $null. + ]] + } + values { + min: double; [[The minimum value.]] + max: double; [[The maximum value.]] + } + } + @property indicator_show_on_focus { + set { + [[Show the indicator of slider on focus.]] + } + get { + [[Get whether the indicator of the slider is set or not.]] + } + values { + flag: bool; [[$true if indicator is shown on focus, $false otherwise]] + } + } + @property step { + set { + [[Set the step by which slider indicator will move. + + This value is used when draggable object is moved automatically + i.e., in case of key event when up/down/left/right key is pressed + or in case when accessibility is set and flick event is used to + inc/dec slider values. By default step value is equal to 0.05. + + @since 1.8 + ]] + } + get { + [[Get the step by which slider indicator moves. + + @since 1.8 + ]] + } + values { + step: double; [[The step value.]] + } + } + @property indicator_visible_mode { + [[Set/Get the visible mode of indicator. + ]] + values { + indicator_visible_mode: Efl.Ui.Slider.Indicator_Visible_Mode; [[The indicator visible mode.]] + } + } + @property indicator_format_function { + set { + [[Set the format function pointer for the indicator label + + Set the callback function to format the indicator string. + ]] + } + values { + func: slider_func_type @nullable; [[The indicator format function.]] + free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]] + } + } + @property range_enabled { + [[ This enables two indicators in slider. + + @since 1.18 + ]] + values { + enable: bool; [[$true if two indicators are enabled, $false otherwise]] + } + } + @property range { + [[ Sets up a start and end range point for the slider + + @since 1.18 + ]] + values { + from: double; [[Range minimum value]] + to: double; [[Range maximum value]] + } + } + } + implements { + class.constructor; + Efl.Object.constructor; + Efl.Canvas.Group.group_calculate; + Elm.Widget.theme_apply; + Elm.Widget.activate; + Elm.Widget.focus_next_manager_is; + Elm.Widget.focus_direction_manager_is; + Elm.Widget.on_focus; + Elm.Widget.widget_event; + Elm.Layout.text_aliases { get; } + Elm.Layout.content_aliases { get; } + Elm.Layout.sizing_eval; + Efl.Ui.Progress.span_size { get; set; } + Efl.Ui.Progress.progress_value { get; set; } + Efl.Ui.Progress.unit_format { get; set; } + Efl.Orientation.orientation { get; set; } + Elm.Interface.Atspi.Value.value_and_text { get; set; } + Elm.Interface.Atspi.Value.range { get; } + Elm.Interface.Atspi.Value.increment { get; } + Elm.Interface.Atspi_Widget_Action.elm_actions { get; } + } + events { + changed; [[Called when slider changed]] + delay,changed; [[Called when delay changed]] + slider,drag,start; [[Called when slider drag started]] + slider,drag,stop; [[Called when slider drag stopped]] + } +} diff --git a/src/lib/elementary/efl_ui_slider_eo.h b/src/lib/elementary/efl_ui_slider_eo.h new file mode 100644 index 0000000000..74abf106f9 --- /dev/null +++ b/src/lib/elementary/efl_ui_slider_eo.h @@ -0,0 +1 @@ +#include "efl_ui_slider.eo.h" diff --git a/src/lib/elementary/efl_ui_slider_private.h b/src/lib/elementary/efl_ui_slider_private.h new file mode 100644 index 0000000000..4667f07a0d --- /dev/null +++ b/src/lib/elementary/efl_ui_slider_private.h @@ -0,0 +1,91 @@ +#ifndef EFL_UI_SLIDER_PRIVATE_H +#define EFL_UI_SLIDER_PRIVATE_H + +#include "Elementary.h" + +/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR + * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT + * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK + * IT AT RUNTIME. + */ + +/** + * @addtogroup Widget + * @{ + * + * @section elm-slider-class The Elementary Slider Class + * + * Elementary, besides having the @ref Slider widget, exposes its + * foundation -- the Elementary Slider Class -- in order to create other + * widgets which are a slider with some more logic on top. + */ + +/** + * Base layout smart data extended with slider instance data. + */ +typedef struct _Efl_Ui_Slider_Data Efl_Ui_Slider_Data; +struct _Efl_Ui_Slider_Data +{ + Evas_Object *spacer, *popup, *popup2, *track, *track2; + Ecore_Timer *delay; + + const char *units; + const char *indicator; + + char *(*indicator_format_func)(double val); + void (*indicator_format_free)(char *str); + + char *(*units_format_func)(double val); + void (*units_format_free)(char *str); + + double val, val_min, val_max, val2, step; + + Ecore_Timer *wheel_indicator_timer; + double wheel_indicator_duration; + Elm_Slider_Indicator_Visible_Mode indicator_visible_mode; /**< indicator_visible_mode of the slider. + This indicates when to show an indicator */ + + Evas_Coord size; + Evas_Coord downx, downy; + Efl_Orient orientation; + + double range_from, range_to; + + Eina_Bool indicator_show : 1; + Eina_Bool spacer_down : 1; + Eina_Bool frozen : 1; + Eina_Bool units_show : 1; + Eina_Bool popup_visible : 1; + Eina_Bool range_enable : 1; +}; + +/** + * @} + */ + +#define ELM_SLIDER_DATA_GET(o, sd) \ + Efl_Ui_Slider_Data * sd = efl_data_scope_get(o, EFL_UI_SLIDER_CLASS) + +#define ELM_SLIDER_DATA_GET_OR_RETURN(o, ptr) \ + ELM_SLIDER_DATA_GET(o, ptr); \ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("No widget data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return; \ + } + +#define ELM_SLIDER_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ + ELM_SLIDER_DATA_GET(o, ptr); \ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("No widget data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return val; \ + } + +#define ELM_SLIDER_CHECK(obj) \ + if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_SLIDER_CLASS))) \ + return + +#endif diff --git a/src/lib/elementary/elc_player.c b/src/lib/elementary/elc_player.c index a8725a2182..bde0f04657 100644 --- a/src/lib/elementary/elc_player.c +++ b/src/lib/elementary/elc_player.c @@ -87,9 +87,9 @@ EFL_CALLBACKS_ARRAY_DEFINE(_emotion_cb, ); EFL_CALLBACKS_ARRAY_DEFINE(_slider_cb, - { ELM_SLIDER_EVENT_CHANGED, _update_position }, - { ELM_SLIDER_EVENT_SLIDER_DRAG_START, _drag_start }, - { ELM_SLIDER_EVENT_SLIDER_DRAG_STOP, _drag_stop } + { EFL_UI_SLIDER_EVENT_CHANGED, _update_position }, + { EFL_UI_SLIDER_EVENT_SLIDER_DRAG_START, _drag_start }, + { EFL_UI_SLIDER_EVENT_SLIDER_DRAG_STOP, _drag_stop } ); static Eina_Bool @@ -657,7 +657,7 @@ _elm_player_efl_canvas_group_group_add(Eo *obj, Elm_Player_Data *priv) elm_layout_content_set(obj, "elm.swallow.media_player.volumeslider", priv->vslider); efl_event_callback_add - (priv->vslider, ELM_SLIDER_EVENT_CHANGED, _update_volume, obj); + (priv->vslider, EFL_UI_SLIDER_EVENT_CHANGED, _update_volume, obj); elm_layout_sizing_eval(obj); elm_widget_can_focus_set(obj, EINA_TRUE); diff --git a/src/lib/elementary/elm_slider.c b/src/lib/elementary/elm_slider.c deleted file mode 100644 index 62e80cb19f..0000000000 --- a/src/lib/elementary/elm_slider.c +++ /dev/null @@ -1,1691 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "elementary_config.h" -#endif - -#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED -#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED -#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED -#define ELM_LAYOUT_PROTECTED - -#include - -#include "elm_priv.h" -#include "elm_widget_slider.h" -#include "elm_widget_layout.h" - -#define MY_CLASS ELM_SLIDER_CLASS - -#define MY_CLASS_NAME "Elm_Slider" -#define MY_CLASS_NAME_LEGACY "elm_slider" -#define SLIDER_DELAY_CHANGED_INTERVAL 0.2 -#define SLIDER_STEP 0.05 - -static const Elm_Layout_Part_Alias_Description _content_aliases[] = -{ - {"icon", "elm.swallow.icon"}, - {"end", "elm.swallow.end"}, - {NULL, NULL} -}; - -static const Elm_Layout_Part_Alias_Description _text_aliases[] = -{ - {"default", "elm.text"}, - {NULL, NULL} -}; - -static const char SIG_CHANGED[] = "changed"; -static const char SIG_DELAY_CHANGED[] = "delay,changed"; -static const char SIG_DRAG_START[] = "slider,drag,start"; -static const char SIG_DRAG_STOP[] = "slider,drag,stop"; -static const Evas_Smart_Cb_Description _smart_callbacks[] = { - {SIG_CHANGED, ""}, - {SIG_DELAY_CHANGED, ""}, - {SIG_DRAG_START, ""}, - {SIG_DRAG_STOP, ""}, - {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */ - {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */ - {SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */ - {SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */ - {NULL, NULL} -}; - -static void _min_max_set(Evas_Object *obj); - -static Eina_Bool _key_action_drag(Evas_Object *obj, const char *params); - -static const Elm_Action key_actions[] = { - {"drag", _key_action_drag}, - {NULL, NULL} -}; - -static Eina_Bool -_delay_change(void *data) -{ - ELM_SLIDER_DATA_GET(data, sd); - - sd->delay = NULL; - efl_event_callback_legacy_call(data, ELM_SLIDER_EVENT_DELAY_CHANGED, NULL); - - if (_elm_config->atspi_mode) - elm_interface_atspi_accessible_value_changed_signal_emit(data); - - return ECORE_CALLBACK_CANCEL; -} - -static inline Eina_Bool -_is_horizontal(Efl_Orient orientation) -{ - if (orientation == EFL_ORIENT_LEFT || - orientation == EFL_ORIENT_RIGHT) - return EINA_TRUE; - - return EINA_FALSE; -} - -static inline Eina_Bool -_is_inverted(Efl_Orient orientation) -{ - if (orientation == EFL_ORIENT_LEFT || - orientation == EFL_ORIENT_UP) - return EINA_TRUE; - - return EINA_FALSE; -} - -static Efl_Orient -_orientation_get(Eina_Bool horizontal, Eina_Bool inverted) -{ - if (horizontal) - { - if (inverted) - return EFL_ORIENT_LEFT; - else - return EFL_ORIENT_RIGHT; - } - else - { - if (inverted) - return EFL_ORIENT_UP; - else - return EFL_ORIENT_DOWN; - } -} - -static void -_val_fetch(Evas_Object *obj, Eina_Bool user_event) -{ - Eina_Bool rtl; - double posx = 0.0, posy = 0.0, pos = 0.0, val; - double posx2 = 0.0, posy2 = 0.0, pos2 = 0.0, val2; - - ELM_SLIDER_DATA_GET(obj, sd); - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - edje_object_part_drag_value_get - (wd->resize_obj, "elm.dragable.slider", &posx, &posy); - if (_is_horizontal(sd->orientation)) pos = posx; - else pos = posy; - - edje_object_part_drag_value_get - (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); - if (_is_horizontal(sd->orientation)) pos2 = posx2; - else pos2 = posy2; - - rtl = elm_widget_mirrored_get(obj); - if ((!rtl && _is_inverted(sd->orientation)) || - (rtl && ((sd->orientation == EFL_ORIENT_UP) || - (sd->orientation == EFL_ORIENT_RIGHT)))) - { - pos = 1.0 - pos; - pos2 = 1.0 - pos2; - } - - val = (pos * (sd->val_max - sd->val_min)) + sd->val_min; - val2 = (pos2 * (sd->val_max - sd->val_min)) + sd->val_min; - - if (fabs(val - sd->val) > DBL_EPSILON) - { - sd->val = val; - sd->range_from = val; - if (user_event) - { - efl_event_callback_legacy_call(obj, ELM_SLIDER_EVENT_CHANGED, NULL); - ecore_timer_del(sd->delay); - sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj); - } - } - if (fabs(val2 - sd->range_to) > DBL_EPSILON) - { - sd->range_to = val2; - if (user_event) - { - efl_event_callback_legacy_call(obj, ELM_SLIDER_EVENT_CHANGED, NULL); - ecore_timer_del(sd->delay); - sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj); - } - } -} - -static void -_val_set(Evas_Object *obj) -{ - Eina_Bool rtl; - double pos, pos2; - - ELM_SLIDER_DATA_GET(obj, sd); - - if (sd->val_max > sd->val_min) - { - pos = (sd->val - sd->val_min) / (sd->val_max - sd->val_min); - pos2 = (sd->range_to - sd->val_min) / (sd->val_max - sd->val_min); - } - else - { - pos = 0.0; - pos2 = 0.0; - } - - if (pos < 0.0) pos = 0.0; - else if (pos > 1.0) - pos = 1.0; - if (pos2 < 0.0) pos2 = 0.0; - else if (pos2 > 1.0) - pos2 = 1.0; - - rtl = elm_widget_mirrored_get(obj); - if ((!rtl && _is_inverted(sd->orientation)) || - (rtl && ((sd->orientation == EFL_ORIENT_UP) || - (sd->orientation == EFL_ORIENT_RIGHT)))) - { - pos = 1.0 - pos; - pos2 = 1.0 - pos2; - } - - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable.slider", pos, pos); - - if (sd->range_enable) - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable2.slider", pos2, pos2); - - // emit accessiblity event also if value was chagend by API - if (_elm_config->atspi_mode) - elm_interface_atspi_accessible_value_changed_signal_emit(obj); -} - -static void -_units_set(Evas_Object *obj) -{ - ELM_SLIDER_DATA_GET(obj, sd); - - if (sd->units_format_func) - { - char *buf; - - buf = sd->units_format_func(sd->val); - if (buf) - { - elm_layout_text_set(obj, "elm.units", buf); - if (!sd->units_show) - { - elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); - sd->units_show = EINA_TRUE; - } - } - else - { - elm_layout_text_set(obj, "elm.units", NULL); - if (sd->units_show) - { - elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); - sd->units_show = EINA_FALSE; - } - } - if (sd->units_format_free) sd->units_format_free(buf); - } - else if (sd->units) - { - char buf[1024]; - - if (!sd->range_enable) - snprintf(buf, sizeof(buf), sd->units, sd->val); - else - { - double v1, v2; - - elm_slider_range_get(obj, &v1, &v2); - snprintf(buf, sizeof(buf), sd->units, v2 - v1); - } - - elm_layout_text_set(obj, "elm.units", buf); - if (!sd->units_show) - { - elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); - sd->units_show = EINA_TRUE; - } - } - else - { - elm_layout_text_set(obj, "elm.units", NULL); - if (sd->units_show) - { - elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); - sd->units_show = EINA_FALSE; - } - } -} - -static void -_indicator_set(Evas_Object *obj) -{ - ELM_SLIDER_DATA_GET(obj, sd); - - if (sd->indicator_format_func) - { - char *buf; - - buf = sd->indicator_format_func(sd->val); - elm_layout_text_set(obj, "elm.indicator", buf); - elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf); - if (sd->popup) - edje_object_part_text_set(sd->popup, "elm.indicator", buf); - if (sd->popup2) - { - if (sd->indicator_format_free) sd->indicator_format_free(buf); - buf = sd->indicator_format_func(sd->range_to); - elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf); - edje_object_part_text_set(sd->popup2, "elm.indicator", buf); - } - - if (sd->indicator_format_free) sd->indicator_format_free(buf); - } - else if (sd->indicator) - { - char buf[1024]; - - snprintf(buf, sizeof(buf), sd->indicator, sd->val); - elm_layout_text_set(obj, "elm.indicator", buf); - elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", buf); - if (sd->popup) - edje_object_part_text_set(sd->popup, "elm.indicator", buf); - if (sd->popup2) - { - memset(buf, 0, 1024); - snprintf(buf, sizeof(buf), sd->indicator, sd->range_to); - elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", buf); - edje_object_part_text_set(sd->popup2, "elm.indicator", buf); - } - } - else - { - elm_layout_text_set(obj, "elm.indicator", NULL); - elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", NULL); - if (sd->popup) - edje_object_part_text_set(sd->popup, "elm.indicator", NULL); - if (sd->popup2) - { - elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", NULL); - edje_object_part_text_set(sd->popup2, "elm.indicator", NULL); - } - } -} - -static void -_slider_update(Evas_Object *obj, Eina_Bool user_event) -{ - _val_fetch(obj, user_event); - evas_object_smart_changed(obj); -} - -static void -_drag(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - _slider_update(data, EINA_TRUE); -} - -static void -_drag_start(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - if (!elm_widget_focus_get(data)) - elm_object_focus_set(data, EINA_TRUE); - _slider_update(data, EINA_TRUE); - efl_event_callback_legacy_call(data, ELM_SLIDER_EVENT_SLIDER_DRAG_START, NULL); - elm_widget_scroll_freeze_push(data); -} - -static void -_drag_stop(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - _slider_update(data, EINA_TRUE); - efl_event_callback_legacy_call(data, ELM_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); - elm_widget_scroll_freeze_pop(data); -} - -static void -_drag_step(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - _slider_update(data, EINA_TRUE); -} - -static void -_drag_up(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - double step; - - ELM_SLIDER_DATA_GET(data, sd); - step = sd->step; - - if (_is_inverted(sd->orientation)) step *= -1.0; - - ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); - edje_object_part_drag_step - (wd->resize_obj, "elm.dragable.slider", step, step); -} - -static void -_drag_down(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - double step; - - ELM_SLIDER_DATA_GET(data, sd); - step = -sd->step; - - if (_is_inverted(sd->orientation)) step *= -1.0; - - ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); - edje_object_part_drag_step - (wd->resize_obj, "elm.dragable.slider", step, step); -} - -static void -_popup_show(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - ELM_SLIDER_DATA_GET(data, sd); - if (sd->popup && - (sd->indicator_visible_mode != ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE)) - { - evas_object_raise(sd->popup); - evas_object_show(sd->popup); - sd->popup_visible = EINA_TRUE; - edje_object_signal_emit(sd->popup, "popup,show", "elm"); // XXX: for compat - edje_object_signal_emit(sd->popup, "elm,popup,show", "elm"); - } - if (sd->popup2 && - (sd->indicator_visible_mode != ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE)) - { - evas_object_raise(sd->popup2); - evas_object_show(sd->popup2); - edje_object_signal_emit(sd->popup2, "popup,show", "elm"); // XXX: for compat - edje_object_signal_emit(sd->popup2, "elm,popup,show", "elm"); - } - ELM_SAFE_FREE(sd->wheel_indicator_timer, ecore_timer_del); -} - -static void -_popup_hide(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - ELM_SLIDER_DATA_GET(data, sd); - - if (!sd->popup_visible || !sd->popup) return; - - if (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) return; - if ((sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS) && - elm_widget_focus_get(data)) - return; - - edje_object_signal_emit(sd->popup, "popup,hide", "elm"); // XXX: for compat - edje_object_signal_emit(sd->popup, "elm,popup,hide", "elm"); - - if (sd->popup2) - { - edje_object_signal_emit(sd->popup2, "popup,hide", "elm"); // XXX: for compat - edje_object_signal_emit(sd->popup2, "elm,popup,hide", "elm"); - } -} - -static void -_popup_hide_done(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission EINA_UNUSED, - const char *source EINA_UNUSED) -{ - ELM_SLIDER_DATA_GET(data, sd); - if (sd->popup) - { - if (!((elm_widget_focus_get(data)) && - (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) - { - evas_object_hide(sd->popup); - sd->popup_visible = EINA_FALSE; - } - } - if (sd->popup2) - { - if (!((elm_widget_focus_get(data)) && - (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) - { - evas_object_hide(sd->popup2); - } - } -} - -static void -_popup_emit(void *data, - Evas_Object *obj EINA_UNUSED, - const char *emission, - const char *source) -{ - ELM_SLIDER_DATA_GET(data, sd); - if (sd->popup) - { - edje_object_signal_emit(sd->popup, emission, source); - } - if (sd->popup2) - { - edje_object_signal_emit(sd->popup2, emission, source); - } -} - -static Eina_Bool -_key_action_drag(Evas_Object *obj, const char *params) -{ - ELM_SLIDER_DATA_GET(obj, sd); - const char *dir = params; - - if (!strcmp(dir, "left")) - { - if (!_is_horizontal(sd->orientation)) - return EINA_FALSE; - if (!_is_inverted(sd->orientation)) - _drag_down(obj, NULL, NULL, NULL); - else _drag_up(obj, NULL, NULL, NULL); - } - else if (!strcmp(dir, "right")) - { - if (!_is_horizontal(sd->orientation)) - return EINA_FALSE; - if (!_is_inverted(sd->orientation)) - _drag_up(obj, NULL, NULL, NULL); - else _drag_down(obj, NULL, NULL, NULL); - } - else if (!strcmp(dir, "up")) - { - if (_is_horizontal(sd->orientation)) - return EINA_FALSE; - if (_is_inverted(sd->orientation)) - _drag_up(obj, NULL, NULL, NULL); - else _drag_down(obj, NULL, NULL, NULL); - } - else if (!strcmp(dir, "down")) - { - if (_is_horizontal(sd->orientation)) - return EINA_FALSE; - if (_is_inverted(sd->orientation)) - _drag_down(obj, NULL, NULL, NULL); - else _drag_up(obj, NULL, NULL, NULL); - } - else return EINA_FALSE; - - return EINA_TRUE; -} - -static Eina_Bool -_wheel_indicator_timer_cb(void *data) -{ - ELM_SLIDER_DATA_GET(data, sd); - sd->wheel_indicator_timer = NULL; - - _popup_hide(data, NULL, NULL, NULL); - return ECORE_CALLBACK_CANCEL; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_widget_widget_event(Eo *obj, Elm_Slider_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) -{ - (void) src; - - if (type == EVAS_CALLBACK_KEY_DOWN) - { - Evas_Event_Key_Down *ev = event_info; - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - - if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions)) - return EINA_FALSE; - ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; - } - else if (type == EVAS_CALLBACK_KEY_UP) - { - _popup_hide(obj, NULL, NULL, NULL); - return EINA_FALSE; - } - else if (type == EVAS_CALLBACK_MOUSE_WHEEL) - { - Evas_Event_Mouse_Wheel *mev = event_info; - if (mev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - - if (mev->z < 0) _drag_up(obj, NULL, NULL, NULL); - else _drag_down(obj, NULL, NULL, NULL); - mev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; - _popup_show(obj, NULL, NULL, NULL); - _slider_update(obj, EINA_TRUE); - sd->wheel_indicator_timer = - ecore_timer_add(0.5, _wheel_indicator_timer_cb, obj); - return EINA_TRUE; - - } - else return EINA_FALSE; - - _popup_show(obj, NULL, NULL, NULL); - _slider_update(obj, EINA_TRUE); - - return EINA_TRUE; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_widget_activate(Eo *obj, Elm_Slider_Data *sd, Elm_Activate act) -{ - if (elm_widget_disabled_get(obj)) return EINA_FALSE; - if (act == ELM_ACTIVATE_DEFAULT) return EINA_FALSE; - - if ((act == ELM_ACTIVATE_UP) || - (act == ELM_ACTIVATE_RIGHT)) - { - if (!_is_inverted(sd->orientation)) - _drag_up(obj, NULL, NULL, NULL); - else _drag_down(obj, NULL, NULL, NULL); - } - else if ((act == ELM_ACTIVATE_DOWN) || - (act == ELM_ACTIVATE_LEFT)) - { - if (!_is_inverted(sd->orientation)) - _drag_down(obj, NULL, NULL, NULL); - else _drag_up(obj, NULL, NULL, NULL); - } - - _slider_update(obj, EINA_TRUE); - - return EINA_TRUE; -} - -static void -_visuals_refresh(Evas_Object *obj) -{ - _val_set(obj); - evas_object_smart_changed(obj); -} - -static void -_track_move_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Evas_Coord x, y; - - ELM_SLIDER_DATA_GET(data, sd); - evas_object_geometry_get(obj, &x, &y, NULL, NULL); - evas_object_move(sd->popup, x, y); -} - -static void -_track2_move_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Evas_Coord x, y; - - ELM_SLIDER_DATA_GET(data, sd); - evas_object_geometry_get(obj, &x, &y, NULL, NULL); - evas_object_move(sd->popup2, x, y); -} - -static void -_track_resize_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Evas_Coord w, h; - - ELM_SLIDER_DATA_GET(data, sd); - evas_object_geometry_get(obj, NULL, NULL, &w, &h); - evas_object_resize(sd->popup, w, h); -} - -static void -_track2_resize_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Evas_Coord w, h; - - ELM_SLIDER_DATA_GET(data, sd); - evas_object_geometry_get(obj, NULL, NULL, &w, &h); - evas_object_resize(sd->popup2, w, h); -} - -static void -_popup_add(Elm_Slider_Data *sd, Eo *obj, Evas_Object **popup, - Evas_Object **track, Eina_Bool is_range) -{ - /* if theme has an overlayed slider mode, then lets support it */ - if (!is_range - && !edje_object_part_exists(elm_layout_edje_get(obj), "elm.track.slider")) - return; - else if (is_range - && !edje_object_part_exists(elm_layout_edje_get(obj), "elm.track2.slider")) - return; - - // XXX popup needs to adapt to theme etc. - *popup = edje_object_add(evas_object_evas_get(obj)); - evas_object_smart_member_add(*popup, obj); - if (_is_horizontal(sd->orientation)) - _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "horizontal/popup", elm_widget_style_get(obj)); - else - _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "vertical/popup", elm_widget_style_get(obj)); - edje_object_scale_set(*popup, efl_ui_scale_get(obj) * - elm_config_scale_get()); - edje_object_signal_callback_add(*popup, "popup,hide,done", "elm", // XXX: for compat - _popup_hide_done, obj); - edje_object_signal_callback_add(*popup, "elm,popup,hide,done", "elm", - _popup_hide_done, obj); - - /* create a rectangle to track position+size of the dragable */ - *track = evas_object_rectangle_add(evas_object_evas_get(obj)); - evas_object_color_set(*track, 0, 0, 0, 0); - evas_object_pass_events_set(*track, EINA_TRUE); - if (!is_range) - { - evas_object_event_callback_add - (*track, EVAS_CALLBACK_MOVE, _track_move_cb, obj); - evas_object_event_callback_add - (*track, EVAS_CALLBACK_RESIZE, _track_resize_cb, obj); - elm_layout_content_set(obj, "elm.track.slider", *track); - } - else - { - evas_object_event_callback_add - (*track, EVAS_CALLBACK_MOVE, _track2_move_cb, obj); - evas_object_event_callback_add - (*track, EVAS_CALLBACK_RESIZE, _track2_resize_cb, obj); - elm_layout_content_set(obj, "elm.track2.slider", *track); - } -} - -EOLIAN static Elm_Theme_Apply -_elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd) -{ - Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED; - ELM_LAYOUT_DATA_GET(obj, ld); - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, ELM_THEME_APPLY_FAILED); - - if (_is_horizontal(sd->orientation)) - { - if (!sd->range_enable) - eina_stringshare_replace(&ld->group, "horizontal"); - else - eina_stringshare_replace(&ld->group, "range/horizontal"); - if (sd->popup) - _elm_theme_set(elm_widget_theme_get(obj), sd->popup, - "slider", "horizontal/popup", - elm_widget_style_get(obj)); - if (sd->popup2) - _elm_theme_set(elm_widget_theme_get(obj), sd->popup2, - "slider", "horizontal/popup", - elm_widget_style_get(obj)); - } - else - { - if (!sd->range_enable) - eina_stringshare_replace(&ld->group, "vertical"); - else - eina_stringshare_replace(&ld->group, "range/vertical"); - - if (sd->popup) - _elm_theme_set(elm_widget_theme_get(obj), sd->popup, - "slider", "vertical/popup", - elm_widget_style_get(obj)); - if (sd->popup2) - _elm_theme_set(elm_widget_theme_get(obj), sd->popup2, - "slider", "vertical/popup", - elm_widget_style_get(obj)); - } - - int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS)); - if (!int_ret) return ELM_THEME_APPLY_FAILED; - - if (sd->popup) - { - edje_object_scale_set(sd->popup, efl_ui_scale_get(obj) * - elm_config_scale_get()); - if (sd->range_enable && sd->popup2) - edje_object_scale_set(sd->popup2, efl_ui_scale_get(obj) * - elm_config_scale_get()); - else if (sd->range_enable && !sd->popup2) - _popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE); - } - else - { - _popup_add(sd, obj, &sd->popup, &sd->track, EINA_FALSE); - if (sd->range_enable && !sd->popup2) - _popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE); - } - - if (_is_horizontal(sd->orientation)) - evas_object_size_hint_min_set - (sd->spacer, (double)sd->size * efl_ui_scale_get(obj) * - elm_config_scale_get(), 1); - else - evas_object_size_hint_min_set - (sd->spacer, 1, (double)sd->size * efl_ui_scale_get(obj) * - elm_config_scale_get()); - - if (sd->range_enable) - elm_layout_signal_emit(obj, "elm,slider,range,enable", "elm"); - else - elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); - - if (_is_inverted(sd->orientation)) - { - elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,inverted,on", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,inverted,on", "elm"); - } - else - { - elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,inverted,off", "elm"); - } - - if (sd->indicator_show) - { - elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); - } - - _min_max_set(obj); - _units_set(obj); - _indicator_set(obj); - _visuals_refresh(obj); - - edje_object_message_signal_process(wd->resize_obj); - if (sd->popup) - edje_object_message_signal_process(sd->popup); - if (sd->popup2) - edje_object_message_signal_process(sd->popup2); - - evas_object_smart_changed(obj); - - return int_ret; -} - -EOLIAN static void -_elm_slider_elm_layout_sizing_eval(Eo *obj, Elm_Slider_Data *_pd EINA_UNUSED) -{ - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - Evas_Coord minw = -1, minh = -1; - - elm_coords_finger_size_adjust(1, &minw, 1, &minh); - edje_object_size_min_restricted_calc - (wd->resize_obj, &minw, &minh, minw, minh); - evas_object_size_hint_min_set(obj, minw, minh); - evas_object_size_hint_max_set(obj, -1, -1); -} - -static void -_move_knob_on_mouse(Evas_Object *obj, double button_x, double button_y) -{ - ELM_SLIDER_DATA_GET(obj, sd); - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - if (!sd->range_enable) - { - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable.slider", - button_x, button_y); - } - else - { - double posx = 0.0, posy = 0.0, posx2 = 0.0, posy2 = 0.0, diff1, diff2; - - edje_object_part_drag_value_get - (wd->resize_obj, "elm.dragable.slider", &posx, &posy); - edje_object_part_drag_value_get - (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); - - if (_is_horizontal(sd->orientation)) - { - diff1 = fabs(button_x - posx); - diff2 = fabs(button_x - posx2); - } - else - { - diff1 = fabs(button_y - posy); - diff2 = fabs(button_y - posy2); - } - - if (diff1 < diff2) - { - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable.slider", - button_x, button_y); - } - else - { - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable2.slider", - button_x, button_y); - } - } - -} - -static void -_spacer_down_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info) -{ - ELM_SLIDER_DATA_GET(data, sd); - - Evas_Event_Mouse_Down *ev = event_info; - Evas_Coord x, y, w, h; - double button_x = 0.0, button_y = 0.0; - - sd->spacer_down = EINA_TRUE; - sd->val2 = sd->val; - evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); - sd->downx = ev->canvas.x - x; - sd->downy = ev->canvas.y - y; - if (_is_horizontal(sd->orientation)) - { - button_x = ((double)ev->canvas.x - (double)x) / (double)w; - if (button_x > 1) button_x = 1; - if (button_x < 0) button_x = 0; - } - else - { - button_y = ((double)ev->canvas.y - (double)y) / (double)h; - if (button_y > 1) button_y = 1; - if (button_y < 0) button_y = 0; - } - - _move_knob_on_mouse(data, button_x, button_y); - - if (!elm_widget_focus_get(data)) - elm_object_focus_set(data, EINA_TRUE); - _slider_update(data, EINA_TRUE); - efl_event_callback_legacy_call(data, ELM_SLIDER_EVENT_SLIDER_DRAG_START, NULL); - elm_layout_signal_emit(data, "elm,state,indicator,show", "elm"); -} - -static void -_spacer_move_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info) -{ - ELM_SLIDER_DATA_GET(data, sd); - - Evas_Coord x, y, w, h; - double button_x = 0.0, button_y = 0.0; - Evas_Event_Mouse_Move *ev = event_info; - - if (sd->spacer_down) - { - Evas_Coord d = 0; - - evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); - if (_is_horizontal(sd->orientation)) - d = abs(ev->cur.canvas.x - x - sd->downx); - else d = abs(ev->cur.canvas.y - y - sd->downy); - if (d > (_elm_config->thumbscroll_threshold - 1)) - { - if (!sd->frozen) - { - elm_widget_scroll_freeze_push(data); - sd->frozen = EINA_TRUE; - } - ev->event_flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - } - - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) - { - if (sd->spacer_down) sd->spacer_down = EINA_FALSE; - _slider_update(data, EINA_TRUE); - efl_event_callback_legacy_call - (data, ELM_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); - if (sd->frozen) - { - elm_widget_scroll_freeze_pop(data); - sd->frozen = EINA_FALSE; - } - elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); - elm_slider_value_set(data, sd->val2); - return; - } - if (_is_horizontal(sd->orientation)) - { - button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w; - if (button_x > 1) button_x = 1; - if (button_x < 0) button_x = 0; - } - else - { - button_y = ((double)ev->cur.canvas.y - (double)y) / (double)h; - if (button_y > 1) button_y = 1; - if (button_y < 0) button_y = 0; - } - - _move_knob_on_mouse(data, button_x, button_y); - _slider_update(data, EINA_TRUE); - } -} - -static void -_spacer_up_cb(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - ELM_SLIDER_DATA_GET(data, sd); - - if (!sd->spacer_down) return; - if (sd->spacer_down) sd->spacer_down = EINA_FALSE; - - _slider_update(data, EINA_TRUE); - efl_event_callback_legacy_call(data, ELM_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); - - if (sd->frozen) - { - elm_widget_scroll_freeze_pop(data); - sd->frozen = EINA_FALSE; - } - elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); -} - -static void -_min_max_set(Evas_Object *obj) -{ - char *buf_min = NULL; - char *buf_max = NULL; - - ELM_SLIDER_DATA_GET(obj, sd); - - if (sd->units_format_func) - { - buf_min = sd->units_format_func(sd->val_min); - buf_max = sd->units_format_func(sd->val_max); - } - else if (sd->units) - { - int length = eina_stringshare_strlen(sd->units); - - buf_min = alloca(length + 128); - buf_max = alloca(length + 128); - - snprintf((char *)buf_min, length + 128, sd->units, sd->val_min); - snprintf((char *)buf_max, length + 128, sd->units, sd->val_max); - } - - elm_layout_text_set(obj, "elm.units.min", buf_min); - elm_layout_text_set(obj, "elm.units.max", buf_max); - - if (sd->units_format_func && sd->units_format_free) - { - sd->units_format_free(buf_min); - sd->units_format_free(buf_max); - } -} - -EOLIAN static void -_elm_slider_efl_canvas_group_group_calculate(Eo *obj, Elm_Slider_Data *sd) -{ - elm_layout_freeze(obj); - - if (_is_horizontal(sd->orientation)) - evas_object_size_hint_min_set - (sd->spacer, (double)sd->size * efl_ui_scale_get(obj) * - elm_config_scale_get(), 1); - else - evas_object_size_hint_min_set - (sd->spacer, 1, (double)sd->size * efl_ui_scale_get(obj) * - elm_config_scale_get()); - - _val_fetch(obj, EINA_FALSE); - _min_max_set(obj); - _units_set(obj); - _indicator_set(obj); - - elm_layout_thaw(obj); -} - -static char * -_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj) -{ - const char *txt = elm_widget_access_info_get(obj); - - if (!txt) txt = elm_layout_text_get(obj, NULL); - if (txt) return strdup(txt); - - return NULL; -} - -static char * -_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) -{ - char *ret; - Eina_Strbuf *buf = eina_strbuf_new(); - const char *txt = elm_layout_text_get(obj, "elm.units"); - - if (txt) eina_strbuf_append(buf, txt); - - if (elm_widget_disabled_get(obj)) - eina_strbuf_append(buf, " state: disabled"); - - if (eina_strbuf_length_get(buf)) - { - ret = eina_strbuf_string_steal(buf); - eina_strbuf_free(buf); - return ret; - } - - eina_strbuf_free(buf); - return NULL; -} - -static void -_on_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - ELM_SLIDER_DATA_GET(obj, sd); - if (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) - _popup_show(obj, NULL, NULL, NULL); -} - -EOLIAN static void -_elm_slider_efl_canvas_group_group_add(Eo *obj, Elm_Slider_Data *priv) -{ - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - efl_canvas_group_add(efl_super(obj, MY_CLASS)); - elm_widget_sub_object_parent_add(obj); - - priv->orientation = EFL_ORIENT_RIGHT; - priv->indicator_show = EINA_TRUE; - priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get(); - priv->val_max = 1.0; - //TODO: customize this time duration from api or theme data. - priv->wheel_indicator_duration = 0.25; - priv->step = SLIDER_STEP; - - if (!elm_layout_theme_set - (obj, "slider", "horizontal", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); - - elm_layout_signal_callback_add(obj, "drag", "*", _drag, obj); - elm_layout_signal_callback_add(obj, "drag,start", "*", _drag_start, obj); - elm_layout_signal_callback_add(obj, "drag,stop", "*", _drag_stop, obj); - elm_layout_signal_callback_add(obj, "drag,step", "*", _drag_step, obj); - elm_layout_signal_callback_add(obj, "drag,page", "*", _drag_stop, obj); - elm_layout_signal_callback_add(obj, "popup,show", "elm", _popup_show, obj); // XXX: for compat - elm_layout_signal_callback_add(obj, "popup,hide", "elm", _popup_hide, obj); // XXX: for compat - elm_layout_signal_callback_add(obj, "elm,popup,show", "elm", _popup_show, obj); - elm_layout_signal_callback_add(obj, "elm,popup,hide", "elm", _popup_hide, obj); - elm_layout_signal_callback_add(obj, "*", "popup,emit", _popup_emit, obj); - edje_object_part_drag_value_set - (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0); - - priv->spacer = evas_object_rectangle_add(evas_object_evas_get(obj)); - evas_object_color_set(priv->spacer, 0, 0, 0, 0); - evas_object_pass_events_set(priv->spacer, EINA_TRUE); - elm_layout_content_set(obj, "elm.swallow.bar", priv->spacer); - - if (!priv->range_enable) - _popup_add(priv, obj, &priv->popup, &priv->track, priv->range_enable); - else - _popup_add(priv, obj, &priv->popup2, &priv->track2, priv->range_enable); - - evas_object_event_callback_add - (priv->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_down_cb, obj); - evas_object_event_callback_add - (priv->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj); - evas_object_event_callback_add - (priv->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj); - - evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL); - - elm_widget_can_focus_set(obj, EINA_TRUE); - - _elm_access_object_register(obj, wd->resize_obj); - _elm_access_text_set - (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("slider")); - _elm_access_callback_set - (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL); - _elm_access_callback_set - (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL); - - evas_object_smart_changed(obj); -} - -EOLIAN static void -_elm_slider_efl_canvas_group_group_del(Eo *obj, Elm_Slider_Data *sd) -{ - eina_stringshare_del(sd->indicator); - eina_stringshare_del(sd->units); - ecore_timer_del(sd->delay); - ecore_timer_del(sd->wheel_indicator_timer); - evas_object_del(sd->popup); - evas_object_del(sd->popup2); - - efl_canvas_group_del(efl_super(obj, MY_CLASS)); -} - -EOLIAN static const Elm_Layout_Part_Alias_Description* -_elm_slider_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *_pd EINA_UNUSED) -{ - return _text_aliases; -} - -EOLIAN static const Elm_Layout_Part_Alias_Description* -_elm_slider_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *_pd EINA_UNUSED) -{ - return _content_aliases; -} - -EOLIAN static Eina_Bool -_elm_slider_range_enabled_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd) -{ - return pd->range_enable; -} - -EOLIAN static void -_elm_slider_range_enabled_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool enable) -{ - if (sd->range_enable == enable) return; - - sd->range_enable = enable; - - elm_obj_widget_theme_apply(obj); - if (sd->range_enable) - { - elm_layout_signal_emit(obj, "elm,slider,range,enable", "elm"); - if (sd->indicator_show) - edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); - } - else - { - elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); - ELM_SAFE_FREE(sd->popup2, evas_object_del); - } -} - -EOLIAN static void -_elm_slider_range_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd, double *from, double *to) -{ - if (from) *from = fmin(pd->range_from, pd->range_to); - if (to) *to = fmax(pd->range_from, pd->range_to); -} - -EOLIAN static void -_elm_slider_range_set(Eo *obj, Elm_Slider_Data *pd, double from, double to) -{ - pd->range_from = from; - //TODO: remove val later - pd->val = from; - pd->range_to = to; - - if (pd->range_from < pd->val_min) pd->range_from = pd->val_min; - if (pd->range_to > pd->val_max) pd->range_to = pd->val_max; - - _visuals_refresh(obj); -} - -EAPI Evas_Object * -elm_slider_add(Evas_Object *parent) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - Evas_Object *obj = efl_add(MY_CLASS, parent); - return obj; -} - -EOLIAN static Eo * -_elm_slider_efl_object_constructor(Eo *obj, Elm_Slider_Data *_pd EINA_UNUSED) -{ - obj = efl_constructor(efl_super(obj, MY_CLASS)); - efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); - evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); - elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_SLIDER); - - return obj; -} - -EAPI void -elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size) -{ - efl_ui_progress_span_size_set(obj, size); -} - -EAPI Evas_Coord -elm_slider_span_size_get(const Evas_Object *obj) -{ - return efl_ui_progress_span_size_get(obj); -} - -EAPI void -elm_slider_unit_format_set(Evas_Object *obj, const char *units) -{ - efl_ui_progress_unit_format_set(obj, units); -} - -EAPI const char * -elm_slider_unit_format_get(const Evas_Object *obj) -{ - return efl_ui_progress_unit_format_get(obj); -} - -EAPI void -elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) -{ - Efl_Orient dir; - ELM_SLIDER_DATA_GET(obj, sd); - - dir = _orientation_get(horizontal, _is_inverted(sd->orientation)); - - efl_orientation_set(obj, dir); -} - -EAPI Eina_Bool -elm_slider_horizontal_get(const Evas_Object *obj) -{ - Efl_Orient dir; - dir = efl_orientation_get(obj); - - return _is_horizontal(dir); -} - -EAPI void -elm_slider_value_set(Evas_Object *obj, double val) -{ - efl_ui_progress_value_set(obj, val); -} - -EAPI double -elm_slider_value_get(const Evas_Object *obj) -{ - return efl_ui_progress_value_get(obj); -} - -EAPI void -elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted) -{ - Efl_Orient dir; - ELM_SLIDER_DATA_GET(obj, sd); - - dir = _orientation_get(_is_horizontal(sd->orientation), inverted); - - efl_orientation_set(obj, dir); -} - -EAPI Eina_Bool -elm_slider_inverted_get(const Evas_Object *obj) -{ - Efl_Orient dir; - dir = efl_orientation_get(obj); - - return _is_inverted(dir); -} - -EAPI void -elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func) -{ - ELM_SLIDER_DATA_GET(obj, sd); - - sd->units_format_func = func; - sd->units_format_free = free_func; - - evas_object_smart_changed(obj); -} - -EOLIAN static void -_elm_slider_efl_orientation_orientation_set(Eo *obj, Elm_Slider_Data *sd, Efl_Orient dir) -{ - sd->orientation = dir; - - elm_obj_widget_theme_apply(obj); -} - -EOLIAN static Efl_Orient -_elm_slider_efl_orientation_orientation_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->orientation; -} - -EOLIAN static void -_elm_slider_efl_ui_progress_span_size_set(Eo *obj, Elm_Slider_Data *sd, Evas_Coord size) -{ - if (sd->size == size) return; - sd->size = size; - - if (sd->indicator_show) - { - elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); - } - else - { - elm_layout_signal_emit(obj, "elm,state,val,hide", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,val,hide", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,val,hide", "elm"); - } - - evas_object_smart_changed(obj); -} - -EOLIAN static Evas_Coord -_elm_slider_efl_ui_progress_span_size_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->size; -} - -EOLIAN static void -_elm_slider_efl_ui_progress_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units) -{ - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - eina_stringshare_replace(&sd->units, units); - if (units) - { - elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); - edje_object_message_signal_process(wd->resize_obj); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,units,visible", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,units,visible", "elm"); - } - else - { - elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm"); - edje_object_message_signal_process(wd->resize_obj); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,units,hidden", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,units,hidden", "elm"); - } - evas_object_smart_changed(obj); -} - -EOLIAN static const char * -_elm_slider_efl_ui_progress_unit_format_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->units; -} - -EOLIAN static void -_elm_slider_indicator_format_set(Eo *obj, Elm_Slider_Data *sd, const char *indicator) -{ - eina_stringshare_replace(&sd->indicator, indicator); - evas_object_smart_changed(obj); -} - -EOLIAN static const char* -_elm_slider_indicator_format_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->indicator; -} - -EOLIAN static void -_elm_slider_min_max_set(Eo *obj, Elm_Slider_Data *sd, double min, double max) -{ - if ((sd->val_min == min) && (sd->val_max == max)) return; - sd->val_min = min; - sd->val_max = max; - if (sd->val < sd->val_min) sd->val = sd->val_min; - if (sd->val > sd->val_max) sd->val = sd->val_max; - - _visuals_refresh(obj); -} - -EOLIAN static void -_elm_slider_min_max_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double *min, double *max) -{ - if (min) *min = sd->val_min; - if (max) *max = sd->val_max; -} - -EOLIAN static void -_elm_slider_efl_ui_progress_progress_value_set(Eo *obj, Elm_Slider_Data *sd, double val) -{ - if (sd->val == val) return; - sd->val = val; - sd->range_from = val; - - if (sd->val < sd->val_min) sd->val = sd->val_min; - if (sd->val > sd->val_max) sd->val = sd->val_max; - - _visuals_refresh(obj); -} - -EOLIAN static double -_elm_slider_efl_ui_progress_progress_value_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->val; -} - -EOLIAN static void -_elm_slider_indicator_format_function_set(Eo *obj, Elm_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func) -{ - sd->indicator_format_func = func; - sd->indicator_format_free = free_func; - evas_object_smart_changed(obj); -} - -EOLIAN static void -_elm_slider_indicator_show_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool show) -{ - if (show) - { - sd->indicator_show = EINA_TRUE; - elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,val,show", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm"); - } - else - { - sd->indicator_show = EINA_FALSE; - elm_layout_signal_emit(obj, "elm,state,val,hide", "elm"); - if (sd->popup) - edje_object_signal_emit(sd->popup, "elm,state,val,hide", "elm"); - if (sd->popup2) - edje_object_signal_emit(sd->popup2, "elm,state,val,hide", "elm"); - } - - evas_object_smart_changed(obj); -} - -EOLIAN static Eina_Bool -_elm_slider_indicator_show_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->indicator_show; -} - -EOLIAN static void -_elm_slider_step_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double step) -{ - if (sd->step == step) return; - - if (step < 0.0) step = 0.0; - else if (step > 1.0) step = 1.0; - - sd->step = step; -} - -EOLIAN static double -_elm_slider_step_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->step; -} - -EOLIAN static void -_elm_slider_indicator_show_on_focus_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, Eina_Bool flag) -{ - if (flag) - sd->indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS; - else - sd->indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT; -} - -EOLIAN static Eina_Bool -_elm_slider_indicator_show_on_focus_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return (sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS); -} - -EOLIAN static void -_elm_slider_indicator_visible_mode_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, Elm_Slider_Indicator_Visible_Mode indicator_visible_mode) -{ - if (sd->indicator_visible_mode == indicator_visible_mode) return; - sd->indicator_visible_mode = indicator_visible_mode; -} - -EOLIAN static Elm_Slider_Indicator_Visible_Mode -_elm_slider_indicator_visible_mode_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->indicator_visible_mode; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Slider_Data *_pd EINA_UNUSED) -{ - return EINA_FALSE; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Slider_Data *_pd EINA_UNUSED) -{ - return EINA_FALSE; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_widget_on_focus(Eo *obj, Elm_Slider_Data *sd EINA_UNUSED, Elm_Object_Item *item EINA_UNUSED) -{ - Eina_Bool int_ret = EINA_FALSE; - - int_ret = elm_obj_widget_on_focus(efl_super(obj, MY_CLASS), NULL); - - if ((sd->indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS) && elm_widget_focus_get(obj)) - _popup_show(obj, NULL, NULL, NULL); - else if (!elm_widget_focus_get(obj)) - _popup_hide(obj, NULL, NULL, NULL); - - return int_ret; -} - -EOLIAN static void -_elm_slider_class_constructor(Efl_Class *klass) -{ - evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); -} - -// A11Y Accessibility - -EOLIAN static void -_elm_slider_elm_interface_atspi_value_value_and_text_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double *value, const char **text) -{ - if (value) *value = sd->val; - if (text) *text = NULL; -} - -EOLIAN static Eina_Bool -_elm_slider_elm_interface_atspi_value_value_and_text_set(Eo *obj, Elm_Slider_Data *sd, double value, const char *text EINA_UNUSED) -{ - double oldval = sd->val; - - if (value < sd->val_min) value = sd->val_min; - if (value > sd->val_max) value = sd->val_max; - - efl_event_callback_legacy_call(obj, ELM_SLIDER_EVENT_SLIDER_DRAG_START, NULL); - sd->val = value; - _visuals_refresh(obj); - sd->val = oldval; - _slider_update(obj, EINA_TRUE); - efl_event_callback_legacy_call(obj, ELM_SLIDER_EVENT_SLIDER_DRAG_STOP, NULL); - - return EINA_TRUE; -} - -EOLIAN static void -_elm_slider_elm_interface_atspi_value_range_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double *lower, double *upper, const char **descr) -{ - if (lower) *lower = sd->val_min; - if (upper) *upper = sd->val_max; - if (descr) *descr = NULL; -} - -EOLIAN static double -_elm_slider_elm_interface_atspi_value_increment_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) -{ - return sd->step; -} - -EOLIAN const Elm_Atspi_Action * -_elm_slider_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd EINA_UNUSED) -{ - static Elm_Atspi_Action atspi_actions[] = { - { "drag,left", "drag", "left", _key_action_drag}, - { "drag,right", "drag", "right", _key_action_drag}, - { "drag,up", "drag", "up", _key_action_drag}, - { "drag,down", "drag", "down", _key_action_drag}, - { NULL, NULL, NULL, NULL} - }; - return &atspi_actions[0]; -} - -// A11Y Accessibility - END - -/* Internal EO APIs and hidden overrides */ - -#define ELM_SLIDER_EXTRA_OPS \ - EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_slider) - -#include "elm_slider.eo.c" diff --git a/src/lib/elementary/elm_slider.eo b/src/lib/elementary/elm_slider.eo deleted file mode 100644 index c70cb304c6..0000000000 --- a/src/lib/elementary/elm_slider.eo +++ /dev/null @@ -1,192 +0,0 @@ -type slider_func_type: __undefined_type; [[Elementary slider function type]] -type slider_freefunc_type: __undefined_type; [[Elementary slider free function type]] - -class Elm.Slider (Elm.Layout, Efl.Ui.Progress, - Efl.Orientation, - Elm.Interface.Atspi.Value, - Elm.Interface.Atspi_Widget_Action) -{ - [[Elementary slider class]] - legacy_prefix: elm_slider; - eo_prefix: elm_obj_slider; - event_prefix: elm_slider; - methods { - @property indicator_format { - set { - [[Set the format string for the indicator label. - - The slider may display its value somewhere else then unit label, - for example, above the slider knob that is dragged around. This - function sets the format string used for this. - - If $null, indicator label won't be visible. If not it sets the - format string for the label text. To the label text is provided - a floating point value, so the label text can display up to 1 - floating point value. Note that this is optional. - - Use a format string such as "%1.2f meters" for example, and it - will display values like: "3.14 meters" for a value equal to - 3.14159. - - Default is indicator label disabled. - ]] - } - get { - [[Get the indicator label format of the slider. - - The slider may display its value somewhere else then unit label, - for example, above the slider knob that is dragged around. This - function gets the format string used for this. - ]] - } - values { - indicator: string @nullable; [[The format string for the indicator display.]] - } - } - @property indicator_show { - set { - [[Set whether to enlarge slider indicator (augmented knob) or not. - - By default, indicator will be bigger while dragged by the user. - - Warning: It won't display values set with @.indicator_format.set - if you disable indicator. - ]] - } - get { - [[Get whether a given slider widget's enlarging indicator or not.]] - } - values { - show: bool; [[$true will make it enlarge, $false will - let the knob always at default size.]] - } - } - @property min_max { - set { - [[Set the minimum and maximum values for the slider. - - Define the allowed range of values to be selected by the user. - - If actual value is less than $min, it will be updated to $min. - If it is bigger then $max, will be updated to $max. Actual value - can be get with @Efl.Ui.Progress.progress_value.get - - By default, min is equal to 0.0, and max is equal to 1.0. - - Warning: maximum must be greater than minimum, otherwise behavior - is undefined. - ]] - } - get { - [[Get the minimum and maximum values of the slider. - - Note: If only one value is needed, the other pointer can be passed - as $null. - ]] - } - values { - min: double; [[The minimum value.]] - max: double; [[The maximum value.]] - } - } - @property indicator_show_on_focus { - set { - [[Show the indicator of slider on focus.]] - } - get { - [[Get whether the indicator of the slider is set or not.]] - } - values { - flag: bool; [[$true if indicator is shown on focus, $false otherwise]] - } - } - @property step { - set { - [[Set the step by which slider indicator will move. - - This value is used when draggable object is moved automatically - i.e., in case of key event when up/down/left/right key is pressed - or in case when accessibility is set and flick event is used to - inc/dec slider values. By default step value is equal to 0.05. - - @since 1.8 - ]] - } - get { - [[Get the step by which slider indicator moves. - - @since 1.8 - ]] - } - values { - step: double; [[The step value.]] - } - } - @property indicator_visible_mode { - [[Set/Get the visible mode of indicator. - ]] - values { - indicator_visible_mode: Efl.Ui.Slider.Indicator_Visible_Mode; [[The indicator visible mode.]] - } - } - @property indicator_format_function { - set { - [[Set the format function pointer for the indicator label - - Set the callback function to format the indicator string. - ]] - } - values { - func: slider_func_type @nullable; [[The indicator format function.]] - free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]] - } - } - @property range_enabled { - [[ This enables two indicators in slider. - - @since 1.18 - ]] - values { - enable: bool; [[$true if two indicators are enabled, $false otherwise]] - } - } - @property range { - [[ Sets up a start and end range point for the slider - - @since 1.18 - ]] - values { - from: double; [[Range minimum value]] - to: double; [[Range maximum value]] - } - } - } - implements { - class.constructor; - Efl.Object.constructor; - Efl.Canvas.Group.group_calculate; - Elm.Widget.theme_apply; - Elm.Widget.activate; - Elm.Widget.focus_next_manager_is; - Elm.Widget.focus_direction_manager_is; - Elm.Widget.on_focus; - Elm.Widget.widget_event; - Elm.Layout.text_aliases { get; } - Elm.Layout.content_aliases { get; } - Elm.Layout.sizing_eval; - Efl.Ui.Progress.span_size { get; set; } - Efl.Ui.Progress.progress_value { get; set; } - Efl.Ui.Progress.unit_format { get; set; } - Efl.Orientation.orientation { get; set; } - Elm.Interface.Atspi.Value.value_and_text { get; set; } - Elm.Interface.Atspi.Value.range { get; } - Elm.Interface.Atspi.Value.increment { get; } - Elm.Interface.Atspi_Widget_Action.elm_actions { get; } - } - events { - changed; [[Called when slider changed]] - delay,changed; [[Called when delay changed]] - slider,drag,start; [[Called when slider drag started]] - slider,drag,stop; [[Called when slider drag stopped]] - } -} diff --git a/src/lib/elementary/elm_slider.h b/src/lib/elementary/elm_slider.h index 00a37c0a58..9264fc6d47 100644 --- a/src/lib/elementary/elm_slider.h +++ b/src/lib/elementary/elm_slider.h @@ -76,7 +76,7 @@ #include "elm_slider_common.h" #ifdef EFL_EO_API_SUPPORT -#include "elm_slider_eo.h" +#include "efl_ui_slider_eo.h" #endif #ifndef EFL_NOLEGACY_API_SUPPORT #include "elm_slider_legacy.h" diff --git a/src/lib/elementary/elm_slider_eo.h b/src/lib/elementary/elm_slider_eo.h deleted file mode 100644 index bb87e3dc29..0000000000 --- a/src/lib/elementary/elm_slider_eo.h +++ /dev/null @@ -1 +0,0 @@ -#include "elm_slider.eo.h" diff --git a/src/lib/elementary/elm_slider_legacy.h b/src/lib/elementary/elm_slider_legacy.h index e6e67de6c5..9fa4546908 100644 --- a/src/lib/elementary/elm_slider_legacy.h +++ b/src/lib/elementary/elm_slider_legacy.h @@ -159,4 +159,4 @@ EAPI const char *elm_slider_unit_format_get(const Evas_Object *obj); */ EAPI void elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func); -#include "elm_slider.eo.legacy.h" \ No newline at end of file +#include "efl_ui_slider.eo.legacy.h" \ No newline at end of file diff --git a/src/lib/elementary/elm_widget_slider.h b/src/lib/elementary/elm_widget_slider.h deleted file mode 100644 index ee23efa194..0000000000 --- a/src/lib/elementary/elm_widget_slider.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef ELM_WIDGET_SLIDER_H -#define ELM_WIDGET_SLIDER_H - -#include "Elementary.h" - -/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR - * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT - * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK - * IT AT RUNTIME. - */ - -/** - * @addtogroup Widget - * @{ - * - * @section elm-slider-class The Elementary Slider Class - * - * Elementary, besides having the @ref Slider widget, exposes its - * foundation -- the Elementary Slider Class -- in order to create other - * widgets which are a slider with some more logic on top. - */ - -/** - * Base layout smart data extended with slider instance data. - */ -typedef struct _Elm_Slider_Data Elm_Slider_Data; -struct _Elm_Slider_Data -{ - Evas_Object *spacer, *popup, *popup2, *track, *track2; - Ecore_Timer *delay; - - const char *units; - const char *indicator; - - char *(*indicator_format_func)(double val); - void (*indicator_format_free)(char *str); - - char *(*units_format_func)(double val); - void (*units_format_free)(char *str); - - double val, val_min, val_max, val2, step; - - Ecore_Timer *wheel_indicator_timer; - double wheel_indicator_duration; - Elm_Slider_Indicator_Visible_Mode indicator_visible_mode; /**< indicator_visible_mode of the slider. - This indicates when to show an indicator */ - - Evas_Coord size; - Evas_Coord downx, downy; - Efl_Orient orientation; - - double range_from, range_to; - - Eina_Bool indicator_show : 1; - Eina_Bool spacer_down : 1; - Eina_Bool frozen : 1; - Eina_Bool units_show : 1; - Eina_Bool popup_visible : 1; - Eina_Bool range_enable : 1; -}; - -/** - * @} - */ - -#define ELM_SLIDER_DATA_GET(o, sd) \ - Elm_Slider_Data * sd = efl_data_scope_get(o, ELM_SLIDER_CLASS) - -#define ELM_SLIDER_DATA_GET_OR_RETURN(o, ptr) \ - ELM_SLIDER_DATA_GET(o, ptr); \ - if (EINA_UNLIKELY(!ptr)) \ - { \ - CRI("No widget data for object %p (%s)", \ - o, evas_object_type_get(o)); \ - return; \ - } - -#define ELM_SLIDER_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ - ELM_SLIDER_DATA_GET(o, ptr); \ - if (EINA_UNLIKELY(!ptr)) \ - { \ - CRI("No widget data for object %p (%s)", \ - o, evas_object_type_get(o)); \ - return val; \ - } - -#define ELM_SLIDER_CHECK(obj) \ - if (EINA_UNLIKELY(!efl_isa((obj), ELM_SLIDER_CLASS))) \ - return - -#endif diff --git a/src/modules/elementary/prefs/elm_slider.c b/src/modules/elementary/prefs/elm_slider.c index 9b88ef0732..961d76a32e 100644 --- a/src/modules/elementary/prefs/elm_slider.c +++ b/src/modules/elementary/prefs/elm_slider.c @@ -27,7 +27,7 @@ elm_prefs_slider_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, evas_object_data_set(obj, "prefs_type", (void *)type); efl_event_callback_add - (obj, ELM_SLIDER_EVENT_CHANGED, _item_changed_cb, cb); + (obj, EFL_UI_SLIDER_EVENT_CHANGED, _item_changed_cb, cb); if (type == ELM_PREFS_TYPE_INT) { elm_slider_unit_format_set(obj, "%1.0f"); -- cgit v1.2.1