summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-02-10 00:13:03 +0100
committerdavemds <dave@gurumeditation.it>2014-02-10 00:13:03 +0100
commitcc07e231e9c2b2c59e36f4c0d13f36d4e59bd5f3 (patch)
tree478a0f29248207689ce81e624b5379472909b8e4 /src/bin
parent3ce61868e88fa95d507e01587bf4cbbec9b0d1a1 (diff)
Label: add 2 new api for setting the slide animation speed.
Added API: void elm_label_slide_speed_set(Evas_Object *obj, double speed); double elm_label_slide_speed_get(const Evas_Object *obj); This work is based on the previous reverted commit by nirajkr, thanks! I hope this will fullfill his requirement, please let me know of any problems.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_label.c100
1 files changed, 79 insertions, 21 deletions
diff --git a/src/bin/test_label.c b/src/bin/test_label.c
index 7e6a73d68..abaf83700 100644
--- a/src/bin/test_label.c
+++ b/src/bin/test_label.c
@@ -100,19 +100,35 @@ _cb_size_radio_changed(void *data, Evas_Object *obj, void *event EINA_UNUSED)
100} 100}
101 101
102static void 102static void
103_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 103_duration_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
104{ 104{
105 Evas_Object *lb = (Evas_Object *)data; 105 Evas_Object *lb = (Evas_Object *)data;
106 double val = elm_slider_value_get(obj); 106 double val = elm_slider_value_get(obj);
107
107 elm_label_slide_duration_set(lb, val); 108 elm_label_slide_duration_set(lb, val);
108 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS);
109 elm_label_slide_go(lb); 109 elm_label_slide_go(lb);
110
111 Evas_Object *sl = evas_object_data_get(lb, "speed_slider");
112 elm_slider_value_set(sl, elm_label_slide_speed_get(lb));
113}
114
115static void
116_speed_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
117{
118 Evas_Object *lb = (Evas_Object *)data;
119 double val = elm_slider_value_get(obj);
120
121 elm_label_slide_speed_set(lb, val);
122 elm_label_slide_go(lb);
123
124 Evas_Object *sl = evas_object_data_get(lb, "duration_slider");
125 elm_slider_value_set(sl, elm_label_slide_duration_get(lb));
110} 126}
111 127
112void 128void
113test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 129test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
114{ 130{
115 Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl; 131 Evas_Object *win, *gd, *rect, *lb, *lb1, *lb2, *rd, *rdg, *sl;
116 132
117 win = elm_win_util_standard_add("label2", "Label 2"); 133 win = elm_win_util_standard_add("label2", "Label 2");
118 elm_win_autodel_set(win, EINA_TRUE); 134 elm_win_autodel_set(win, EINA_TRUE);
@@ -126,13 +142,11 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
126 /* Test Label Ellipsis */ 142 /* Test Label Ellipsis */
127 lb = elm_label_add(win); 143 lb = elm_label_add(win);
128 elm_object_text_set(lb, "Test Label Ellipsis:"); 144 elm_object_text_set(lb, "Test Label Ellipsis:");
129 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS); 145 elm_grid_pack(gd, lb, 5, 0, 90, 10);
130 elm_label_slide_go(lb);
131 elm_grid_pack(gd, lb, 5, 5, 90, 10);
132 evas_object_show(lb); 146 evas_object_show(lb);
133 147
134 rect = evas_object_rectangle_add(evas_object_evas_get(win)); 148 rect = evas_object_rectangle_add(evas_object_evas_get(win));
135 elm_grid_pack(gd, rect, 5, 15, 90, 10); 149 elm_grid_pack(gd, rect, 5, 10, 90, 10);
136 evas_object_color_set(rect, 255, 125, 125, 255); 150 evas_object_color_set(rect, 255, 125, 125, 255);
137 evas_object_show(rect); 151 evas_object_show(rect);
138 152
@@ -144,19 +158,17 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
144 "at the end of the widget." 158 "at the end of the widget."
145 ); 159 );
146 elm_label_ellipsis_set(lb, EINA_TRUE); 160 elm_label_ellipsis_set(lb, EINA_TRUE);
147 elm_grid_pack(gd, lb, 5, 15, 90, 10); 161 elm_grid_pack(gd, lb, 5, 10, 90, 10);
148 evas_object_show(lb); 162 evas_object_show(lb);
149 163
150 /* Test Label Slide */ 164 /* Test Label Slide */
151 lb = elm_label_add(win); 165 lb = elm_label_add(win);
152 elm_object_text_set(lb, "Test Label Slide:"); 166 elm_object_text_set(lb, "Test Label Slide:");
153 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS); 167 elm_grid_pack(gd, lb, 5, 20, 90, 10);
154 elm_label_slide_go(lb);
155 elm_grid_pack(gd, lb, 5, 30, 90, 10);
156 evas_object_show(lb); 168 evas_object_show(lb);
157 169
158 rect = evas_object_rectangle_add(evas_object_evas_get(win)); 170 rect = evas_object_rectangle_add(evas_object_evas_get(win));
159 elm_grid_pack(gd, rect, 5, 40, 90, 10); 171 elm_grid_pack(gd, rect, 5, 30, 90, 10);
160 evas_object_color_set(rect, 255, 125, 125, 255); 172 evas_object_color_set(rect, 255, 125, 125, 255);
161 evas_object_show(rect); 173 evas_object_show(rect);
162 174
@@ -169,9 +181,10 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
169 "This only works with the themes \"slide_short\", " 181 "This only works with the themes \"slide_short\", "
170 "\"slide_long\" and \"slide_bounce\"." 182 "\"slide_long\" and \"slide_bounce\"."
171 ); 183 );
172 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS); 184 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_AUTO);
185 elm_label_slide_speed_set(lb, 40.0);
173 elm_label_slide_go(lb); 186 elm_label_slide_go(lb);
174 elm_grid_pack(gd, lb, 5, 40, 90, 10); 187 elm_grid_pack(gd, lb, 5, 30, 90, 10);
175 evas_object_show(lb); 188 evas_object_show(lb);
176 189
177 rd = elm_radio_add(win); 190 rd = elm_radio_add(win);
@@ -179,7 +192,7 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
179 elm_object_text_set(rd, "slide_short"); 192 elm_object_text_set(rd, "slide_short");
180 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 193 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
181 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); 194 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
182 elm_grid_pack(gd, rd, 5, 50, 30, 10); 195 elm_grid_pack(gd, rd, 5, 40, 30, 10);
183 evas_object_show(rd); 196 evas_object_show(rd);
184 rdg = rd; 197 rdg = rd;
185 198
@@ -189,7 +202,7 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
189 elm_object_text_set(rd, "slide_long"); 202 elm_object_text_set(rd, "slide_long");
190 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 203 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
191 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); 204 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
192 elm_grid_pack(gd, rd, 35, 50, 30, 10); 205 elm_grid_pack(gd, rd, 35, 40, 30, 10);
193 evas_object_show(rd); 206 evas_object_show(rd);
194 207
195 rd = elm_radio_add(win); 208 rd = elm_radio_add(win);
@@ -198,20 +211,65 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
198 elm_object_text_set(rd, "slide_bounce"); 211 elm_object_text_set(rd, "slide_bounce");
199 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 212 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
200 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); 213 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
201 elm_grid_pack(gd, rd, 65, 50, 30, 10); 214 elm_grid_pack(gd, rd, 65, 40, 30, 10);
202 evas_object_show(rd); 215 evas_object_show(rd);
203 216
204 sl = elm_slider_add(win); 217 sl = elm_slider_add(win);
205 elm_object_text_set(sl, "Slide Duration"); 218 elm_object_text_set(sl, "Slide Duration");
206 elm_slider_unit_format_set(sl, "%1.1f units"); 219 elm_slider_unit_format_set(sl, "%1.1f sec");
207 elm_slider_min_max_set(sl, 1, 20); 220 elm_slider_min_max_set(sl, 3, 30);
208 elm_slider_value_set(sl, 10); 221 elm_slider_value_set(sl, elm_label_slide_duration_get(lb));
209 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); 222 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
210 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 223 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 evas_object_smart_callback_add(sl, "changed", _change_cb, lb); 224 evas_object_smart_callback_add(sl, "changed", _duration_change_cb, lb);
225 evas_object_data_set(lb, "duration_slider", sl);
226 elm_grid_pack(gd, sl, 5, 50, 90, 10);
227 evas_object_show(sl);
228
229 sl = elm_slider_add(win);
230 elm_object_text_set(sl, "Slide Speed");
231 elm_slider_unit_format_set(sl, "%1.1f px/sec");
232 elm_slider_min_max_set(sl, 40, 300);
233 elm_slider_value_set(sl, elm_label_slide_speed_get(lb));
234 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
235 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 evas_object_smart_callback_add(sl, "changed", _speed_change_cb, lb);
237 evas_object_data_set(lb, "speed_slider", sl);
212 elm_grid_pack(gd, sl, 5, 60, 90, 10); 238 elm_grid_pack(gd, sl, 5, 60, 90, 10);
213 evas_object_show(sl); 239 evas_object_show(sl);
214 240
241 /* Test 2 label at the same speed */
242 lb = elm_label_add(win);
243 elm_object_text_set(lb, "Test 2 label with the same speed:");
244 elm_grid_pack(gd, lb, 5, 70, 90, 10);
245 evas_object_show(lb);
246
247 rect = evas_object_rectangle_add(evas_object_evas_get(win));
248 elm_grid_pack(gd, rect, 5, 80, 90, 20);
249 evas_object_color_set(rect, 255, 125, 125, 255);
250 evas_object_show(rect);
251
252 lb1 = elm_label_add(win);
253 elm_object_style_set(lb1, "slide_long");
254 elm_object_text_set(lb1, "This is a label set to slide with a fixed speed,"
255 " should match the speed with the below label."
256 " This label has few extra char for testing.");
257 elm_label_slide_mode_set(lb1, ELM_LABEL_SLIDE_MODE_ALWAYS);
258 elm_label_slide_speed_set(lb1, 40.0);
259 elm_label_slide_go(lb1);
260 elm_grid_pack(gd, lb1, 5, 80, 90, 10);
261 evas_object_show(lb1);
262
263 lb2 = elm_label_add(win);
264 elm_object_style_set(lb2, "slide_long");
265 elm_object_text_set(lb2, "This is a label set to slide and will"
266 " match the speed of the upper label.");
267 elm_label_slide_mode_set(lb2, ELM_LABEL_SLIDE_MODE_ALWAYS);
268 elm_label_slide_speed_set(lb2, 40.0);
269 elm_label_slide_go(lb2);
270 elm_grid_pack(gd, lb2, 5, 90, 90, 10);
271 evas_object_show(lb2);
272
215 evas_object_resize(win, 320, 320); 273 evas_object_resize(win, 320, 320);
216 evas_object_show(win); 274 evas_object_show(win);
217} 275}