forked from enlightenment/efl
spinner: add min, max filter
Summary: In spinner's entry allow numbers only with in min/max range Signed-off-by: Shilpa Singh <shilpa.singh@samsung.com> @feature Test Plan: 1. Set min/max value to spinner 2. Enter numbers beyond min/max value 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 <cedric@osg.samsung.com>
This commit is contained in:
parent
4607109531
commit
dd9ff4aa96
|
@ -98,6 +98,7 @@ group "Elm_Config" struct {
|
||||||
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
||||||
value "popup_horizontal_align" double: 0.5;
|
value "popup_horizontal_align" double: 0.5;
|
||||||
value "popup_vertical_align" double: 0.5;
|
value "popup_vertical_align" double: 0.5;
|
||||||
|
value "spinner_min_max_filter_enable" uchar: 0;
|
||||||
group "color_palette" list {
|
group "color_palette" list {
|
||||||
group "Elm_Custom_Palette" struct {
|
group "Elm_Custom_Palette" struct {
|
||||||
value "palette_name" string: "default";
|
value "palette_name" string: "default";
|
||||||
|
|
|
@ -102,6 +102,7 @@ group "Elm_Config" struct {
|
||||||
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
||||||
value "popup_horizontal_align" double: 0.5;
|
value "popup_horizontal_align" double: 0.5;
|
||||||
value "popup_vertical_align" double: 0.5;
|
value "popup_vertical_align" double: 0.5;
|
||||||
|
value "spinner_min_max_filter_enable" uchar: 1;
|
||||||
group "color_palette" list {
|
group "color_palette" list {
|
||||||
group "Elm_Custom_Palette" struct {
|
group "Elm_Custom_Palette" struct {
|
||||||
value "palette_name" string: "default";
|
value "palette_name" string: "default";
|
||||||
|
|
|
@ -99,6 +99,7 @@ group "Elm_Config" struct {
|
||||||
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
value "naviframe_prev_btn_auto_pushed" uchar: 1;
|
||||||
value "popup_horizontal_align" double: 0.5;
|
value "popup_horizontal_align" double: 0.5;
|
||||||
value "popup_vertical_align" double: 0.5;
|
value "popup_vertical_align" double: 0.5;
|
||||||
|
value "spinner_min_max_filter_enable" uchar: 0;
|
||||||
group "color_palette" list {
|
group "color_palette" list {
|
||||||
group "Elm_Custom_Palette" struct {
|
group "Elm_Custom_Palette" struct {
|
||||||
value "palette_name" string: "default";
|
value "palette_name" string: "default";
|
||||||
|
|
|
@ -496,6 +496,7 @@ _desc_init(void)
|
||||||
ELM_CONFIG_VAL(D, T, naviframe_prev_btn_auto_pushed, T_UCHAR);
|
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_horizontal_align, T_DOUBLE);
|
||||||
ELM_CONFIG_VAL(D, T, popup_vertical_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 T
|
||||||
#undef D
|
#undef D
|
||||||
#undef T_INT
|
#undef T_INT
|
||||||
|
@ -1797,6 +1798,7 @@ _config_load(void)
|
||||||
_elm_config->indicator_service_270 = eina_stringshare_add("elm_indicator_landscape");
|
_elm_config->indicator_service_270 = eina_stringshare_add("elm_indicator_landscape");
|
||||||
_elm_config->disable_external_menu = EINA_FALSE;
|
_elm_config->disable_external_menu = EINA_FALSE;
|
||||||
_elm_config->magnifier_enable = EINA_TRUE;
|
_elm_config->magnifier_enable = EINA_TRUE;
|
||||||
|
_elm_config->spinner_min_max_filter_enable = EINA_FALSE;
|
||||||
_elm_config->magnifier_scale = 1.5;
|
_elm_config->magnifier_scale = 1.5;
|
||||||
_elm_config->audio_mute_effect = 0;
|
_elm_config->audio_mute_effect = 0;
|
||||||
_elm_config->audio_mute_background = 0;
|
_elm_config->audio_mute_background = 0;
|
||||||
|
@ -2497,6 +2499,8 @@ _env_get(void)
|
||||||
if (s) _elm_config->magnifier_scale = _elm_atof(s);
|
if (s) _elm_config->magnifier_scale = _elm_atof(s);
|
||||||
s = getenv("ELM_ATSPI_MODE");
|
s = getenv("ELM_ATSPI_MODE");
|
||||||
if (s) _elm_config->atspi_mode = ELM_ATSPI_MODE_ON;
|
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");
|
s = getenv("ELM_TRANSITION_DURATION_FACTOR");
|
||||||
if (s) _elm_config->transition_duration_factor = atof(s);
|
if (s) _elm_config->transition_duration_factor = atof(s);
|
||||||
|
|
|
@ -308,6 +308,7 @@ struct _Elm_Config
|
||||||
unsigned char win_auto_focus_animate;
|
unsigned char win_auto_focus_animate;
|
||||||
double transition_duration_factor;
|
double transition_duration_factor;
|
||||||
unsigned char naviframe_prev_btn_auto_pushed;
|
unsigned char naviframe_prev_btn_auto_pushed;
|
||||||
|
unsigned char spinner_min_max_filter_enable;
|
||||||
Eina_List *bindings;
|
Eina_List *bindings;
|
||||||
Eina_Bool atspi_mode;
|
Eina_Bool atspi_mode;
|
||||||
int gl_depth;
|
int gl_depth;
|
||||||
|
|
|
@ -81,7 +81,7 @@ _is_label_format_integer(const char *fmt)
|
||||||
if ((*itr == 'd') || (*itr == 'u') || (*itr == 'i') ||
|
if ((*itr == 'd') || (*itr == 'u') || (*itr == 'i') ||
|
||||||
(*itr == 'o') || (*itr == 'x') || (*itr == 'X'))
|
(*itr == 'o') || (*itr == 'x') || (*itr == 'X'))
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
else if ((*itr == 'f'))
|
else if ((*itr == 'f') || (*itr == 'F'))
|
||||||
return EINA_FALSE;
|
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);
|
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
|
static void
|
||||||
_entry_show_cb(void *data,
|
_entry_show_cb(void *data,
|
||||||
Evas *e EINA_UNUSED,
|
Evas *e EINA_UNUSED,
|
||||||
|
@ -468,6 +518,8 @@ _toggle_entry(Evas_Object *obj)
|
||||||
(ELM_ENTRY_EVENT_ACTIVATED, _entry_activated_cb, obj));
|
(ELM_ENTRY_EVENT_ACTIVATED, _entry_activated_cb, obj));
|
||||||
elm_layout_content_set(obj, "elm.swallow.entry", sd->ent);
|
elm_layout_content_set(obj, "elm.swallow.entry", sd->ent);
|
||||||
_entry_filter_add(obj);
|
_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)
|
if (!sd->button_layout)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue