diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/elementary/src/bin/test_progressbar.c | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_progressbar.c b/libraries/elementary/src/bin/test_progressbar.c new file mode 100644 index 0000000..6eed552 --- /dev/null +++ b/libraries/elementary/src/bin/test_progressbar.c | |||
@@ -0,0 +1,199 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #endif | ||
4 | #include <Elementary.h> | ||
5 | #ifndef ELM_LIB_QUICKLAUNCH | ||
6 | typedef struct Progressbar | ||
7 | { | ||
8 | Evas_Object *pb1; | ||
9 | Evas_Object *pb2; | ||
10 | Evas_Object *pb3; | ||
11 | Evas_Object *pb4; | ||
12 | Evas_Object *pb5; | ||
13 | Evas_Object *pb6; | ||
14 | Evas_Object *pb7; | ||
15 | Eina_Bool run; | ||
16 | Ecore_Timer *timer; | ||
17 | } Progressbar; | ||
18 | |||
19 | static Progressbar _test_progressbar; | ||
20 | |||
21 | static Eina_Bool | ||
22 | _my_progressbar_value_set (void *data __UNUSED__) | ||
23 | { | ||
24 | double progress; | ||
25 | |||
26 | progress = elm_progressbar_value_get (_test_progressbar.pb1); | ||
27 | if (progress < 1.0) progress += 0.0123; | ||
28 | else progress = 0.0; | ||
29 | elm_progressbar_value_set(_test_progressbar.pb1, progress); | ||
30 | elm_progressbar_value_set(_test_progressbar.pb4, progress); | ||
31 | elm_progressbar_value_set(_test_progressbar.pb3, progress); | ||
32 | elm_progressbar_value_set(_test_progressbar.pb6, progress); | ||
33 | if (progress < 1.0) return ECORE_CALLBACK_RENEW; | ||
34 | _test_progressbar.run = 0; | ||
35 | return ECORE_CALLBACK_CANCEL; | ||
36 | } | ||
37 | |||
38 | static void | ||
39 | my_progressbar_test_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
40 | { | ||
41 | elm_progressbar_pulse(_test_progressbar.pb2, EINA_TRUE); | ||
42 | elm_progressbar_pulse(_test_progressbar.pb5, EINA_TRUE); | ||
43 | elm_progressbar_pulse(_test_progressbar.pb7, EINA_TRUE); | ||
44 | if (!_test_progressbar.run) | ||
45 | { | ||
46 | _test_progressbar.timer = ecore_timer_add(0.1, _my_progressbar_value_set, NULL); | ||
47 | _test_progressbar.run = EINA_TRUE; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | static void | ||
52 | my_progressbar_test_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
53 | { | ||
54 | elm_progressbar_pulse(_test_progressbar.pb2, EINA_FALSE); | ||
55 | elm_progressbar_pulse(_test_progressbar.pb5, EINA_FALSE); | ||
56 | elm_progressbar_pulse(_test_progressbar.pb7, EINA_FALSE); | ||
57 | if (_test_progressbar.run) | ||
58 | { | ||
59 | ecore_timer_del(_test_progressbar.timer); | ||
60 | _test_progressbar.run = EINA_FALSE; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | static void | ||
65 | my_progressbar_destroy(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
66 | { | ||
67 | my_progressbar_test_stop(NULL, NULL, NULL); | ||
68 | evas_object_del(obj); | ||
69 | } | ||
70 | |||
71 | void | ||
72 | test_progressbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
73 | { | ||
74 | Evas_Object *win, *pb, *bx, *hbx, *bt, *bt_bx, *ic1, *ic2; | ||
75 | char buf[PATH_MAX]; | ||
76 | |||
77 | win = elm_win_util_standard_add("progressbar", "Progressbar"); | ||
78 | evas_object_smart_callback_add(win, "delete,request", | ||
79 | my_progressbar_destroy, NULL); | ||
80 | |||
81 | bx = elm_box_add(win); | ||
82 | elm_win_resize_object_add(win, bx); | ||
83 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
84 | evas_object_show(bx); | ||
85 | |||
86 | pb = elm_progressbar_add(win); | ||
87 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
88 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
89 | elm_box_pack_end(bx, pb); | ||
90 | // elm_progressbar_horizontal_set(pb, EINA_TRUE); | ||
91 | // elm_object_text_set(pb, "Progression %"); | ||
92 | // elm_progressbar_unit_format_set(pb, NULL); | ||
93 | evas_object_show(pb); | ||
94 | _test_progressbar.pb1 = pb; | ||
95 | |||
96 | pb = elm_progressbar_add(win); | ||
97 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
98 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
99 | elm_object_text_set(pb, "Infinite bounce"); | ||
100 | elm_progressbar_pulse_set(pb, EINA_TRUE); | ||
101 | elm_box_pack_end(bx, pb); | ||
102 | evas_object_show(pb); | ||
103 | _test_progressbar.pb2 = pb; | ||
104 | |||
105 | ic1 = elm_icon_add(win); | ||
106 | snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); | ||
107 | elm_icon_file_set(ic1, buf, NULL); | ||
108 | evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); | ||
109 | |||
110 | pb = elm_progressbar_add(win); | ||
111 | elm_object_text_set(pb, "Label"); | ||
112 | elm_object_part_content_set(pb, "icon", ic1); | ||
113 | elm_progressbar_inverted_set(pb, 1); | ||
114 | elm_progressbar_unit_format_set(pb, "%1.1f units"); | ||
115 | elm_progressbar_span_size_set(pb, 200); | ||
116 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
117 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
118 | elm_box_pack_end(bx, pb); | ||
119 | evas_object_show(ic1); | ||
120 | evas_object_show(pb); | ||
121 | _test_progressbar.pb3 = pb; | ||
122 | |||
123 | hbx = elm_box_add(win); | ||
124 | elm_box_horizontal_set(hbx, EINA_TRUE); | ||
125 | evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
126 | evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
127 | elm_box_pack_end(bx, hbx); | ||
128 | evas_object_show(hbx); | ||
129 | |||
130 | pb = elm_progressbar_add(win); | ||
131 | elm_progressbar_horizontal_set(pb, EINA_FALSE); | ||
132 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
133 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
134 | elm_box_pack_end(hbx, pb); | ||
135 | elm_progressbar_span_size_set(pb, 60); | ||
136 | elm_object_text_set(pb, "percent"); | ||
137 | evas_object_show(pb); | ||
138 | _test_progressbar.pb4 = pb; | ||
139 | |||
140 | pb = elm_progressbar_add(win); | ||
141 | elm_progressbar_horizontal_set(pb, EINA_FALSE); | ||
142 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
143 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
144 | elm_progressbar_span_size_set(pb, 80); | ||
145 | elm_progressbar_pulse_set(pb, EINA_TRUE); | ||
146 | elm_progressbar_unit_format_set(pb, NULL); | ||
147 | elm_object_text_set(pb, "Infinite bounce"); | ||
148 | elm_box_pack_end(hbx, pb); | ||
149 | evas_object_show(pb); | ||
150 | _test_progressbar.pb5 = pb; | ||
151 | |||
152 | ic2 = elm_icon_add(win); | ||
153 | elm_icon_file_set(ic2, buf, NULL); | ||
154 | evas_object_size_hint_aspect_set(ic2, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1); | ||
155 | |||
156 | pb = elm_progressbar_add(win); | ||
157 | elm_progressbar_horizontal_set(pb, EINA_FALSE); | ||
158 | elm_object_text_set(pb, "Label"); | ||
159 | elm_object_part_content_set(pb, "icon", ic2); | ||
160 | elm_progressbar_inverted_set(pb, 1); | ||
161 | elm_progressbar_unit_format_set(pb, "%1.2f%%"); | ||
162 | elm_progressbar_span_size_set(pb, 200); | ||
163 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
164 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
165 | elm_box_pack_end(hbx, pb); | ||
166 | evas_object_show(ic2); | ||
167 | evas_object_show(pb); | ||
168 | _test_progressbar.pb6 = pb; | ||
169 | |||
170 | pb = elm_progressbar_add(win); | ||
171 | elm_object_style_set(pb, "wheel"); | ||
172 | elm_object_text_set(pb, "Style: wheel"); | ||
173 | evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); | ||
174 | evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
175 | elm_box_pack_end(bx, pb); | ||
176 | evas_object_show(pb); | ||
177 | _test_progressbar.pb7 = pb; | ||
178 | |||
179 | bt_bx = elm_box_add(win); | ||
180 | elm_box_horizontal_set(bt_bx, EINA_TRUE); | ||
181 | evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
182 | elm_box_pack_end(bx, bt_bx); | ||
183 | evas_object_show(bt_bx); | ||
184 | |||
185 | bt = elm_button_add(win); | ||
186 | elm_object_text_set(bt, "Start"); | ||
187 | evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_start, NULL); | ||
188 | elm_box_pack_end(bt_bx, bt); | ||
189 | evas_object_show(bt); | ||
190 | |||
191 | bt = elm_button_add(win); | ||
192 | elm_object_text_set(bt, "Stop"); | ||
193 | evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_stop, NULL); | ||
194 | elm_box_pack_end(bt_bx, bt); | ||
195 | evas_object_show(bt); | ||
196 | |||
197 | evas_object_show(win); | ||
198 | } | ||
199 | #endif | ||