summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 16:17:38 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 19:56:33 +0200
commit5efb4b374e6052fc401b109d6a98db7fe2ef3222 (patch)
tree180f10703a92e60c08c7963f761669ec762e5996
parent1e73201169473a92c26c233377b9e5747b3e0776 (diff)
efl_ui_*: get range users onto the same semantics
this commits introduces unified behaviour for the users of the range interfaces. This includes: - The same errors for limit_set errors - The same errors for value setting outside the range Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9241
-rw-r--r--src/lib/elementary/efl_ui_progressbar.c21
-rw-r--r--src/lib/elementary/efl_ui_slider.c35
-rw-r--r--src/lib/elementary/efl_ui_spin.c24
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c8
4 files changed, 74 insertions, 14 deletions
diff --git a/src/lib/elementary/efl_ui_progressbar.c b/src/lib/elementary/efl_ui_progressbar.c
index 637c54f8d6..f085924893 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -593,6 +593,17 @@ _progressbar_part_value_get(Efl_Ui_Progressbar_Data *sd, const char* part)
593EOLIAN static void 593EOLIAN static void
594_efl_ui_progressbar_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double val) 594_efl_ui_progressbar_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double val)
595{ 595{
596 if (val < sd->val_min)
597 {
598 ERR("Error, value is less than minimum");
599 return;
600 }
601
602 if (val > sd->val_max)
603 {
604 ERR("Error, value is greater than maximum");
605 return;
606 }
596 if (EINA_DBL_EQ(sd->val, val)) return; 607 if (EINA_DBL_EQ(sd->val, val)) return;
597 608
598 if (elm_widget_is_legacy(obj)) 609 if (elm_widget_is_legacy(obj))
@@ -644,6 +655,16 @@ _efl_ui_progressbar_pulse_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data
644EOLIAN static void 655EOLIAN static void
645_efl_ui_progressbar_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double min, double max) 656_efl_ui_progressbar_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double min, double max)
646{ 657{
658 if (max < min)
659 {
660 ERR("Wrong params. min(%lf) is greater than max(%lf).", min, max);
661 return;
662 }
663 if (EINA_DBL_EQ(max, min))
664 {
665 ERR("min and max must have a different value");
666 return;
667 }
647 if (elm_widget_is_legacy(obj)) 668 if (elm_widget_is_legacy(obj))
648 _progress_part_min_max_set(obj, sd, "elm.cur.progressbar", min, max); 669 _progress_part_min_max_set(obj, sd, "elm.cur.progressbar", min, max);
649 else 670 else
diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c
index 188d631ad2..3a6de63a26 100644
--- a/src/lib/elementary/efl_ui_slider.c
+++ b/src/lib/elementary/efl_ui_slider.c
@@ -719,7 +719,17 @@ _efl_ui_slider_efl_ui_layout_orientable_orientation_get(const Eo *obj EINA_UNUSE
719EOLIAN static void 719EOLIAN static void
720_efl_ui_slider_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Slider_Data *sd, double min, double max) 720_efl_ui_slider_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Slider_Data *sd, double min, double max)
721{ 721{
722 if ((sd->val_min == min) && (sd->val_max == max)) return; 722 if (max < min)
723 {
724 ERR("Wrong params. min(%lf) is greater than max(%lf).", min, max);
725 return;
726 }
727 if (EINA_DBL_EQ(max, min))
728 {
729 ERR("min and max must have a different value");
730 return;
731 }
732 if ((EINA_DBL_EQ(sd->val_min, min)) && (EINA_DBL_EQ(sd->val_max, max))) return;
723 sd->val_min = min; 733 sd->val_min = min;
724 sd->val_max = max; 734 sd->val_max = max;
725 if (sd->val < sd->val_min) sd->val = sd->val_min; 735 if (sd->val < sd->val_min) sd->val = sd->val_min;
@@ -738,7 +748,19 @@ _efl_ui_slider_efl_ui_range_display_range_limits_get(const Eo *obj EINA_UNUSED,
738EOLIAN static void 748EOLIAN static void
739_efl_ui_slider_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Slider_Data *sd, double val) 749_efl_ui_slider_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Slider_Data *sd, double val)
740{ 750{
741 if (sd->val == val) return; 751 if (val < sd->val_min)
752 {
753 ERR("Error, value is less than minimum");
754 return;
755 }
756
757 if (val > sd->val_max)
758 {
759 ERR("Error, value is greater than maximum");
760 return;
761 }
762
763 if (EINA_DBL_EQ(val, sd->val)) return;
742 sd->val = val; 764 sd->val = val;
743 765
744 if (sd->val < sd->val_min) sd->val = sd->val_min; 766 if (sd->val < sd->val_min) sd->val = sd->val_min;
@@ -762,10 +784,13 @@ _efl_ui_slider_efl_ui_range_interactive_range_step_get(const Eo *obj EINA_UNUSED
762EOLIAN static void 784EOLIAN static void
763_efl_ui_slider_efl_ui_range_interactive_range_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double step) 785_efl_ui_slider_efl_ui_range_interactive_range_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Slider_Data *sd, double step)
764{ 786{
765 if (sd->step == step) return; 787 if (step <= 0)
788 {
789 ERR("Wrong param. The step(%lf) should be greater than 0.0", step);
790 return;
791 }
766 792
767 if (step < 0.0) step = 0.0; 793 if (sd->step == step) return;
768 else if (step > 1.0) step = 1.0;
769 794
770 sd->step = step; 795 sd->step = step;
771} 796}
diff --git a/src/lib/elementary/efl_ui_spin.c b/src/lib/elementary/efl_ui_spin.c
index dddc869152..d6c717cb72 100644
--- a/src/lib/elementary/efl_ui_spin.c
+++ b/src/lib/elementary/efl_ui_spin.c
@@ -108,10 +108,13 @@ _efl_ui_spin_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Spin_Data *sd
108{ 108{
109 if (max < min) 109 if (max < min)
110 { 110 {
111 ERR("Wrong params. min(%lf) is bigger than max(%lf). It will swaped.", min, max); 111 ERR("Wrong params. min(%lf) is greater than max(%lf).", min, max);
112 double t = min; 112 return;
113 min = max; 113 }
114 max = t; 114 if (EINA_DBL_EQ(max, min))
115 {
116 ERR("min and max must have a different value");
117 return;
115 } 118 }
116 if ((EINA_DBL_EQ(sd->val_min, min)) && (EINA_DBL_EQ(sd->val_max, max))) return; 119 if ((EINA_DBL_EQ(sd->val_min, min)) && (EINA_DBL_EQ(sd->val_max, max))) return;
117 120
@@ -153,9 +156,16 @@ EOLIAN static void
153_efl_ui_spin_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Spin_Data *sd, double val) 156_efl_ui_spin_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Spin_Data *sd, double val)
154{ 157{
155 if (val < sd->val_min) 158 if (val < sd->val_min)
156 val = sd->val_min; 159 {
157 else if (val > sd->val_max) 160 ERR("Error, value is less than minimum");
158 val = sd->val_max; 161 return;
162 }
163
164 if (val > sd->val_max)
165 {
166 ERR("Error, value is greater than maximum");
167 return;
168 }
159 169
160 if (EINA_DBL_EQ(val, sd->val)) return; 170 if (EINA_DBL_EQ(val, sd->val)) return;
161 171
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index c356686aea..a975df1327 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -168,7 +168,7 @@ static void
168_entry_value_apply(Evas_Object *obj) 168_entry_value_apply(Evas_Object *obj)
169{ 169{
170 const char *str; 170 const char *str;
171 double val; 171 double val, val_min, val_max;
172 char *end; 172 char *end;
173 173
174 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS); 174 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS);
@@ -184,6 +184,8 @@ _entry_value_apply(Evas_Object *obj)
184 184
185 val = strtod(str, &end); 185 val = strtod(str, &end);
186 if (((*end != '\0') && (!isspace(*end))) || (fabs(val - pd->val) < DBL_EPSILON)) return; 186 if (((*end != '\0') && (!isspace(*end))) || (fabs(val - pd->val) < DBL_EPSILON)) return;
187 efl_ui_range_limits_get(obj, &val_min, &val_max);
188 val = MIN(val_max, MAX(val_min, val));
187 efl_ui_range_value_set(obj, val); 189 efl_ui_range_value_set(obj, val);
188 190
189 efl_event_callback_call(obj, EFL_UI_SPIN_EVENT_CHANGED, NULL); 191 efl_event_callback_call(obj, EFL_UI_SPIN_EVENT_CHANGED, NULL);
@@ -406,7 +408,9 @@ _spin_value(void *data)
406 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(data, MY_CLASS); 408 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(data, MY_CLASS);
407 Efl_Ui_Spin_Data *pd = efl_data_scope_get(data, EFL_UI_SPIN_CLASS); 409 Efl_Ui_Spin_Data *pd = efl_data_scope_get(data, EFL_UI_SPIN_CLASS);
408 410
409 if (_value_set(data, pd->val + (sd->inc_val ? pd->step : -pd->step))) 411 int absolut_value = pd->val + (sd->inc_val ? pd->step : -pd->step);
412
413 if (_value_set(data, MIN(MAX(absolut_value, pd->val_min), pd->val_max)))
410 _label_write(data); 414 _label_write(data);
411 415
412 return ECORE_CALLBACK_RENEW; 416 return ECORE_CALLBACK_RENEW;