aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/bin/test_photocam.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:20:32 +1000
committerDavid Walter Seikel2012-04-22 09:20:32 +1000
commit3ad3455551be0d7859ecb02290376206d5e66498 (patch)
tree497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/bin/test_photocam.c
parentUpdate EFL to latest beta. (diff)
downloadSledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz
And actually include new files, plus elementary libraries.
Diffstat (limited to '')
-rw-r--r--libraries/elementary/src/bin/test_photocam.c373
1 files changed, 373 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_photocam.c b/libraries/elementary/src/bin/test_photocam.c
new file mode 100644
index 0000000..75431ee
--- /dev/null
+++ b/libraries/elementary/src/bin/test_photocam.c
@@ -0,0 +1,373 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#ifndef ELM_LIB_QUICKLAUNCH
6
7static Evas_Object *rect;
8
9static void
10my_ph_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
11{
12 printf("clicked\n");
13}
14
15static void
16my_ph_press(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
17{
18 printf("press\n");
19}
20
21static void
22my_ph_longpressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
23{
24 printf("longpressed\n");
25}
26
27static void
28my_ph_clicked_double(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
29{
30 printf("clicked,double\n");
31}
32
33static void
34my_ph_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
35{
36 printf("load\n");
37}
38
39static void
40my_ph_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
41{
42 printf("loaded\n");
43}
44
45static void
46my_ph_load_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
47{
48 printf("load,details\n");
49}
50
51static void
52my_ph_loaded_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
53{
54 printf("loaded,details\n");
55}
56
57static void
58my_ph_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
59{
60 printf("zoom,start\n");
61}
62
63static void
64my_ph_zoom_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
65{
66 printf("zoom,stop\n");
67}
68
69static void
70my_ph_zoom_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
71{
72 printf("zoom,change\n");
73}
74
75static void
76my_ph_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
77{
78 printf("anim,start\n");
79}
80
81static void
82my_ph_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
83{
84 printf("anim,stop\n");
85}
86
87static void
88my_ph_drag_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
89{
90 printf("drag,start\n");
91}
92
93static void
94my_ph_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
95{
96 printf("drag_stop\n");
97}
98
99static void
100my_ph_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
101{
102 int x, y, w, h;
103 elm_photocam_image_region_get(obj, &x, &y, &w, &h);
104 printf("scroll %i %i %ix%i\n", x, y, w, h);
105}
106
107static void
108my_bt_open(void *data, Evas_Object *obj __UNUSED__, void *event_info)
109{
110 Evas_Object *ph = data;
111 const char *file = event_info;
112
113 if (file)
114 elm_photocam_file_set(ph, file);
115}
116
117static void
118my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
119{
120 elm_photocam_image_region_show(data, 30, 50, 500, 300);
121}
122
123static void
124my_bt_bring_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
125
126{
127 elm_photocam_image_region_bring_in(data, 800, 300, 500, 300);
128}
129
130static void
131my_bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
132{
133 double zoom;
134
135 zoom = elm_photocam_zoom_get(data);
136 zoom -= 0.5;
137 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
138 if (zoom >= (1.0 / 32.0)) elm_photocam_zoom_set(data, zoom);
139}
140
141static void
142my_bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
143{
144 double zoom;
145
146 zoom = elm_photocam_zoom_get(data);
147 zoom += 0.5;
148 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
149 if (zoom <= 256.0) elm_photocam_zoom_set(data, zoom);
150}
151
152static void
153my_bt_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
154{
155 elm_photocam_paused_set(data, !elm_photocam_paused_get(data));
156}
157
158static void
159my_bt_zoom_fit_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
160{
161 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT_IN);
162}
163
164static void
165my_bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
166{
167 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
168}
169
170static void
171my_bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
172{
173 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL);
174}
175
176static void
177my_bt_gesture(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
178{
179 elm_photocam_gesture_enabled_set(data, !elm_photocam_gesture_enabled_get(data));
180}
181
182static void
183_photocam_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
184{
185 Evas_Object *photocam = data;
186 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
187 int zoom;
188 double val;
189 //unset the mouse wheel
190 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
191
192 zoom = elm_photocam_zoom_get(photocam);
193 if ((ev->z>0) && (zoom == 1)) return;
194
195 if (ev->z > 0)
196 zoom /= 2;
197 else
198 zoom *= 2;
199
200 val = 1;
201 int _zoom = zoom;
202 while (_zoom>1)
203 {
204 _zoom /= 2;
205 val++;
206 }
207
208 elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
209 if (zoom >= 1) elm_photocam_zoom_set(photocam, zoom);
210}
211
212static void
213_photocam_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
214{
215 int x,y,w,h;
216
217 evas_object_geometry_get(data,&x,&y,&w,&h);
218 evas_object_resize(rect,w,h);
219 evas_object_move(rect,x,y);
220}
221
222void
223test_photocam(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
224{
225 Evas_Object *win, *ph, *tb2, *bt, *box;
226 // these were just testing - use the "select photo" browser to select one
227 const char *img[5] =
228 {
229 "/home/raster/t1.jpg", // 5 mpixel
230 "/home/raster/t2.jpg", // 18 mpixel
231 "/home/raster/t3.jpg", // 39 mpixel
232 "/home/raster/t4.jpg", // 192 mpixel
233 "/home/raster/t5.jpg" // 466 mpixel
234 };
235
236 win = elm_win_util_standard_add("photocam", "PhotoCam");
237 elm_win_autodel_set(win, EINA_TRUE);
238
239 ph = elm_photocam_add(win);
240 evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
241 elm_win_resize_object_add(win, ph);
242 evas_object_data_set(ph, "window", win);
243
244 rect = evas_object_rectangle_add(evas_object_evas_get(win));
245 evas_object_color_set(rect, 0, 0, 0, 0);
246 evas_object_repeat_events_set(rect,1);
247 evas_object_show(rect);
248 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_WHEEL, _photocam_mouse_wheel_cb, ph);
249 evas_object_raise(rect);
250
251 evas_object_event_callback_add(ph, EVAS_CALLBACK_RESIZE, _photocam_move_resize_cb, ph);
252 evas_object_event_callback_add(ph, EVAS_CALLBACK_MOVE, _photocam_move_resize_cb, ph);
253
254 evas_object_smart_callback_add(ph, "clicked", my_ph_clicked, win);
255 evas_object_smart_callback_add(ph, "press", my_ph_press, win);
256 evas_object_smart_callback_add(ph, "longpressed", my_ph_longpressed, win);
257 evas_object_smart_callback_add(ph, "clicked,double", my_ph_clicked_double, win);
258 evas_object_smart_callback_add(ph, "load", my_ph_load, win);
259 evas_object_smart_callback_add(ph, "loaded", my_ph_loaded, win);
260 evas_object_smart_callback_add(ph, "load,details", my_ph_load_details, win);
261 evas_object_smart_callback_add(ph, "loaded,details", my_ph_loaded_details, win);
262 evas_object_smart_callback_add(ph, "zoom,start", my_ph_zoom_start, win);
263 evas_object_smart_callback_add(ph, "zoom,stop", my_ph_zoom_stop, win);
264 evas_object_smart_callback_add(ph, "zoom,change", my_ph_zoom_change, win);
265 evas_object_smart_callback_add(ph, "scroll,anim,start", my_ph_anim_start, win);
266 evas_object_smart_callback_add(ph, "scroll,anim,stop", my_ph_anim_stop, win);
267 evas_object_smart_callback_add(ph, "scroll,drag,start", my_ph_drag_start, win);
268 evas_object_smart_callback_add(ph, "scroll,drag,stop", my_ph_drag_stop, win);
269 evas_object_smart_callback_add(ph, "scroll", my_ph_scroll, win);
270
271 elm_photocam_file_set(ph, img[1]);
272
273 evas_object_show(ph);
274
275 tb2 = elm_table_add(win);
276 evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
277 elm_win_resize_object_add(win, tb2);
278
279 bt = elm_button_add(win);
280 elm_object_text_set(bt, "Z -");
281 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_out, ph);
282 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
283 evas_object_size_hint_align_set(bt, 0.1, 0.1);
284 elm_table_pack(tb2, bt, 0, 0, 1, 1);
285 evas_object_show(bt);
286
287 bt = elm_fileselector_button_add(win);
288 elm_object_text_set(bt, "Select Photo");
289 evas_object_smart_callback_add(bt, "file,chosen", my_bt_open, ph);
290 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
291 evas_object_size_hint_align_set(bt, 0.5, 0.1);
292 elm_table_pack(tb2, bt, 1, 0, 1, 1);
293 evas_object_show(bt);
294
295 bt = elm_button_add(win);
296 elm_object_text_set(bt, "Z +");
297 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_in, ph);
298 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299 evas_object_size_hint_align_set(bt, 0.9, 0.1);
300 elm_table_pack(tb2, bt, 2, 0, 1, 1);
301 evas_object_show(bt);
302
303 bt = elm_button_add(win);
304 elm_object_text_set(bt, "Show 30,50 500x300");
305 evas_object_smart_callback_add(bt, "clicked", my_bt_show_reg, ph);
306 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
307 evas_object_size_hint_align_set(bt, 0.1, 0.5);
308 elm_table_pack(tb2, bt, 0, 1, 1, 1);
309 evas_object_show(bt);
310
311 bt = elm_button_add(win);
312 elm_object_text_set(bt, "Bring 800,300 500x300");
313 evas_object_smart_callback_add(bt, "clicked", my_bt_bring_reg, ph);
314 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
315 evas_object_size_hint_align_set(bt, 0.9, 0.5);
316 elm_table_pack(tb2, bt, 2, 1, 1, 1);
317 evas_object_show(bt);
318
319 box = elm_box_add(win);
320 elm_box_horizontal_set(box, EINA_TRUE);
321 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
322 evas_object_size_hint_align_set(box, 0.0, 0.9);
323 elm_table_pack(tb2, box, 0, 2, 1, 1);
324 evas_object_show(box);
325
326 bt = elm_button_add(win);
327 elm_object_text_set(bt, "Pause On/Off");
328 evas_object_smart_callback_add(bt, "clicked", my_bt_pause, ph);
329 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
330 elm_box_pack_end(box, bt);
331 evas_object_show(bt);
332
333 bt = elm_button_add(win);
334 elm_object_text_set(bt, "Gesture On/Off");
335 evas_object_smart_callback_add(bt, "clicked", my_bt_gesture, ph);
336 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
337 elm_box_pack_end(box, bt);
338 evas_object_show(bt);
339
340 box = elm_box_add(win);
341 elm_box_horizontal_set(box, EINA_TRUE);
342 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
343 evas_object_size_hint_align_set(box, 0.9, 0.9);
344 elm_table_pack(tb2, box, 2, 2, 1, 1);
345
346 bt = elm_button_add(win);
347 elm_object_text_set(bt, "Fit");
348 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit, ph);
349 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
350 elm_box_pack_end(box, bt);
351 evas_object_show(bt);
352
353 bt = elm_button_add(win);
354 elm_object_text_set(bt, "Fit_In");
355 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit_in, ph);
356 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
357 elm_box_pack_end(box, bt);
358 evas_object_show(bt);
359
360 bt = elm_button_add(win);
361 elm_object_text_set(bt, "Fill");
362 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fill, ph);
363 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
364 elm_box_pack_end(box, bt);
365 evas_object_show(bt);
366
367 evas_object_show(box);
368 evas_object_show(tb2);
369
370 evas_object_resize(win, 800, 800);
371 evas_object_show(win);
372}
373#endif