2016-02-12 21:30 GMT+01:00 Shilpa Singh <[email protected]>:

> cedric pushed a commit to branch master.
>
>
> http://git.enlightenment.org/core/elementary.git/commit/?id=a3e66305d7601fa4a62629ec2ceb29a1af274915
>
> commit a3e66305d7601fa4a62629ec2ceb29a1af274915
> Author: Shilpa Singh <[email protected]>
> Date:   Fri Feb 12 20:38:36 2016 +0100
>
>     spinner: add min, max filter
>
>     Summary:
>     In spinner's entry allow numbers only with in min/max range
>     Signed-off-by: Shilpa Singh <[email protected]>
>
>     @feature
>
>     Test Plan:
>     1. Set min/max value to spinner
>     2. Enter numbers beyond min/max value
>

Is there a reason why this is only enabled in mobile profile? I cannot
either see why this is configurable at all, seems to me that this check
should be always on... no?


>
>     Reviewers: CHAN, cedric
>
>     Reviewed By: cedric
>
>     Subscribers: subodh6129, buds, govi, CHAN, cedric, raster, id213sin
>
>     Differential Revision: https://phab.enlightenment.org/D3265
>
>     Signed-off-by: Cedric BAIL <[email protected]>
> ---
>  config/default/base.src.in  |  1 +
>  config/mobile/base.src.in   |  1 +
>  config/standard/base.src.in |  1 +
>  src/lib/elm_config.c        |  4 ++++
>  src/lib/elm_priv.h          |  1 +
>  src/lib/elm_spinner.c       | 54
> ++++++++++++++++++++++++++++++++++++++++++++-
>  6 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/config/default/base.src.in b/config/default/base.src.in
> index 6a488c4..f48f4a4 100644
> --- a/config/default/base.src.in
> +++ b/config/default/base.src.in
> @@ -98,6 +98,7 @@ group "Elm_Config" struct {
>    value "naviframe_prev_btn_auto_pushed" uchar: 1;
>    value "popup_horizontal_align" double: 0.5;
>    value "popup_vertical_align" double: 0.5;
> +  value "spinner_min_max_filter_enable" uchar: 0;
>    group "color_palette" list {
>       group "Elm_Custom_Palette" struct {
>          value "palette_name" string: "default";
> diff --git a/config/mobile/base.src.in b/config/mobile/base.src.in
> index d3ec42e..8eca4b8 100644
> --- a/config/mobile/base.src.in
> +++ b/config/mobile/base.src.in
> @@ -102,6 +102,7 @@ group "Elm_Config" struct {
>    value "naviframe_prev_btn_auto_pushed" uchar: 1;
>    value "popup_horizontal_align" double: 0.5;
>    value "popup_vertical_align" double: 0.5;
> +  value "spinner_min_max_filter_enable" uchar: 1;
>    group "color_palette" list {
>       group "Elm_Custom_Palette" struct {
>          value "palette_name" string: "default";
> diff --git a/config/standard/base.src.in b/config/standard/base.src.in
> index 6e8196c..37c2cda 100644
> --- a/config/standard/base.src.in
> +++ b/config/standard/base.src.in
> @@ -99,6 +99,7 @@ group "Elm_Config" struct {
>    value "naviframe_prev_btn_auto_pushed" uchar: 1;
>    value "popup_horizontal_align" double: 0.5;
>    value "popup_vertical_align" double: 0.5;
> +  value "spinner_min_max_filter_enable" uchar: 0;
>    group "color_palette" list {
>       group "Elm_Custom_Palette" struct {
>          value "palette_name" string: "default";
> diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
> index d28ebba..7239248 100644
> --- a/src/lib/elm_config.c
> +++ b/src/lib/elm_config.c
> @@ -496,6 +496,7 @@ _desc_init(void)
>     ELM_CONFIG_VAL(D, T, naviframe_prev_btn_auto_pushed, T_UCHAR);
>     ELM_CONFIG_VAL(D, T, popup_horizontal_align, T_DOUBLE);
>     ELM_CONFIG_VAL(D, T, popup_vertical_align, T_DOUBLE);
> +   ELM_CONFIG_VAL(D, T, spinner_min_max_filter_enable, T_UCHAR);
>  #undef T
>  #undef D
>  #undef T_INT
> @@ -1797,6 +1798,7 @@ _config_load(void)
>     _elm_config->indicator_service_270 =
> eina_stringshare_add("elm_indicator_landscape");
>     _elm_config->disable_external_menu = EINA_FALSE;
>     _elm_config->magnifier_enable = EINA_TRUE;
> +   _elm_config->spinner_min_max_filter_enable = EINA_FALSE;
>     _elm_config->magnifier_scale = 1.5;
>     _elm_config->audio_mute_effect = 0;
>     _elm_config->audio_mute_background = 0;
> @@ -2497,6 +2499,8 @@ _env_get(void)
>     if (s) _elm_config->magnifier_scale = _elm_atof(s);
>     s = getenv("ELM_ATSPI_MODE");
>     if (s) _elm_config->atspi_mode = ELM_ATSPI_MODE_ON;
> +   s = getenv("ELM_SPINNER_MIN_MAX_FILTER_ENABLE");
> +   if (s) _elm_config->spinner_min_max_filter_enable = !!atoi(s);
>
>     s = getenv("ELM_TRANSITION_DURATION_FACTOR");
>     if (s) _elm_config->transition_duration_factor = atof(s);
> diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
> index 82915a5..a1dcb50 100644
> --- a/src/lib/elm_priv.h
> +++ b/src/lib/elm_priv.h
> @@ -308,6 +308,7 @@ struct _Elm_Config
>     unsigned char win_auto_focus_animate;
>     double        transition_duration_factor;
>     unsigned char naviframe_prev_btn_auto_pushed;
> +   unsigned char spinner_min_max_filter_enable;
>     Eina_List    *bindings;
>     Eina_Bool     atspi_mode;
>     int           gl_depth;
> diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
> index 65ffee4..45674bd 100644
> --- a/src/lib/elm_spinner.c
> +++ b/src/lib/elm_spinner.c
> @@ -81,7 +81,7 @@ _is_label_format_integer(const char *fmt)
>          if ((*itr == 'd') || (*itr == 'u') || (*itr == 'i') ||
>              (*itr == 'o') || (*itr == 'x') || (*itr == 'X'))
>            return EINA_TRUE;
> -        else if ((*itr == 'f'))
> +        else if ((*itr == 'f') || (*itr == 'F'))
>            return EINA_FALSE;
>       }
>
> @@ -421,6 +421,56 @@ _entry_filter_add(Evas_Object *obj)
>     elm_entry_markup_filter_append(sd->ent, elm_entry_filter_accept_set,
> &digits_filter_data);
>  }
>
> +char *
> +_text_insert(const char *text, const char *input, int pos)
> +{
> +   char *result = NULL;
> +   int text_len, input_len;
> +
> +   text_len = evas_string_char_len_get(text);
> +   input_len = evas_string_char_len_get(input);
> +   result = (char *)calloc(text_len + input_len + 1, sizeof(char));
> +   if (!result) return NULL;
> +
> +   strncpy(result, text, pos);
> +   strcpy(result + pos, input);
> +   strcpy(result + pos + input_len, text + pos);
> +
> +   return result;
> +}
> +
> +static void
> +_min_max_validity_filter(void *data, Evas_Object *obj, char **text)
> +{
> +   const char *str, *new_str;
> +   char *insert;
> +   double val;
> +   int max_len, len;
> +
> +   EINA_SAFETY_ON_NULL_RETURN(data);
> +   EINA_SAFETY_ON_NULL_RETURN(obj);
> +   EINA_SAFETY_ON_NULL_RETURN(text);
> +
> +   ELM_SPINNER_DATA_GET(data, sd);
> +
> +   str = elm_object_text_get(obj);
> +   if (!str) return;
> +
> +   insert = *text;
> +   new_str = _text_insert(str, insert, elm_entry_cursor_pos_get(obj));
> +   if (!new_str) return;
> +
> +   max_len = log10(abs(sd->val_max)) + 1;
> +   len = evas_string_char_len_get(new_str);
> +   if (len < max_len) return;
> +
> +   val = strtod(new_str, NULL);
> +   ELM_SAFE_FREE(new_str, free);
> +
> +   if ((val < sd->val_min) || (val > sd->val_max))
> +     *insert = 0;
> +}
> +
>  static void
>  _entry_show_cb(void *data,
>                 Evas *e EINA_UNUSED,
> @@ -468,6 +518,8 @@ _toggle_entry(Evas_Object *obj)
>                 (ELM_ENTRY_EVENT_ACTIVATED, _entry_activated_cb, obj));
>               elm_layout_content_set(obj, "elm.swallow.entry", sd->ent);
>               _entry_filter_add(obj);
> +             if (_elm_config->spinner_min_max_filter_enable)
> +               elm_entry_markup_filter_append(sd->ent,
> _min_max_validity_filter, obj);
>            }
>          if (!sd->button_layout)
>            {
>
> --
>
>
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to