summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2018-02-06 22:33:58 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2018-02-06 22:35:33 +0900
commit0aca43be2377c55260ef3224dc825bc41cddb1eb (patch)
treee6fa344d9666069157ba3d445ddc8a826940ee51
parent27c0d53f9b969bc641b3b321ce55b77230d62817 (diff)
efl.ui.progressbar: add checks for min & max value
this improves the validity check for min & max values provided from user side.
-rw-r--r--src/lib/elementary/efl_ui_progressbar.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/elementary/efl_ui_progressbar.c b/src/lib/elementary/efl_ui_progressbar.c
index 2177cd28f6..2654b1a850 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -130,16 +130,21 @@ _val_set(Evas_Object *obj)
130{ 130{
131 Eina_Bool rtl; 131 Eina_Bool rtl;
132 double pos; 132 double pos;
133 Efl_Ui_Progress_Status *ps;
134 Eina_List *l;
133 135
134 EFL_UI_PROGRESSBAR_DATA_GET(obj, sd); 136 EFL_UI_PROGRESSBAR_DATA_GET(obj, sd);
135 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 137 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
136 138
137 rtl = efl_ui_mirrored_get(obj); 139 rtl = efl_ui_mirrored_get(obj);
138 Efl_Ui_Progress_Status *ps;
139 Eina_List *l;
140 140
141 EINA_LIST_FOREACH(sd->progress_status, l, ps) 141 EINA_LIST_FOREACH(sd->progress_status, l, ps)
142 { 142 {
143 if (EINA_DBL_EQ(ps->val_max, ps->val_min))
144 {
145 WRN("progressbar min and max are equal.");
146 continue;
147 }
143 pos = (ps->val - ps->val_min)/(ps->val_max - ps->val_min); 148 pos = (ps->val - ps->val_min)/(ps->val_max - ps->val_min);
144 149
145 if ((!rtl && _is_inverted(sd->dir)) || 150 if ((!rtl && _is_inverted(sd->dir)) ||
@@ -478,12 +483,23 @@ _progressbar_span_size_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Evas_Coord size
478} 483}
479 484
480static void 485static void
481_progress_part_min_max_set(Efl_Ui_Progressbar_Data *sd, const char *part_name, double min, double max) 486_progress_part_min_max_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double min, double max)
482{ 487{
483 Efl_Ui_Progress_Status *ps; 488 Efl_Ui_Progress_Status *ps;
484 Eina_Bool existing_ps = EINA_FALSE; 489 Eina_Bool existing_ps = EINA_FALSE;
485 Eina_List *l; 490 Eina_List *l;
486 491
492 if (EINA_DBL_EQ(min, max))
493 {
494 ERR("min & max provided are equal.");
495 return;
496 }
497
498 if (min > max)
499 {
500 WRN("min is greater than max.");
501 }
502
487 if (!strcmp(part_name, "elm.cur.progressbar")) 503 if (!strcmp(part_name, "elm.cur.progressbar"))
488 { 504 {
489 sd->val_min = min; 505 sd->val_min = min;
@@ -507,6 +523,7 @@ _progress_part_min_max_set(Efl_Ui_Progressbar_Data *sd, const char *part_name, d
507 ps->val_max = max; 523 ps->val_max = max;
508 sd->progress_status = eina_list_append(sd->progress_status, ps); 524 sd->progress_status = eina_list_append(sd->progress_status, ps);
509 } 525 }
526 _val_set(obj);
510} 527}
511 528
512static void 529static void
@@ -622,9 +639,9 @@ _efl_ui_progressbar_pulse_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
622} 639}
623 640
624EOLIAN static void 641EOLIAN static void
625_efl_ui_progressbar_efl_ui_range_range_min_max_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double min, double max) 642_efl_ui_progressbar_efl_ui_range_range_min_max_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double min, double max)
626{ 643{
627 _progress_part_min_max_set(sd, "elm.cur.progressbar", min, max); 644 _progress_part_min_max_set(obj, sd, "elm.cur.progressbar", min, max);
628} 645}
629 646
630EOLIAN static void 647EOLIAN static void
@@ -679,7 +696,7 @@ _efl_ui_progressbar_part_efl_ui_range_range_min_max_set(Eo *obj, void *_pd EINA_
679 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); 696 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
680 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS); 697 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
681 698
682 _progress_part_min_max_set(sd, pd->part, min, max); 699 _progress_part_min_max_set(pd->obj, sd, pd->part, min, max);
683} 700}
684 701
685EOLIAN static void 702EOLIAN static void