summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2018-11-26 10:32:31 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2018-11-26 10:47:20 +0200
commit976a33e36a6309133483d851495a5ed6d914628a (patch)
tree548e15551239768bb16f7f339f9e29a4260459c6 /src
parent5de51f84fb206a728c5df72739ec187b69e7cc57 (diff)
FlipSelector: fix items creation when range is used
In the case step is 0, the application will enter in an infinite loop where the max will never be reached. To fix this, step is set to 1 if 0 is given by the user. Moreover, step is forced to positive. According to the given min and max values, the step will be negative or positive. In this way, we are sure to be inside the correct range.
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/elm_flipselector.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_flipselector.c b/src/lib/elementary/elm_flipselector.c
index 54b6957e9c..4aeaf9b125 100644
--- a/src/lib/elementary/elm_flipselector.c
+++ b/src/lib/elementary/elm_flipselector.c
@@ -456,14 +456,18 @@ static void
456_items_add(Evas_Object *obj) 456_items_add(Evas_Object *obj)
457{ 457{
458 double d; 458 double d;
459 Eina_Bool reverse;
459 char buf[16]; 460 char buf[16];
460 461
461 ELM_FLIPSELECTOR_DATA_GET(obj, sd); 462 ELM_FLIPSELECTOR_DATA_GET(obj, sd);
463 reverse = (sd->val_min > sd->val_max);
462 _clear_items(obj); 464 _clear_items(obj);
463 for (d = sd->val_min; d < sd->val_max; d = d + sd->step) 465 for (d = sd->val_min; d < sd->val_max;)
464 { 466 {
465 snprintf(buf, sizeof(buf), "%.2f", d); 467 snprintf(buf, sizeof(buf), "%.2f", d);
466 elm_flipselector_item_append(obj, buf, NULL, NULL); 468 elm_flipselector_item_append(obj, buf, NULL, NULL);
469 if (reverse) d = d - sd->step;
470 else d = d + sd->step;
467 } 471 }
468 snprintf(buf, sizeof(buf), "%.2f", sd->val_max); 472 snprintf(buf, sizeof(buf), "%.2f", sd->val_max);
469 elm_flipselector_item_append(obj, buf, NULL, NULL); 473 elm_flipselector_item_append(obj, buf, NULL, NULL);
@@ -472,7 +476,6 @@ _items_add(Evas_Object *obj)
472EOLIAN static void 476EOLIAN static void
473_elm_flipselector_efl_ui_range_range_min_max_set(Eo *obj, Elm_Flipselector_Data *sd, double min, double max) 477_elm_flipselector_efl_ui_range_range_min_max_set(Eo *obj, Elm_Flipselector_Data *sd, double min, double max)
474{ 478{
475 if (min > max) return;
476 if ((sd->val_min == min) && (sd->val_max == max)) return; 479 if ((sd->val_min == min) && (sd->val_max == max)) return;
477 480
478 sd->val_min = min; 481 sd->val_min = min;
@@ -493,6 +496,9 @@ _elm_flipselector_efl_ui_range_range_step_set(Eo *obj EINA_UNUSED, Elm_Flipselec
493{ 496{
494 if (sd->step == step) return; 497 if (sd->step == step) return;
495 498
499 if (step == 0.0) step = 1.0;
500 else if (step < 0.0) step *= -1;
501
496 sd->step = step; 502 sd->step = step;
497 _items_add(obj); 503 _items_add(obj);
498} 504}