summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_spin_button.c
diff options
context:
space:
mode:
authorWoochan Lee <wc0917.lee@samsung.com>2018-05-20 03:01:44 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2018-05-20 03:11:55 +0900
commit976b9d877e762aee6e0fbd1b37766591644a2f2f (patch)
tree28e2a01c325c9791be6f7ad8e2028070af8cc884 /src/lib/elementary/efl_ui_spin_button.c
parent175b25ab2e77fa0d4e4646d470e5e0263ca22b93 (diff)
efl_ui_spin: Added special value feature.
Summary: User may want to set as meanignful words for the value instead of numberic value. @feature Test Plan: elementary_test->test_ui_spin_button. Reviewers: cedric, woohyun, Jaehyun_Cho, herb Reviewed By: Jaehyun_Cho Subscribers: zmike, felipealmeida, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D5969
Diffstat (limited to 'src/lib/elementary/efl_ui_spin_button.c')
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index 37ef72f..6b2bfbe 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -50,9 +50,22 @@ EFL_CALLBACKS_ARRAY_DEFINE(_inc_dec_button_cb,
50static void 50static void
51_entry_show(Evas_Object *obj) 51_entry_show(Evas_Object *obj)
52{ 52{
53 Efl_Ui_Spin_Special_Value *sv;
54 Eina_Array_Iterator iterator;
55 unsigned int i;
56 char buf[32], fmt[32] = "%0.f";
57
53 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS); 58 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS);
54 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS); 59 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS);
55 char buf[32], fmt[32] = "%0.f"; 60
61 EINA_ARRAY_ITER_NEXT(pd->special_values, i, sv, iterator)
62 {
63 if (sv->value == pd->val)
64 {
65 snprintf(buf, sizeof(buf), "%s", sv->label);
66 elm_object_text_set(sd->ent, buf);
67 }
68 }
56 69
57 /* try to construct just the format from given label 70 /* try to construct just the format from given label
58 * completely ignoring pre/post words 71 * completely ignoring pre/post words
@@ -169,6 +182,9 @@ _entry_hide(Evas_Object *obj)
169static void 182static void
170_entry_value_apply(Evas_Object *obj) 183_entry_value_apply(Evas_Object *obj)
171{ 184{
185 Efl_Ui_Spin_Special_Value *sv;
186 Eina_Array_Iterator iterator;
187 unsigned int i;
172 const char *str; 188 const char *str;
173 double val; 189 double val;
174 char *end; 190 char *end;
@@ -184,6 +200,10 @@ _entry_value_apply(Evas_Object *obj)
184 str = elm_object_text_get(sd->ent); 200 str = elm_object_text_get(sd->ent);
185 if (!str) return; 201 if (!str) return;
186 202
203 EINA_ARRAY_ITER_NEXT(pd->special_values, i, sv, iterator)
204 if (sv->value == pd->val)
205 if (!strcmp(sv->label, str)) return;
206
187 val = strtod(str, &end); 207 val = strtod(str, &end);
188 if (((*end != '\0') && (!isspace(*end))) || (fabs(val - pd->val) < DBL_EPSILON)) return; 208 if (((*end != '\0') && (!isspace(*end))) || (fabs(val - pd->val) < DBL_EPSILON)) return;
189 efl_ui_range_value_set(obj, val); 209 efl_ui_range_value_set(obj, val);