From 6d1d6dec7c9404153bd1ff0f6de9d7aa34a2986b Mon Sep 17 00:00:00 2001 From: Anil Kumar Nahak Date: Sat, 29 Nov 2014 15:56:45 +0900 Subject: [PATCH] Slider: Added APIs to set/get slider's indicator visibility mode. Summary: elm_config_slider_indicator_visible_mode_set elm_config_slider_indicator_visible_mode_get The patch will enable the slider's indicator to get visible always visible on focus visible never visible on slider value change Reviewers: raster, seoz Subscribers: sachin.dev Differential Revision: https://phab.enlightenment.org/D1558 --- legacy/elementary/config/default/base.src.in | 1 + legacy/elementary/config/mobile/base.src.in | 1 + legacy/elementary/config/standard/base.src.in | 1 + legacy/elementary/src/lib/elm_config.c | 26 +++++++++++- legacy/elementary/src/lib/elm_config.h | 40 +++++++++++++++++++ legacy/elementary/src/lib/elm_priv.h | 1 + legacy/elementary/src/lib/elm_slider.c | 36 ++++++++++++----- 7 files changed, 95 insertions(+), 11 deletions(-) diff --git a/legacy/elementary/config/default/base.src.in b/legacy/elementary/config/default/base.src.in index 64b278313b..35f9984fa8 100644 --- a/legacy/elementary/config/default/base.src.in +++ b/legacy/elementary/config/default/base.src.in @@ -27,6 +27,7 @@ group "Elm_Config" struct { value "scroll_smooth_future_time" double: 0.0; value "scroll_smooth_time_window" double: 0.01; value "focus_autoscroll_mode" uchar: 0; + value "slider_indicator_visible_mode" int: 0; value "scale" double: 1.0; value "bgpixmap" int: 0; value "compositing" int: 1; diff --git a/legacy/elementary/config/mobile/base.src.in b/legacy/elementary/config/mobile/base.src.in index ff6624303f..4e4afd483a 100644 --- a/legacy/elementary/config/mobile/base.src.in +++ b/legacy/elementary/config/mobile/base.src.in @@ -27,6 +27,7 @@ group "Elm_Config" struct { value "scroll_smooth_future_time" double: 0.0; value "scroll_smooth_time_window" double: 0.01; value "focus_autoscroll_mode" uchar: 0; + value "slider_indicator_visible_mode" int: 0; value "scale" double: 1.0; value "bgpixmap" int: 0; value "compositing" int: 1; diff --git a/legacy/elementary/config/standard/base.src.in b/legacy/elementary/config/standard/base.src.in index 7df943717b..e55f879dd3 100644 --- a/legacy/elementary/config/standard/base.src.in +++ b/legacy/elementary/config/standard/base.src.in @@ -27,6 +27,7 @@ group "Elm_Config" struct { value "scroll_smooth_future_time" double: 0.0; value "scroll_smooth_time_window" double: 0.01; value "focus_autoscroll_mode" uchar: 0; + value "slider_indicator_visible_mode" int: 0; value "scale" double: 1.0; value "bgpixmap" int: 0; value "compositing" int: 1; diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 661aaf8085..5ddea1edb8 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -529,6 +529,7 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, focus_highlight_clip_disable, T_UCHAR); ELM_CONFIG_VAL(D, T, focus_move_policy, T_UCHAR); ELM_CONFIG_VAL(D, T, focus_autoscroll_mode, T_UCHAR); + ELM_CONFIG_VAL(D, T, slider_indicator_visible_mode, T_INT); ELM_CONFIG_VAL(D, T, item_select_on_focus_disable, T_UCHAR); ELM_CONFIG_VAL(D, T, first_item_focus_on_first_focus_in, T_UCHAR); ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT); @@ -1992,7 +1993,18 @@ _env_get(void) else _elm_config->focus_autoscroll_mode = ELM_FOCUS_AUTOSCROLL_MODE_SHOW; } - + s = getenv("ELM_SLIDER_INDICATOR_VISIBLE_MODE"); + if (s) + { + if (!strcmp(s, "ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT")) + _elm_config->slider_indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT; + else if (!strcmp(s, "ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS")) + _elm_config->slider_indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS; + else if (!strcmp(s, "ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS")) + _elm_config->slider_indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS; + else + _elm_config->slider_indicator_visible_mode = ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE; + } s = getenv("ELM_THEME"); if (s) eina_stringshare_replace(&_elm_config->theme, s); @@ -2956,6 +2968,18 @@ elm_config_focus_autoscroll_mode_get(void) return _elm_config->focus_autoscroll_mode; } +EAPI void +elm_config_slider_indicator_visible_mode_set(Elm_Slider_Indicator_Visible_Mode mode) +{ + _elm_config->slider_indicator_visible_mode = mode; +} + +EAPI Elm_Slider_Indicator_Visible_Mode +elm_config_slider_indicator_visible_mode_get(void) +{ + return _elm_config->slider_indicator_visible_mode; +} + EAPI void elm_config_focus_autoscroll_mode_set(Elm_Focus_Autoscroll_Mode mode) { diff --git a/legacy/elementary/src/lib/elm_config.h b/legacy/elementary/src/lib/elm_config.h index ae16b4dc4d..7da1f58725 100644 --- a/legacy/elementary/src/lib/elm_config.h +++ b/legacy/elementary/src/lib/elm_config.h @@ -594,6 +594,46 @@ EAPI Elm_Focus_Autoscroll_Mode elm_config_focus_autoscroll_mode_get(void); */ EAPI void elm_config_focus_autoscroll_mode_set(Elm_Focus_Autoscroll_Mode mode); +/** + * Slider's indicator visiblity mode. + * + * @since 1.12 + * @ingroup Slider + */ + +typedef enum +{ + ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT, /**< show indicator on mouse down or change in slider value */ + ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS, /**< Always show the indicator. */ + ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS, /**< Show the indicator on focus */ + ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE /**< Never show the indicator */ +} Elm_Slider_Indicator_Visible_Mode; + +/** + * Sets the slider's indicator visible mode. + * + * @param obj The slider object. + * @param mode Elm_Slider_Indicator_Visible_Mode. + * viewport. + * + * @ingroup Slider + * @since 1.12 + */ +EAPI void elm_config_slider_indicator_visible_mode_set(Elm_Slider_Indicator_Visible_Mode mode); + +/** + * Get the slider's indicator visible mode. + * + * @param obj The slider object. + * @return @c ELM_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT if not set anything by the user. + * @c ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS, ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS, + * ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE if any of the above is set by user. + * + * @ingroup Slider + * @since 1.12 + */ +EAPI Elm_Slider_Indicator_Visible_Mode elm_config_slider_indicator_visible_mode_get(void); + /** * @} */ diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 5d1c6fa075..719cbf1afe 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -231,6 +231,7 @@ struct _Elm_Config unsigned char item_select_on_focus_disable; /**< This shows the disabled status of select on focus feature. This value is false by default so that select on focus feature is enabled by default.*/ unsigned char first_item_focus_on_first_focus_in; /**< This sets the first item focus on first focus in feature*/ Elm_Focus_Autoscroll_Mode focus_autoscroll_mode; /**< This shows the focus auto scroll mode. By default, @c ELM_FOCUS_AUTOSCROLL_MODE_SHOW is set. */ + Elm_Slider_Indicator_Visible_Mode slider_indicator_visible_mode; /**< this sets the slider indicator visible mode */ int toolbar_shrink_mode; unsigned char fileselector_expand_enable; unsigned char fileselector_double_tap_navigation_enable; diff --git a/legacy/elementary/src/lib/elm_slider.c b/legacy/elementary/src/lib/elm_slider.c index 82707ec08b..6d11d2382b 100644 --- a/legacy/elementary/src/lib/elm_slider.c +++ b/legacy/elementary/src/lib/elm_slider.c @@ -308,7 +308,7 @@ _popup_show(void *data, const char *source EINA_UNUSED) { ELM_SLIDER_DATA_GET(data, sd); - if (sd->popup) + if (sd->popup && _elm_config->slider_indicator_visible_mode != ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE) { evas_object_raise(sd->popup); evas_object_show(sd->popup); @@ -328,7 +328,10 @@ _popup_hide(void *data, if (!sd->popup_visible || !sd->popup) return; - if (!(elm_widget_focus_get(data) && sd->always_popup_show)) + if (_elm_config->slider_indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) return; + + if (!((elm_widget_focus_get(data)) && + (_elm_config->slider_indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) { // XXX: for compat edje_object_signal_emit(sd->popup, "popup,hide", "elm"); @@ -345,7 +348,8 @@ _popup_hide_done(void *data, ELM_SLIDER_DATA_GET(data, sd); if (sd->popup) { - if (!(elm_widget_focus_get(data) && sd->always_popup_show)) + if (!((elm_widget_focus_get(data)) && + (_elm_config->slider_indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS))) { evas_object_hide(sd->popup); sd->popup_visible = EINA_FALSE; @@ -823,6 +827,16 @@ _access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) return NULL; } +static void +_on_show(void *data EINA_UNUSED, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + if (_elm_config->slider_indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS) + _popup_show(obj, NULL, NULL, NULL); +} + EOLIAN static void _elm_slider_evas_object_smart_add(Eo *obj, Elm_Slider_Data *priv) { @@ -867,6 +881,8 @@ _elm_slider_evas_object_smart_add(Eo *obj, Elm_Slider_Data *priv) 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); @@ -1143,18 +1159,18 @@ _elm_slider_step_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) } EOLIAN static void -_elm_slider_indicator_show_on_focus_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, Eina_Bool flag) +_elm_slider_indicator_show_on_focus_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd EINA_UNUSED, Eina_Bool flag) { if (flag) - sd->always_popup_show = EINA_TRUE; + elm_config_slider_indicator_visible_mode_set(ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS); else - sd->always_popup_show = EINA_FALSE; + elm_config_slider_indicator_visible_mode_set(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) +_elm_slider_indicator_show_on_focus_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd EINA_UNUSED) { - return sd->always_popup_show; + return (elm_config_slider_indicator_visible_mode_get() == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS); } EOLIAN static Eina_Bool @@ -1170,13 +1186,13 @@ _elm_slider_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Slide } EOLIAN static Eina_Bool -_elm_slider_elm_widget_on_focus(Eo *obj, Elm_Slider_Data *sd) +_elm_slider_elm_widget_on_focus(Eo *obj, Elm_Slider_Data *sd EINA_UNUSED) { Eina_Bool int_ret = EINA_FALSE; eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_on_focus()); - if (sd->always_popup_show && elm_widget_focus_get(obj)) + if ((_elm_config->slider_indicator_visible_mode == ELM_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS) && elm_widget_focus_get(obj)) _popup_show(obj, NULL, NULL, NULL); else _popup_hide(obj, NULL, NULL, NULL);