summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2018-01-17 15:52:58 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2018-01-31 17:44:20 +0900
commitc99b37ad47f022cfbaca5fde230572df2136e104 (patch)
tree7abf5fdd0be8919a19019c28970b4117fddb444e
parent90fecc7485b2cb8c4ac2d0a4a79f9dc761c51067 (diff)
Efl.Ui.Progressbar: implement range min max
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_ui_progressbar.c171
-rw-r--r--src/lib/elementary/efl_ui_progressbar.c94
-rw-r--r--src/lib/elementary/efl_ui_progressbar.eo1
-rw-r--r--src/lib/elementary/efl_ui_progressbar_part.eo1
-rw-r--r--src/lib/elementary/efl_ui_progressbar_private.h4
8 files changed, 269 insertions, 6 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 925b2952cf..425f35c5ad 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -49,6 +49,7 @@ src/bin/elementary/test_panes.c
49src/bin/elementary/test_photo.c 49src/bin/elementary/test_photo.c
50src/bin/elementary/test_photocam.c 50src/bin/elementary/test_photocam.c
51src/bin/elementary/test_progressbar.c 51src/bin/elementary/test_progressbar.c
52src/bin/elementary/test_ui_progressbar.c
52src/bin/elementary/test_radio.c 53src/bin/elementary/test_radio.c
53src/bin/elementary/test_scaling.c 54src/bin/elementary/test_scaling.c
54src/bin/elementary/test_scroller.c 55src/bin/elementary/test_scroller.c
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index db53d2aba7..eee0170d3d 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -955,6 +955,7 @@ bin/elementary/test_photocam.c \
955bin/elementary/test_popup.c \ 955bin/elementary/test_popup.c \
956bin/elementary/test_prefs.c \ 956bin/elementary/test_prefs.c \
957bin/elementary/test_progressbar.c \ 957bin/elementary/test_progressbar.c \
958bin/elementary/test_ui_progressbar.c \
958bin/elementary/test_radio.c \ 959bin/elementary/test_radio.c \
959bin/elementary/test_scaling.c \ 960bin/elementary/test_scaling.c \
960bin/elementary/test_scroller.c \ 961bin/elementary/test_scroller.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 6c0d4ee1e0..8685e1bce5 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -170,6 +170,7 @@ void test_win_state2(void *data, Evas_Object *obj, void *event_info);
170void test_win_stack(void *data, Evas_Object *obj, void *event_info); 170void test_win_stack(void *data, Evas_Object *obj, void *event_info);
171void test_progressbar(void *data, Evas_Object *obj, void *event_info); 171void test_progressbar(void *data, Evas_Object *obj, void *event_info);
172void test_progressbar2(void *data, Evas_Object *obj, void *event_info); 172void test_progressbar2(void *data, Evas_Object *obj, void *event_info);
173void test_ui_progressbar(void *data, Evas_Object *obj, void *event_info);
173void test_fileselector(void *data, Evas_Object *obj, void *event_info); 174void test_fileselector(void *data, Evas_Object *obj, void *event_info);
174void test_separator(void *data, Evas_Object *obj, void *event_info); 175void test_separator(void *data, Evas_Object *obj, void *event_info);
175void test_scroller(void *data, Evas_Object *obj, void *event_info); 176void test_scroller(void *data, Evas_Object *obj, void *event_info);
@@ -1045,6 +1046,7 @@ add_tests:
1045 ADD_TEST(NULL, "Range Values", "Slider", test_slider); 1046 ADD_TEST(NULL, "Range Values", "Slider", test_slider);
1046 ADD_TEST(NULL, "Range Values", "Progressbar", test_progressbar); 1047 ADD_TEST(NULL, "Range Values", "Progressbar", test_progressbar);
1047 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2); 1048 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2);
1049 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Progressbar", test_ui_progressbar);
1048 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate); 1050 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate);
1049 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval); 1051 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval);
1050 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider", test_ui_slider); 1052 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider", test_ui_slider);
diff --git a/src/bin/elementary/test_ui_progressbar.c b/src/bin/elementary/test_ui_progressbar.c
new file mode 100644
index 0000000000..e1391421b1
--- /dev/null
+++ b/src/bin/elementary/test_ui_progressbar.c
@@ -0,0 +1,171 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6typedef struct _pbdata
7{
8 Eo *win;
9 Eo *pb1;
10 Eo *pb2;
11 Eo *btn_start;
12 Eo *btn_stop;
13 Eo *btn_reset;
14 Ecore_Timer *timer;
15} pbdata;
16
17static Eina_Bool
18_set_progress_val(Eo *pb, double inc_value)
19{
20 double progress;
21
22 progress = efl_ui_range_value_get(pb);
23
24 if (progress < 100.0)
25 progress += inc_value;
26 else
27 return EINA_TRUE;
28
29 efl_ui_range_value_set(pb, progress);
30
31 return EINA_FALSE;
32}
33
34static Eina_Bool
35_pb_timer_cb(void *d)
36{
37 pbdata *pd = d;
38 double progress_val;
39
40 if (!pd) return ECORE_CALLBACK_CANCEL;
41
42 progress_val = efl_ui_range_value_get(pd->pb1);
43 if (progress_val < 100.0)
44 {
45 progress_val += 1;
46 efl_ui_range_value_set(pd->pb2, progress_val);
47 }
48
49 if (!_set_progress_val(pd->pb1, 0.5))
50 return ECORE_CALLBACK_RENEW;
51
52 pd->timer = NULL;
53 return ECORE_CALLBACK_CANCEL;
54}
55
56static void
57_start_btn_clicked_cb(void *d, const Efl_Event *ev EINA_UNUSED)
58{
59 pbdata *pd = d;
60
61 if (!pd) return;
62
63 printf("start button is clicked\n");
64
65 efl_ui_widget_disabled_set(pd->btn_start, EINA_TRUE);
66 efl_ui_widget_disabled_set(pd->btn_stop, EINA_FALSE);
67
68 if (!pd->timer) pd->timer = ecore_timer_add(0.1, _pb_timer_cb, pd);
69}
70
71static void
72_stop_btn_clicked_cb(void *d, const Efl_Event *ev EINA_UNUSED)
73{
74 pbdata *pd = d;
75
76 if (!pd) return;
77 printf("stop button is clicked\n");
78
79 efl_ui_widget_disabled_set(pd->btn_start, EINA_FALSE);
80 efl_ui_widget_disabled_set(pd->btn_stop, EINA_TRUE);
81
82 if (pd->timer)
83 {
84 ecore_timer_del(pd->timer);
85 pd->timer = NULL;
86 }
87}
88
89static void
90_reset_btn_clicked_cb(void *d, const Efl_Event *ev EINA_UNUSED)
91{
92 pbdata *pd = d;
93
94 if (!pd) return;
95 printf("reset button is clicked\n");
96
97 efl_ui_range_value_set(pd->pb1, 0.0);
98 efl_ui_range_value_set(pd->pb2, 0.0);
99}
100
101static void
102_win_delete_req_cb(void *d, const Efl_Event *ev EINA_UNUSED)
103{
104 pbdata *pd = d;
105
106 if (pd->timer) ecore_timer_del(pd->timer);
107 efl_del(pd->win);
108 free(pd);
109}
110
111void
112test_ui_progressbar(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
113{
114 Eo *win, *bx, *btbx;
115 pbdata *pd;
116
117 pd = (pbdata *)calloc(1, sizeof(pbdata));
118
119 pd->win = win = efl_add(EFL_UI_WIN_CLASS, NULL,
120 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
121 efl_text_set(efl_added, "Efl.Ui.Progressbar"),
122 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
123 efl_event_callback_add(efl_added, EFL_UI_WIN_EVENT_DELETE_REQUEST,
124 _win_delete_req_cb, pd)
125 );
126
127 bx = efl_add(EFL_UI_BOX_CLASS, win,
128 efl_content_set(win, efl_added)
129 );
130
131 pd->pb1 = efl_add(EFL_UI_PROGRESSBAR_CLASS, bx,
132 efl_pack(bx, efl_added),
133 efl_text_set(efl_added, "percent"),
134 efl_ui_range_min_max_set(efl_added, 0, 100),
135 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(250, 20))
136 );
137
138 pd->pb2 = efl_add(EFL_UI_PROGRESSBAR_CLASS, bx,
139 efl_pack(bx, efl_added),
140 efl_text_set(efl_added, "10-100"),
141 efl_ui_progressbar_pulse_set(efl_added, EINA_TRUE),
142 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(250, 20)),
143 efl_ui_range_min_max_set(efl_added, 10, 100),
144 efl_ui_range_value_set(efl_added, 10)
145 );
146
147 btbx = efl_add(EFL_UI_BOX_CLASS, bx,
148 efl_pack(bx, efl_added),
149 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL)
150 );
151
152 pd->btn_start = efl_add(EFL_UI_BUTTON_CLASS, btbx,
153 efl_text_set(efl_added, "start"),
154 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
155 _start_btn_clicked_cb, pd),
156 efl_pack(btbx, efl_added)
157 );
158
159 pd->btn_stop = efl_add(EFL_UI_BUTTON_CLASS, btbx,
160 efl_text_set(efl_added, "stop"),
161 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
162 _stop_btn_clicked_cb, pd),
163 efl_pack(btbx, efl_added)
164 );
165 pd->btn_reset = efl_add(EFL_UI_BUTTON_CLASS, btbx,
166 efl_text_set(efl_added, "reset"),
167 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
168 _reset_btn_clicked_cb, pd),
169 efl_pack(btbx, efl_added)
170 );
171}
diff --git a/src/lib/elementary/efl_ui_progressbar.c b/src/lib/elementary/efl_ui_progressbar.c
index dc03e3dcf7..b8129fec4f 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -114,6 +114,8 @@ _units_set(Evas_Object *obj)
114 // Keeping this bug since the legacy code was like that. 114 // Keeping this bug since the legacy code was like that.
115 if (sd->is_legacy_format_string && !sd->is_legacy_format_cb) 115 if (sd->is_legacy_format_string && !sd->is_legacy_format_cb)
116 eina_value_set(&val, 100 * sd->val); 116 eina_value_set(&val, 100 * sd->val);
117 else
118 eina_value_set(&val, sd->val);
117 119
118 eina_strbuf_reset(sd->format_strbuf); 120 eina_strbuf_reset(sd->format_strbuf);
119 sd->format_cb(sd->format_cb_data, sd->format_strbuf, val); 121 sd->format_cb(sd->format_cb_data, sd->format_strbuf, val);
@@ -140,7 +142,8 @@ _val_set(Evas_Object *obj)
140 142
141 EINA_LIST_FOREACH(sd->progress_status, l, ps) 143 EINA_LIST_FOREACH(sd->progress_status, l, ps)
142 { 144 {
143 pos = ps->val; 145 pos = (ps->val - ps->val_min)/(ps->val_max - ps->val_min);
146
144 if ((!rtl && _is_inverted(sd->dir)) || 147 if ((!rtl && _is_inverted(sd->dir)) ||
145 (rtl && ((sd->dir == EFL_UI_DIR_UP) || 148 (rtl && ((sd->dir == EFL_UI_DIR_UP) ||
146 (sd->dir == EFL_UI_DIR_RIGHT)))) 149 (sd->dir == EFL_UI_DIR_RIGHT))))
@@ -361,7 +364,7 @@ _efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data
361 364
362 priv->dir = EFL_UI_DIR_RIGHT; 365 priv->dir = EFL_UI_DIR_RIGHT;
363 priv->val = MIN_RATIO_LVL; 366 priv->val = MIN_RATIO_LVL;
364 367 priv->val_max = 1.0;
365 group = _efl_ui_progressbar_theme_group_get(obj, priv); 368 group = _efl_ui_progressbar_theme_group_get(obj, priv);
366 369
367 if (!elm_widget_theme_object_set(obj, wd->resize_obj, 370 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
@@ -477,14 +480,49 @@ _progressbar_span_size_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Evas_Coord size
477} 480}
478 481
479static void 482static void
483_progress_part_min_max_set(Efl_Ui_Progressbar_Data *sd, const char *part_name, double min, double max)
484{
485 Efl_Ui_Progress_Status *ps;
486 Eina_Bool existing_ps = EINA_FALSE;
487 Eina_List *l;
488
489 if (!strcmp(part_name, "elm.cur.progressbar"))
490 {
491 sd->val_min = min;
492 sd->val_max = max;
493 }
494
495 EINA_LIST_FOREACH(sd->progress_status, l, ps)
496 {
497 if (!strcmp(ps->part_name, part_name))
498 {
499 existing_ps = EINA_TRUE;
500 ps->val_min = min;
501 ps->val_max = max;
502 break;
503 }
504 }
505 if (!existing_ps)
506 {
507 ps = _progress_status_new(part_name, min);
508 ps->val_min = min;
509 ps->val_max = max;
510 sd->progress_status = eina_list_append(sd->progress_status, ps);
511 }
512}
513
514static void
480_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val) 515_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val)
481{ 516{
482 Efl_Ui_Progress_Status *ps; 517 Efl_Ui_Progress_Status *ps;
483 Eina_Bool existing_ps = EINA_FALSE; 518 Eina_Bool existing_ps = EINA_FALSE;
484 Eina_List *l; 519 Eina_List *l;
520 double min, max;
485 521
486 if (val < MIN_RATIO_LVL) val = MIN_RATIO_LVL; 522 efl_ui_range_min_max_get(efl_part(obj, part_name), &min, &max);
487 if (val > MAX_RATIO_LVL) val = MAX_RATIO_LVL; 523
524 if (val < min) val = min;
525 if (val > max) val = max;
488 526
489 if (!strcmp(part_name, "elm.cur.progressbar")) 527 if (!strcmp(part_name, "elm.cur.progressbar"))
490 sd->val = val; 528 sd->val = val;
@@ -501,6 +539,8 @@ _progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *pa
501 if (!existing_ps) 539 if (!existing_ps)
502 { 540 {
503 ps = _progress_status_new(part_name, val); 541 ps = _progress_status_new(part_name, val);
542 ps->val_min = 0.0;
543 ps->val_max = 1.0;
504 sd->progress_status = eina_list_append(sd->progress_status, ps); 544 sd->progress_status = eina_list_append(sd->progress_status, ps);
505 } 545 }
506 else 546 else
@@ -535,9 +575,9 @@ _efl_ui_progressbar_efl_ui_range_range_value_set(Eo *obj, Efl_Ui_Progressbar_Dat
535} 575}
536 576
537EOLIAN static double 577EOLIAN static double
538_efl_ui_progressbar_efl_ui_range_range_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd) 578_efl_ui_progressbar_efl_ui_range_range_value_get(Eo *obj, Efl_Ui_Progressbar_Data *sd EINA_UNUSED)
539{ 579{
540 return sd->val; 580 return efl_ui_range_value_get(efl_part(obj, "elm.cur.progressbar"));
541} 581}
542 582
543EOLIAN static void 583EOLIAN static void
@@ -583,6 +623,19 @@ _efl_ui_progressbar_pulse_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
583 return (sd->pulse_state && sd->pulse); 623 return (sd->pulse_state && sd->pulse);
584} 624}
585 625
626EOLIAN static void
627_efl_ui_progressbar_efl_ui_range_range_min_max_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double min, double max)
628{
629 _progress_part_min_max_set(sd, "elm.cur.progressbar", min, max);
630}
631
632EOLIAN static void
633_efl_ui_progressbar_efl_ui_range_range_min_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double *min, double *max)
634{
635 if (min) *min = sd->val_min;
636 if (max) *max = sd->val_max;
637}
638
586/* Efl.Part begin */ 639/* Efl.Part begin */
587 640
588EOLIAN static Eo * 641EOLIAN static Eo *
@@ -622,6 +675,35 @@ _efl_ui_progressbar_efl_access_value_value_and_text_get(Eo *obj EINA_UNUSED, Efl
622 if (value) *value = _pd->val; 675 if (value) *value = _pd->val;
623} 676}
624 677
678EOLIAN static void
679_efl_ui_progressbar_part_efl_ui_range_range_min_max_set(Eo *obj, void *_pd EINA_UNUSED, double min, double max)
680{
681 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
682 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
683
684 _progress_part_min_max_set(sd, pd->part, min, max);
685}
686
687EOLIAN static void
688_efl_ui_progressbar_part_efl_ui_range_range_min_max_get(Eo *obj, void *_pd EINA_UNUSED, double *min, double *max)
689{
690 Efl_Ui_Progress_Status *ps;
691 Eina_List *l;
692
693 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
694 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
695
696 EINA_LIST_FOREACH(sd->progress_status, l, ps)
697 {
698 if (!strcmp(ps->part_name, pd->part))
699 {
700 if (min) *min = ps->val_min;
701 if (max) *max = ps->val_max;
702 break;
703 }
704 }
705}
706
625#include "efl_ui_progressbar_part.eo.c" 707#include "efl_ui_progressbar_part.eo.c"
626 708
627/* Efl.Part end */ 709/* Efl.Part end */
diff --git a/src/lib/elementary/efl_ui_progressbar.eo b/src/lib/elementary/efl_ui_progressbar.eo
index fd1e890af4..c8c16f1d31 100644
--- a/src/lib/elementary/efl_ui_progressbar.eo
+++ b/src/lib/elementary/efl_ui_progressbar.eo
@@ -54,6 +54,7 @@ class Efl.Ui.Progressbar (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Format,
54 Efl.Ui.Widget.widget_sub_object_add; 54 Efl.Ui.Widget.widget_sub_object_add;
55 Efl.Ui.Widget.widget_sub_object_del; 55 Efl.Ui.Widget.widget_sub_object_del;
56 Efl.Ui.Range.range_value { get; set; } 56 Efl.Ui.Range.range_value { get; set; }
57 Efl.Ui.Range.range_min_max {get; set; }
57 Efl.Ui.Direction.direction { get; set; } 58 Efl.Ui.Direction.direction { get; set; }
58 Efl.Ui.Format.format_cb { set; } 59 Efl.Ui.Format.format_cb { set; }
59 Efl.Part.part; 60 Efl.Part.part;
diff --git a/src/lib/elementary/efl_ui_progressbar_part.eo b/src/lib/elementary/efl_ui_progressbar_part.eo
index a57bfa7cdc..f1d2515c96 100644
--- a/src/lib/elementary/efl_ui_progressbar_part.eo
+++ b/src/lib/elementary/efl_ui_progressbar_part.eo
@@ -4,5 +4,6 @@ class Efl.Ui.Progressbar.Part (Efl.Ui.Layout.Part, Efl.Ui.Range)
4 data: null; 4 data: null;
5 implements { 5 implements {
6 Efl.Ui.Range.range_value { set; get; } 6 Efl.Ui.Range.range_value { set; get; }
7 Efl.Ui.Range.range_min_max {get; set; }
7 } 8 }
8} 9}
diff --git a/src/lib/elementary/efl_ui_progressbar_private.h b/src/lib/elementary/efl_ui_progressbar_private.h
index c9b0c9b11f..7bdf8a98a0 100644
--- a/src/lib/elementary/efl_ui_progressbar_private.h
+++ b/src/lib/elementary/efl_ui_progressbar_private.h
@@ -32,6 +32,9 @@ struct _Efl_Ui_Progressbar_Data
32 32
33 Evas_Coord size; /**< Width or height of progressbar */ 33 Evas_Coord size; /**< Width or height of progressbar */
34 double val; /**< Value of progressbar */ 34 double val; /**< Value of progressbar */
35
36 double val_min;
37 double val_max;
35 38
36 Eina_List *progress_status; /**< The list of _Elm_Progress_Status. To save the progress value(in percentage) each part of given progress bar */ 39 Eina_List *progress_status; /**< The list of _Elm_Progress_Status. To save the progress value(in percentage) each part of given progress bar */
37 40
@@ -52,6 +55,7 @@ struct _Efl_Ui_Progress_Status
52{ 55{
53 const char *part_name; 56 const char *part_name;
54 double val; 57 double val;
58 double val_min, val_max;
55}; 59};
56 60
57/** 61/**