summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.c93
-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, 268 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 b080c61f87..2325140ac7 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -928,6 +928,7 @@ bin/elementary/test_photocam.c \
928bin/elementary/test_popup.c \ 928bin/elementary/test_popup.c \
929bin/elementary/test_prefs.c \ 929bin/elementary/test_prefs.c \
930bin/elementary/test_progressbar.c \ 930bin/elementary/test_progressbar.c \
931bin/elementary/test_ui_progressbar.c \
931bin/elementary/test_radio.c \ 932bin/elementary/test_radio.c \
932bin/elementary/test_scaling.c \ 933bin/elementary/test_scaling.c \
933bin/elementary/test_scroller.c \ 934bin/elementary/test_scroller.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 1f75b930cb..74902ffcb3 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -169,6 +169,7 @@ void test_win_state2(void *data, Evas_Object *obj, void *event_info);
169void test_win_stack(void *data, Evas_Object *obj, void *event_info); 169void test_win_stack(void *data, Evas_Object *obj, void *event_info);
170void test_progressbar(void *data, Evas_Object *obj, void *event_info); 170void test_progressbar(void *data, Evas_Object *obj, void *event_info);
171void test_progressbar2(void *data, Evas_Object *obj, void *event_info); 171void test_progressbar2(void *data, Evas_Object *obj, void *event_info);
172void test_ui_progressbar(void *data, Evas_Object *obj, void *event_info);
172void test_fileselector(void *data, Evas_Object *obj, void *event_info); 173void test_fileselector(void *data, Evas_Object *obj, void *event_info);
173void test_separator(void *data, Evas_Object *obj, void *event_info); 174void test_separator(void *data, Evas_Object *obj, void *event_info);
174void test_scroller(void *data, Evas_Object *obj, void *event_info); 175void test_scroller(void *data, Evas_Object *obj, void *event_info);
@@ -1041,6 +1042,7 @@ add_tests:
1041 ADD_TEST(NULL, "Range Values", "Slider", test_slider); 1042 ADD_TEST(NULL, "Range Values", "Slider", test_slider);
1042 ADD_TEST(NULL, "Range Values", "Progressbar", test_progressbar); 1043 ADD_TEST(NULL, "Range Values", "Progressbar", test_progressbar);
1043 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2); 1044 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2);
1045 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Progressbar", test_ui_progressbar);
1044 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate); 1046 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate);
1045 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval); 1047 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval);
1046 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider", test_ui_slider); 1048 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..509969e83f
--- /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.14))
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 0ecaed2a0b..9ab3e32de6 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -115,6 +115,8 @@ _units_set(Evas_Object *obj)
115 // Keeping this bug since the legacy code was like that. 115 // Keeping this bug since the legacy code was like that.
116 if (sd->is_legacy_format_string && !sd->is_legacy_format_cb) 116 if (sd->is_legacy_format_string && !sd->is_legacy_format_cb)
117 eina_value_set(&val, 100 * sd->val); 117 eina_value_set(&val, 100 * sd->val);
118 else
119 eina_value_set(&val, sd->val);
118 120
119 eina_strbuf_reset(sd->format_strbuf); 121 eina_strbuf_reset(sd->format_strbuf);
120 sd->format_cb(sd->format_cb_data, sd->format_strbuf, val); 122 sd->format_cb(sd->format_cb_data, sd->format_strbuf, val);
@@ -141,7 +143,8 @@ _val_set(Evas_Object *obj)
141 143
142 EINA_LIST_FOREACH(sd->progress_status, l, ps) 144 EINA_LIST_FOREACH(sd->progress_status, l, ps)
143 { 145 {
144 pos = ps->val; 146 pos = (ps->val - ps->val_min)/(ps->val_max - ps->val_min);
147
145 if ((!rtl && _is_inverted(sd->dir)) || 148 if ((!rtl && _is_inverted(sd->dir)) ||
146 (rtl && ((sd->dir == EFL_UI_DIR_UP) || 149 (rtl && ((sd->dir == EFL_UI_DIR_UP) ||
147 (sd->dir == EFL_UI_DIR_RIGHT)))) 150 (sd->dir == EFL_UI_DIR_RIGHT))))
@@ -362,7 +365,7 @@ _efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data
362 365
363 priv->dir = EFL_UI_DIR_RIGHT; 366 priv->dir = EFL_UI_DIR_RIGHT;
364 priv->val = MIN_RATIO_LVL; 367 priv->val = MIN_RATIO_LVL;
365 368 priv->val_max = 1.0;
366 group = _efl_ui_progressbar_theme_group_get(obj, priv); 369 group = _efl_ui_progressbar_theme_group_get(obj, priv);
367 370
368 if (!elm_widget_theme_object_set(obj, wd->resize_obj, 371 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
@@ -479,14 +482,49 @@ _progressbar_span_size_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Evas_Coord size
479} 482}
480 483
481static void 484static void
485_progress_part_min_max_set(Efl_Ui_Progressbar_Data *sd, const char *part_name, double min, double max)
486{
487 Efl_Ui_Progress_Status *ps;
488 Eina_Bool existing_ps = EINA_FALSE;
489 Eina_List *l;
490
491 if (!strcmp(part_name, "elm.cur.progressbar"))
492 {
493 sd->val_min = min;
494 sd->val_max = max;
495 }
496
497 EINA_LIST_FOREACH(sd->progress_status, l, ps)
498 {
499 if (!strcmp(ps->part_name, part_name))
500 {
501 existing_ps = EINA_TRUE;
502 ps->val_min = min;
503 ps->val_max = max;
504 break;
505 }
506 }
507 if (!existing_ps)
508 {
509 ps = _progress_status_new(part_name, min);
510 ps->val_min = min;
511 ps->val_max = max;
512 sd->progress_status = eina_list_append(sd->progress_status, ps);
513 }
514}
515
516static void
482_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val) 517_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val)
483{ 518{
484 Efl_Ui_Progress_Status *ps; 519 Efl_Ui_Progress_Status *ps;
485 Eina_Bool existing_ps = EINA_FALSE; 520 Eina_Bool existing_ps = EINA_FALSE;
486 Eina_List *l; 521 Eina_List *l;
522 double min, max;
523
524 efl_ui_range_min_max_get(efl_part(obj, part_name), &min, &max);
487 525
488 if (val < MIN_RATIO_LVL) val = MIN_RATIO_LVL; 526 if (val < min) val = min;
489 if (val > MAX_RATIO_LVL) val = MAX_RATIO_LVL; 527 if (val > max) val = max;
490 528
491 if (!strcmp(part_name, "elm.cur.progressbar")) 529 if (!strcmp(part_name, "elm.cur.progressbar"))
492 sd->val = val; 530 sd->val = val;
@@ -503,6 +541,8 @@ _progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *pa
503 if (!existing_ps) 541 if (!existing_ps)
504 { 542 {
505 ps = _progress_status_new(part_name, val); 543 ps = _progress_status_new(part_name, val);
544 ps->val_min = 0.0;
545 ps->val_max = 1.0;
506 sd->progress_status = eina_list_append(sd->progress_status, ps); 546 sd->progress_status = eina_list_append(sd->progress_status, ps);
507 } 547 }
508 else 548 else
@@ -537,9 +577,9 @@ _efl_ui_progressbar_efl_ui_range_range_value_set(Eo *obj, Efl_Ui_Progressbar_Dat
537} 577}
538 578
539EOLIAN static double 579EOLIAN static double
540_efl_ui_progressbar_efl_ui_range_range_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd) 580_efl_ui_progressbar_efl_ui_range_range_value_get(Eo *obj, Efl_Ui_Progressbar_Data *sd EINA_UNUSED)
541{ 581{
542 return sd->val; 582 return efl_ui_range_value_get(efl_part(obj, "elm.cur.progressbar"));
543} 583}
544 584
545EOLIAN static void 585EOLIAN static void
@@ -586,6 +626,19 @@ _efl_ui_progressbar_pulse_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
586} 626}
587 627
588EOLIAN static void 628EOLIAN static void
629_efl_ui_progressbar_efl_ui_range_range_min_max_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double min, double max)
630{
631 _progress_part_min_max_set(sd, "elm.cur.progressbar", min, max);
632}
633
634EOLIAN static void
635_efl_ui_progressbar_efl_ui_range_range_min_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double *min, double *max)
636{
637 if (min) *min = sd->val_min;
638 if (max) *max = sd->val_max;
639}
640
641EOLIAN static void
589_efl_ui_progressbar_class_constructor(Efl_Class *klass) 642_efl_ui_progressbar_class_constructor(Efl_Class *klass)
590{ 643{
591 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 644 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
@@ -630,6 +683,34 @@ _efl_ui_progressbar_efl_access_value_value_and_text_get(Eo *obj EINA_UNUSED, Efl
630 if (value) *value = _pd->val; 683 if (value) *value = _pd->val;
631} 684}
632 685
686EOLIAN static void
687_efl_ui_progressbar_part_efl_ui_range_range_min_max_set(Eo *obj, void *_pd EINA_UNUSED, double min, double max)
688{
689 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
690 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
691
692 _progress_part_min_max_set(sd, pd->part, min, max);
693}
694
695EOLIAN static void
696_efl_ui_progressbar_part_efl_ui_range_range_min_max_get(Eo *obj, void *_pd EINA_UNUSED, double *min, double *max)
697{
698 Efl_Ui_Progress_Status *ps;
699 Eina_List *l;
700
701 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
702 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
703
704 EINA_LIST_FOREACH(sd->progress_status, l, ps)
705 {
706 if (!strcmp(ps->part_name, pd->part))
707 {
708 if (min) *min = ps->val_min;
709 if (max) *max = ps->val_max;
710 break;
711 }
712 }
713}
633#include "efl_ui_progressbar_part.eo.c" 714#include "efl_ui_progressbar_part.eo.c"
634 715
635/* Efl.Part end */ 716/* Efl.Part end */
diff --git a/src/lib/elementary/efl_ui_progressbar.eo b/src/lib/elementary/efl_ui_progressbar.eo
index 3100b90ec0..d58c764772 100644
--- a/src/lib/elementary/efl_ui_progressbar.eo
+++ b/src/lib/elementary/efl_ui_progressbar.eo
@@ -55,6 +55,7 @@ class Efl.Ui.Progressbar (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Format,
55 Efl.Ui.Widget.widget_sub_object_add; 55 Efl.Ui.Widget.widget_sub_object_add;
56 Efl.Ui.Widget.widget_sub_object_del; 56 Efl.Ui.Widget.widget_sub_object_del;
57 Efl.Ui.Range.range_value { get; set; } 57 Efl.Ui.Range.range_value { get; set; }
58 Efl.Ui.Range.range_min_max {get; set; }
58 Efl.Ui.Direction.direction { get; set; } 59 Efl.Ui.Direction.direction { get; set; }
59 Efl.Ui.Format.format_cb { set; } 60 Efl.Ui.Format.format_cb { set; }
60 Efl.Part.part; 61 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/**