1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 static Evas_Object *rect;
10 my_ph_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
16 my_ph_press(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
22 my_ph_longpressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
24 printf("longpressed\n");
28 my_ph_clicked_double(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
30 printf("clicked,double\n");
34 my_ph_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
40 my_ph_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
46 my_ph_load_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
48 printf("load,details\n");
52 my_ph_loaded_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54 printf("loaded,details\n");
58 my_ph_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 printf("zoom,start\n");
64 my_ph_zoom_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
66 printf("zoom,stop\n");
70 my_ph_zoom_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
72 printf("zoom,change\n");
76 my_ph_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
78 printf("anim,start\n");
82 my_ph_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84 printf("anim,stop\n");
88 my_ph_drag_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
90 printf("drag,start\n");
94 my_ph_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
96 printf("drag_stop\n");
100 my_ph_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
103 elm_photocam_region_get(obj, &x, &y, &w, &h);
104 printf("scroll %i %i %ix%i\n", x, y, w, h);
108 my_bt_open(void *data, Evas_Object *obj __UNUSED__, void *event_info)
110 Evas_Object *ph = data;
111 const char *file = event_info;
114 elm_photocam_file_set(ph, file);
118 my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
120 elm_photocam_image_region_show(data, 30, 50, 500, 300);
124 my_bt_bring_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
127 elm_photocam_image_region_bring_in(data, 800, 300, 500, 300);
131 my_bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
135 zoom = elm_photocam_zoom_get(data);
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);
142 my_bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
146 zoom = elm_photocam_zoom_get(data);
148 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
149 if (zoom <= 256.0) elm_photocam_zoom_set(data, zoom);
153 my_bt_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
155 elm_photocam_paused_set(data, !elm_photocam_paused_get(data));
159 my_bt_zoom_fit_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
161 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT_IN);
165 my_bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
167 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
171 my_bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
173 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL);
177 _photocam_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
179 Evas_Object *photocam = data;
180 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
183 //unset the mouse wheel
184 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
186 zoom = elm_photocam_zoom_get(photocam);
187 if ((ev->z>0) && (zoom == 1)) return;
202 elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
203 if (zoom >= 1) elm_photocam_zoom_set(photocam, zoom);
207 _photocam_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
211 evas_object_geometry_get(data,&x,&y,&w,&h);
212 evas_object_resize(rect,w,h);
213 evas_object_move(rect,x,y);
217 test_photocam(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
219 Evas_Object *win, *bg, *ph, *tb2, *bt, *box;
220 // these were just testing - use the "select photo" browser to select one
223 "/home/raster/t1.jpg", // 5 mpixel
224 "/home/raster/t2.jpg", // 18 mpixel
225 "/home/raster/t3.jpg", // 39 mpixel
226 "/home/raster/t4.jpg", // 192 mpixel
227 "/home/raster/t5.jpg" // 466 mpixel
230 win = elm_win_add(NULL, "photocam", ELM_WIN_BASIC);
231 elm_win_title_set(win, "Photocam");
232 elm_win_autodel_set(win, EINA_TRUE);
234 bg = elm_bg_add(win);
235 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 elm_win_resize_object_add(win, bg);
237 evas_object_show(bg);
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);
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);
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);
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);
271 elm_photocam_file_set(ph, img[1]);
273 evas_object_show(ph);
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);
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);
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);
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);
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);
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);
319 bt = elm_button_add(win);
320 elm_object_text_set(bt, "Pause On/Off");
321 evas_object_smart_callback_add(bt, "clicked", my_bt_pause, ph);
322 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
323 evas_object_size_hint_align_set(bt, 0.1, 0.9);
324 elm_table_pack(tb2, bt, 0, 2, 1, 1);
325 evas_object_show(bt);
327 box = elm_box_add(win);
328 elm_box_horizontal_set(box, EINA_TRUE);
329 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
330 evas_object_size_hint_align_set(box, 0.9, 0.9);
331 elm_table_pack(tb2, box, 2, 2, 1, 1);
333 bt = elm_button_add(win);
334 elm_object_text_set(bt, "Fit");
335 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit, 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);
340 bt = elm_button_add(win);
341 elm_object_text_set(bt, "Fit_In");
342 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit_in, ph);
343 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
344 elm_box_pack_end(box, bt);
345 evas_object_show(bt);
347 bt = elm_button_add(win);
348 elm_object_text_set(bt, "Fill");
349 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fill, ph);
350 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
351 elm_box_pack_end(box, bt);
352 evas_object_show(bt);
354 evas_object_show(box);
355 evas_object_show(tb2);
357 evas_object_resize(win, 800, 800);
358 evas_object_show(win);